1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "products": [
12 {
13 "sku": "DEMO-01",
14 "salePrice": "40",
15 "currency": "USD",
16 "saleUnit": "each",
17 "targetMarginPct": "35"
18 },
19 {
20 "sku": "DEMO-02",
21 "salePrice": "80",
22 "currency": "USD",
23 "saleUnit": "each"
24 }
25 ],
26 "quotes": [
27 {
28 "quoteId": "Q-DEMO-01",
29 "sku": "DEMO-01",
30 "supplier": "Supplier Alpha (fictional)",
31 "currency": "USD",
32 "purchaseUnit": "each",
33 "moq": 12,
34 "packSize": 6,
35 "validUntil": "2027-12-31",
36 "tiers": [
37 {
38 "minQty": 1,
39 "unitPrice": "25"
40 },
41 {
42 "minQty": 24,
43 "unitPrice": "22"
44 }
45 ],
46 "costs": {
47 "freightTotal": "30",
48 "nonRecoverableTaxTotal": "0",
49 "otherLandedTotal": "0",
50 "salesCommissionPct": "5"
51 }
52 },
53 {
54 "quoteId": "Q-DEMO-02",
55 "sku": "DEMO-01",
56 "supplier": "Supplier Beta (fictional)",
57 "currency": "USD",
58 "purchaseUnit": "each",
59 "moq": 10,
60 "packSize": 10,
61 "validUntil": "2027-12-31",
62 "tiers": [
63 {
64 "minQty": 1,
65 "unitPrice": "24"
66 }
67 ],
68 "costs": {
69 "nonRecoverableTaxTotal": "0",
70 "otherLandedTotal": "0",
71 "salesCommissionPct": "0"
72 }
73 },
74 {
75 "quoteId": "Q-DEMO-03",
76 "sku": "DEMO-02",
77 "supplier": "Supplier Gamma (fictional)",
78 "currency": "CNY",
79 "purchaseUnit": "case",
80 "unitsPerPurchaseUnit": 12,
81 "moq": 2,
82 "packSize": 1,
83 "validUntil": "2027-12-31",
84 "tiers": [
85 {
86 "minQty": 1,
87 "unitPrice": "300"
88 }
89 ],
90 "costs": {
91 "freightTotal": "0",
92 "nonRecoverableTaxTotal": "0",
93 "otherLandedTotal": "0",
94 "salesCommissionPct": "2"
95 }
96 },
97 {
98 "quoteId": "Q-DEMO-04",
99 "sku": "DEMO-02",
100 "supplier": "Supplier Delta (fictional)",
101 "currency": "USD",
102 "purchaseUnit": "each",
103 "moq": 20,
104 "packSize": 5,
105 "validUntil": "2026-01-01",
106 "tiers": [
107 {
108 "minQty": 1,
109 "unitPrice": "45"
110 }
111 ],
112 "costs": {
113 "freightTotal": "20",
114 "nonRecoverableTaxTotal": "0",
115 "otherLandedTotal": "0",
116 "salesCommissionPct": "5"
117 }
118 }
119 ],
120 "requestedQuantity": 20,
121 "targetMarginPct": 35,
122 "targetCurrency": "USD",
123 "maxResults": 3
124};
125
126
127const run = await client.actor("afkdigital/restock-margin-guard").call(input);
128
129
130console.log('Results from dataset');
131console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
132const { items } = await client.dataset(run.defaultDatasetId).listItems();
133items.forEach((item) => {
134 console.dir(item);
135});
136
137