1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "payload": {
12 "title": "Example custom gift box",
13 "base_price_cents": 2500,
14 "currency": "USD",
15 "options": [
16 {
17 "id": "size",
18 "label": "Box size",
19 "values": [
20 {
21 "id": "small",
22 "label": "Small",
23 "price_cents": 0
24 },
25 {
26 "id": "large",
27 "label": "Large",
28 "price_cents": 1200
29 }
30 ]
31 },
32 {
33 "id": "finish",
34 "label": "Ribbon finish",
35 "values": [
36 {
37 "id": "cotton",
38 "label": "Cotton",
39 "price_cents": 0
40 },
41 {
42 "id": "satin",
43 "label": "Satin",
44 "price_cents": 400
45 }
46 ]
47 },
48 {
49 "id": "card",
50 "label": "Gift card",
51 "values": [
52 {
53 "id": "none",
54 "label": "No card",
55 "price_cents": 0
56 },
57 {
58 "id": "foil",
59 "label": "Foil card",
60 "price_cents": 300
61 }
62 ]
63 }
64 ],
65 "rules": [
66 {
67 "if": {
68 "size": "small"
69 },
70 "exclude": {
71 "card": [
72 "foil"
73 ]
74 }
75 }
76 ]
77 }
78};
79
80
81const run = await client.actor("usta/optionforge-product-option-configurator").call(input);
82
83
84console.log('Results from dataset');
85console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
86const { items } = await client.dataset(run.defaultDatasetId).listItems();
87items.forEach((item) => {
88 console.dir(item);
89});
90
91