1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "cartsFile": {
10 "format": "json",
11 "content": "[{\"cart_id\": \"DEMO-1\", \"currency\": \"USD\", \"items\": [{\"sku\": \"A\", \"quantity\": 1, \"unit_price\": \"100.00\"}]}]",
12 },
13 "productCostsFile": {
14 "format": "json",
15 "content": "[{\"sku\": \"A\", \"currency\": \"USD\", \"unit_cost\": \"60.00\"}]",
16 },
17 "promotionRules": [
18 {
19 "id": "TENPCT",
20 "type": "percent",
21 "scope": "cart",
22 "value": "10",
23 },
24 {
25 "id": "TENUSD",
26 "type": "fixed",
27 "scope": "cart",
28 "value": "10",
29 },
30 {
31 "id": "SHIP",
32 "type": "free_shipping",
33 },
34 ],
35 "rulePriority": [
36 "TENPCT",
37 "TENUSD",
38 "SHIP",
39 ],
40 "scenarios": [
41 [
42 "TENPCT",
43 "TENUSD",
44 ],
45 [
46 "TENPCT",
47 "TENUSD",
48 "SHIP",
49 ],
50 ],
51 "shippingInputs": { "DEMO-1": {
52 "revenue": "10",
53 "cost": "7",
54 "variable_cost": "3",
55 } },
56 "roundingPolicy": {
57 "mode": "HALF_UP",
58 "decimals": 2,
59 },
60 "marginThreshold": {
61 "type": "amount",
62 "value": "25",
63 },
64 "maxScenarios": 100,
65}
66
67
68run = client.actor("afkdigital/newapi90-promotion-stacking-simulator").call(run_input=run_input)
69
70
71print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
72for item in client.dataset(run.default_dataset_id).iterate_items():
73 print(item)
74
75