@foxtware/mineral 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.creds.yml.sample +27 -6
- package/AGENTS.md +6 -1
- package/README.md +1 -1
- package/api/bleckmann/.gitkeep +0 -0
- package/api/bleckmann/bleckmann.constants.js +8 -0
- package/api/bleckmann/bleckmann.utils.js +32 -0
- package/api/bleckmann/bleckmannAsnGet.js +52 -0
- package/api/bleckmann/bleckmannAsnsGet.js +65 -0
- package/api/constants.js +2 -1
- package/api/github/github.constants.js +11 -0
- package/api/github/github.utils.js +65 -0
- package/api/github/githubGet.js +144 -0
- package/api/github/githubIssueCreate.js +71 -0
- package/api/github/githubIssueGet.js +65 -0
- package/api/github/githubIssueUpdate.js +71 -0
- package/api/github/githubIssuesGet.js +74 -0
- package/api/github/githubPullRequestCreate.js +74 -0
- package/api/github/githubPullRequestGet.js +65 -0
- package/api/github/githubPullRequestMerge.js +77 -0
- package/api/github/githubPullRequestUpdate.js +72 -0
- package/api/github/githubPullRequestsGet.js +74 -0
- package/api/github/githubRepoCreate.js +80 -0
- package/api/github/githubRepoDelete.js +60 -0
- package/api/github/githubRepoGet.js +61 -0
- package/api/github/githubRepoUpdate.js +68 -0
- package/api/github/githubReposGet.js +69 -0
- package/api/github/githubUserGet.js +64 -0
- package/api/linear/linear.utils.js +9 -14
- package/api/linear/linearIssuesGet.js +9 -9
- package/api/logiwa/logiwa.utils.js +27 -25
- package/api/logiwa/logiwaInventoriesGet.js +5 -3
- package/api/logiwa/logiwaOrderGet.js +4 -2
- package/api/logiwa/logiwaOrdersGet.js +5 -3
- package/api/logiwa/logiwaProductGet.js +4 -2
- package/api/logiwa/logiwaProductsGet.js +5 -3
- package/api/logiwa/logiwaReportGetAvailableToPromise.js +5 -3
- package/api/logiwa/logiwaReportGetInventoryCalculation.js +5 -3
- package/api/logiwa/logiwaReportGetInventorySnapshot.js +5 -3
- package/api/logiwa/logiwaReportGetTotalInventory.js +5 -3
- package/api/logiwa/logiwaWebhookStatusGet.js +4 -2
- package/api/logiwa/logiwaWebhookSubscribe.js +8 -6
- package/api/logiwa/logiwaWebhookUnsubscribe.js +4 -2
- package/api/logiwa/logiwaWebhooksGet.js +4 -2
- package/api/loop/loop.utils.js +9 -15
- package/api/loop/loopGet.js +20 -24
- package/api/loop/loopReturnGet.js +6 -6
- package/api/peoplevox/peoplevox.constants.js +1 -1
- package/api/peoplevox/peoplevox.sessions.js +0 -33
- package/api/peoplevox/peoplevox.utils.js +63 -19
- package/api/peoplevox/peoplevoxGetSingle.js +7 -5
- package/api/peoplevox/peoplevoxOrderEdit.js +7 -5
- package/api/peoplevox/peoplevoxReportGet.js +11 -9
- package/api/pipelineSteps.js +49 -0
- package/api/shopify/shopify.utils.js +93 -22
- package/api/shopify/shopifyBulkMutationDo.js +211 -0
- package/api/shopify/shopifyBulkOperationGet.js +86 -0
- package/api/shopify/shopifyBulkOperationRunMutation.js +83 -0
- package/api/shopify/shopifyBulkOperationRunQuery.js +70 -0
- package/api/shopify/shopifyBulkQueryDo.js +127 -0
- package/api/shopify/shopifyCheckoutAndAccountsConfigurationUpdate.js +79 -0
- package/api/shopify/shopifyCollectionGet.js +6 -6
- package/api/shopify/shopifyCustomerGet.js +6 -6
- package/api/shopify/shopifyGet.js +18 -13
- package/api/shopify/shopifyGetSingle.js +9 -9
- package/api/shopify/shopifyMutationDo.js +6 -6
- package/api/shopify/shopifyOrdersGet.js +11 -11
- package/api/shopify/shopifyStagedUploadCreate.js +96 -0
- package/api/shopify/shopifyTagsAddBulk.js +77 -0
- package/api/slack/slack.utils.js +10 -19
- package/api/slack/slackMessagePost.js +11 -11
- package/api/starshipit/starshipit.constants.js +8 -0
- package/api/starshipit/starshipit.utils.js +71 -0
- package/api/starshipit/starshipitAddressCreate.js +77 -0
- package/api/starshipit/starshipitAddressDelete.js +55 -0
- package/api/starshipit/starshipitAddressUpdate.js +69 -0
- package/api/starshipit/starshipitAddressesGet.js +52 -0
- package/api/starshipit/starshipitGet.js +146 -0
- package/api/starshipit/starshipitOrderDelete.js +102 -0
- package/api/starshipit/starshipitOrderGet.js +74 -0
- package/api/starshipit/starshipitOrderUpdate.js +109 -0
- package/api/starshipit/starshipitOrdersListShipped.js +64 -0
- package/api/starshipit/starshipitProductAdd.js +100 -0
- package/api/starshipit/starshipitProductsDelete.js +57 -0
- package/api/starshipit/starshipitProductsGet.js +49 -0
- package/api/starshipit/starshipitTrackingGet.js +69 -0
- package/api/stripe/_example.js +7 -7
- package/api/stripe/stripe.utils.js +9 -14
- package/api/stripe/stripeCardTokenCreate.js +11 -11
- package/api/stripe/stripeChargeCapture.js +11 -11
- package/api/stripe/stripeChargeCreate.js +11 -11
- package/api/stripe/stripeChargeGet.js +5 -5
- package/api/stripe/stripeChargesGet.js +6 -6
- package/api/stripe/stripeRefundCreate.js +10 -10
- package/api/stripe/stripeRefundGet.js +5 -5
- package/api/stripe/stripeRefundsGet.js +6 -6
- package/api/stripe/stripeTokenGet.js +5 -5
- package/api/stylearcade/stylearcade.constants.js +5 -0
- package/api/stylearcade/stylearcade.utils.js +40 -0
- package/api/stylearcade/stylearcadeDataGet.js +62 -0
- package/api/stylearcade/stylearcadeGet.js +133 -0
- package/api/stylearcade/stylearcadeMetadataGet.js +47 -0
- package/api/threeclicks/threeclicks.constants.js +8 -0
- package/api/threeclicks/threeclicks.utils.js +119 -0
- package/api/threeclicks/threeclicksCollectionsGet.js +40 -0
- package/api/threeclicks/threeclicksGet.js +138 -0
- package/api/threeclicks/threeclicksKeycodeCreate.js +55 -0
- package/api/threeclicks/threeclicksKeycodeGet.js +47 -0
- package/api/threeclicks/threeclicksPurchaseOrderCreate.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderCreateBulk.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderGet.js +33 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantitiesGet.js +33 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityCreate.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityCreateBulk.js +34 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityUpdate.js +46 -0
- package/api/threeclicks/threeclicksPurchaseOrderQuantityUpdateBulk.js +46 -0
- package/api/threeclicks/threeclicksPurchaseOrderUpdate.js +35 -0
- package/api/threeclicks/threeclicksPurchaseOrdersGet.js +30 -0
- package/api/threeclicks/threeclicksShipmentCreate.js +34 -0
- package/api/threeclicks/threeclicksShipmentGet.js +33 -0
- package/api/threeclicks/threeclicksShipmentOrderAdd.js +38 -0
- package/api/threeclicks/threeclicksShipmentOrderQuantityCreate.js +35 -0
- package/api/threeclicks/threeclicksShipmentQuantityUpdate.js +35 -0
- package/api/threeclicks/threeclicksShipmentStatusUpdate.js +45 -0
- package/api/threeclicks/threeclicksShipmentsGet.js +52 -0
- package/api/threeclicks/threeclicksSignatureCalculate.js +73 -0
- package/api/threeclicks/threeclicksStyleCodesGet.js +46 -0
- package/api/threeclicks/threeclicksStyleColourCreate.js +47 -0
- package/api/threeclicks/threeclicksStyleColourDelete.js +34 -0
- package/api/threeclicks/threeclicksStyleCreate.js +44 -0
- package/api/threeclicks/threeclicksStyleDelete.js +33 -0
- package/api/threeclicks/threeclicksStyleGet.js +43 -0
- package/api/threeclicks/threeclicksStylePriceUpdate.js +70 -0
- package/api/threeclicks/threeclicksStyleUpdate.js +47 -0
- package/api/threeclicks/threeclicksStylesGet.js +45 -0
- package/api/utils.js +85 -117
- package/api/validators.js +1 -1
- package/api/workable/workable.utils.js +8 -13
- package/api/workable/workableGet.js +16 -11
- package/api/workable/workableJobCandidateCreate.js +10 -10
- package/api/workable/workableJobGet.js +5 -5
- package/api/workable/workableJobMembersGet.js +5 -5
- package/api/workable/workableJobStagesGet.js +5 -5
- package/api/yotpo/yotpo.utils.js +17 -22
- package/api/yotpo/yotpoCampaignsGet.js +6 -6
- package/api/yotpo/yotpoCustomerActionRecord.js +7 -7
- package/api/yotpo/yotpoCustomerAnniversaryGet.js +7 -7
- package/api/yotpo/yotpoCustomerAnniversarySet.js +7 -7
- package/api/yotpo/yotpoCustomerBirthdaySet.js +7 -7
- package/api/yotpo/yotpoCustomerGet.js +6 -6
- package/api/yotpo/yotpoCustomerPointsAdjust.js +7 -7
- package/api/yotpo/yotpoCustomerUpsert.js +7 -7
- package/api/yotpo/yotpoCustomersRecentGet.js +6 -6
- package/api/yotpo/yotpoRedemptionCreate.js +7 -7
- package/api/yotpo/yotpoRedemptionOptionsGet.js +6 -6
- package/api/yotpo/yotpoVipTiersGet.js +5 -5
- package/api/youtube/youtube.constants.js +5 -0
- package/api/youtube/youtube.utils.js +77 -0
- package/api/youtube/youtubeChannelVideosGet.js +25 -70
- package/package.json +1 -1
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
const { credsFromPayload, ArgsWarden, Getter } = require('../utils');
|
|
2
|
+
const { credsValidator } = require('../validators');
|
|
3
|
+
const { starshipitClient } = require('../starshipit/starshipit.utils');
|
|
4
|
+
const { MAX_PER_PAGE } = require('../starshipit/starshipit.constants');
|
|
5
|
+
|
|
6
|
+
const argsWarden = new ArgsWarden([
|
|
7
|
+
['credsPayload', credsValidator],
|
|
8
|
+
['url'],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const starshipitGetPacket = async (
|
|
12
|
+
creds,
|
|
13
|
+
url,
|
|
14
|
+
{
|
|
15
|
+
params,
|
|
16
|
+
perPage = MAX_PER_PAGE,
|
|
17
|
+
} = {},
|
|
18
|
+
) => {
|
|
19
|
+
return starshipitClient.fetch({
|
|
20
|
+
requestPayload: {
|
|
21
|
+
url,
|
|
22
|
+
params: {
|
|
23
|
+
page_size: perPage,
|
|
24
|
+
page_number: 1,
|
|
25
|
+
...params,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
context: {
|
|
29
|
+
creds,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const starshipitGetPaginator = async (currentParams, response) => {
|
|
35
|
+
if (!response?.ok) {
|
|
36
|
+
return [true];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
page_number: currentPage,
|
|
41
|
+
page_size: pageSize,
|
|
42
|
+
total_records: totalCount,
|
|
43
|
+
} = response.data || {};
|
|
44
|
+
|
|
45
|
+
if (!currentPage || !pageSize || !totalCount) {
|
|
46
|
+
return [true];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const done = currentPage * pageSize >= totalCount;
|
|
50
|
+
if (done) {
|
|
51
|
+
return [true];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const { args, options } = currentParams;
|
|
55
|
+
|
|
56
|
+
return [false, {
|
|
57
|
+
args,
|
|
58
|
+
options: {
|
|
59
|
+
...options,
|
|
60
|
+
params: {
|
|
61
|
+
...options.params,
|
|
62
|
+
page_number: currentPage + 1,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
}];
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const starshipitGet = async (
|
|
69
|
+
returnGetter,
|
|
70
|
+
|
|
71
|
+
credsPayload,
|
|
72
|
+
url,
|
|
73
|
+
{
|
|
74
|
+
params,
|
|
75
|
+
perPage = MAX_PER_PAGE,
|
|
76
|
+
nodeName = 'results',
|
|
77
|
+
...getterOptions
|
|
78
|
+
} = {},
|
|
79
|
+
) => {
|
|
80
|
+
|
|
81
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
82
|
+
credsPayload,
|
|
83
|
+
url,
|
|
84
|
+
});
|
|
85
|
+
if (rejectResponse) {
|
|
86
|
+
return rejectResponse;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const creds = await credsFromPayload(credsPayload);
|
|
90
|
+
|
|
91
|
+
const getter = new Getter(
|
|
92
|
+
{
|
|
93
|
+
args: [creds, url],
|
|
94
|
+
options: {
|
|
95
|
+
params,
|
|
96
|
+
perPage,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
func: starshipitGetPacket,
|
|
101
|
+
digester: (response) => {
|
|
102
|
+
if (!response?.ok) {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return response?.data?.[nodeName] ?? [];
|
|
107
|
+
},
|
|
108
|
+
paginator: starshipitGetPaginator,
|
|
109
|
+
...getterOptions,
|
|
110
|
+
},
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
if (returnGetter) {
|
|
114
|
+
return getter;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const data = await getter.run({ returnAll: true });
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
ok: true,
|
|
121
|
+
data,
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const funcApiConfig = {
|
|
126
|
+
argsWarden,
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
module.exports = {
|
|
130
|
+
starshipitGet: (...args) => starshipitGet(false, ...args),
|
|
131
|
+
starshipitGetter: (...args) => starshipitGet(true, ...args),
|
|
132
|
+
funcApiConfig,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/*
|
|
136
|
+
curl -X POST "http://localhost:8000/starshipitGet" \
|
|
137
|
+
-H "Content-Type: application/json" \
|
|
138
|
+
-d '{
|
|
139
|
+
"credsPayload": { "credsPath": "starshipit.acc" },
|
|
140
|
+
"url": "/products",
|
|
141
|
+
"options": {
|
|
142
|
+
"nodeName": "products",
|
|
143
|
+
"limit": 10
|
|
144
|
+
}
|
|
145
|
+
}'
|
|
146
|
+
*/
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// https://api-docs.starshipit.com/#c96bed4f-3a89-4e97-abaa-b1775cc7c5a7
|
|
2
|
+
|
|
3
|
+
const { objHasAny, ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { starshipitClient } = require('../starshipit/starshipit.utils');
|
|
6
|
+
const { starshipitOrderGet } = require('../starshipit/starshipitOrderGet');
|
|
7
|
+
|
|
8
|
+
const orderIdentifierValidator = (orderIdentifier) => {
|
|
9
|
+
return objHasAny(orderIdentifier, [
|
|
10
|
+
'orderId',
|
|
11
|
+
'orderNumber',
|
|
12
|
+
]);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const argsWarden = new ArgsWarden([
|
|
16
|
+
['credsPayload', credsValidator],
|
|
17
|
+
['orderIdentifier', orderIdentifierValidator],
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
const resolveOrderId = async (credsPayload, orderIdentifier) => {
|
|
21
|
+
const { orderId, orderNumber } = orderIdentifier;
|
|
22
|
+
|
|
23
|
+
if (orderId) {
|
|
24
|
+
return {
|
|
25
|
+
ok: true,
|
|
26
|
+
data: orderId,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const orderResponse = await starshipitOrderGet(credsPayload, { orderNumber });
|
|
31
|
+
|
|
32
|
+
if (!orderResponse?.ok) {
|
|
33
|
+
return orderResponse;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const resolvedOrderId = orderResponse?.data?.order_id;
|
|
37
|
+
|
|
38
|
+
if (!resolvedOrderId) {
|
|
39
|
+
return {
|
|
40
|
+
ok: false,
|
|
41
|
+
error: {
|
|
42
|
+
code: 'ORDER_NOT_FOUND',
|
|
43
|
+
message: 'No order ID found',
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
ok: true,
|
|
50
|
+
data: resolvedOrderId,
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const starshipitOrderDelete = async (
|
|
55
|
+
credsPayload,
|
|
56
|
+
orderIdentifier,
|
|
57
|
+
) => {
|
|
58
|
+
|
|
59
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
60
|
+
credsPayload,
|
|
61
|
+
orderIdentifier,
|
|
62
|
+
});
|
|
63
|
+
if (rejectResponse) {
|
|
64
|
+
return rejectResponse;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const orderIdResponse = await resolveOrderId(credsPayload, orderIdentifier);
|
|
68
|
+
if (!orderIdResponse?.ok) {
|
|
69
|
+
return orderIdResponse;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return starshipitClient.fetch({
|
|
73
|
+
requestPayload: {
|
|
74
|
+
url: '/orders/delete',
|
|
75
|
+
method: 'delete',
|
|
76
|
+
params: {
|
|
77
|
+
order_id: orderIdResponse.data,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
context: {
|
|
81
|
+
credsPayload,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const funcApiConfig = {
|
|
87
|
+
argsWarden,
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
module.exports = {
|
|
91
|
+
starshipitOrderDelete,
|
|
92
|
+
funcApiConfig,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/*
|
|
96
|
+
curl -X POST "http://localhost:8000/starshipitOrderDelete" \
|
|
97
|
+
-H "Content-Type: application/json" \
|
|
98
|
+
-d '{
|
|
99
|
+
"credsPayload": { "credsPath": "starshipit.acc" },
|
|
100
|
+
"orderIdentifier": { "orderId": "408418809" }
|
|
101
|
+
}'
|
|
102
|
+
*/
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const { objHasAny, ArgsWarden } = require('../utils');
|
|
2
|
+
const { credsValidator } = require('../validators');
|
|
3
|
+
const { starshipitClient } = require('../starshipit/starshipit.utils');
|
|
4
|
+
|
|
5
|
+
const orderIdentifierValidator = (orderIdentifier) => {
|
|
6
|
+
return objHasAny(orderIdentifier, [
|
|
7
|
+
'orderId',
|
|
8
|
+
'orderNumber',
|
|
9
|
+
]);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const argsWarden = new ArgsWarden([
|
|
13
|
+
['credsPayload', credsValidator],
|
|
14
|
+
['orderIdentifier', orderIdentifierValidator],
|
|
15
|
+
]);
|
|
16
|
+
|
|
17
|
+
const starshipitOrderGet = async (
|
|
18
|
+
credsPayload,
|
|
19
|
+
orderIdentifier,
|
|
20
|
+
) => {
|
|
21
|
+
|
|
22
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
23
|
+
credsPayload,
|
|
24
|
+
orderIdentifier,
|
|
25
|
+
});
|
|
26
|
+
if (rejectResponse) {
|
|
27
|
+
return rejectResponse;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
orderId,
|
|
32
|
+
orderNumber,
|
|
33
|
+
} = orderIdentifier;
|
|
34
|
+
|
|
35
|
+
const response = await starshipitClient.fetch({
|
|
36
|
+
requestPayload: {
|
|
37
|
+
url: '/orders',
|
|
38
|
+
params: {
|
|
39
|
+
...orderId && { order_id: orderId },
|
|
40
|
+
...orderNumber && { order_number: orderNumber },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
context: {
|
|
44
|
+
credsPayload,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (!response?.ok) {
|
|
49
|
+
return response;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
...response,
|
|
54
|
+
data: response.data?.order ?? response.data,
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const funcApiConfig = {
|
|
59
|
+
argsWarden,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
module.exports = {
|
|
63
|
+
starshipitOrderGet,
|
|
64
|
+
funcApiConfig,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/*
|
|
68
|
+
curl -X POST "http://localhost:8000/starshipitOrderGet" \
|
|
69
|
+
-H "Content-Type: application/json" \
|
|
70
|
+
-d '{
|
|
71
|
+
"credsPayload": { "credsPath": "starshipit.acc" },
|
|
72
|
+
"orderIdentifier": { "orderId": 408418809 }
|
|
73
|
+
}'
|
|
74
|
+
*/
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// https://api-docs.starshipit.com/#c96bed4f-3a89-4e97-abaa-b1775cc7c5a7
|
|
2
|
+
|
|
3
|
+
const { objHasAny, ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { starshipitClient } = require('../starshipit/starshipit.utils');
|
|
6
|
+
const { starshipitOrderGet } = require('../starshipit/starshipitOrderGet');
|
|
7
|
+
|
|
8
|
+
const orderIdentifierValidator = (orderIdentifier) => {
|
|
9
|
+
return objHasAny(orderIdentifier, [
|
|
10
|
+
'orderId',
|
|
11
|
+
'orderNumber',
|
|
12
|
+
]);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const argsWarden = new ArgsWarden([
|
|
16
|
+
['credsPayload', credsValidator],
|
|
17
|
+
['orderIdentifier', orderIdentifierValidator],
|
|
18
|
+
['updatePayload'],
|
|
19
|
+
]);
|
|
20
|
+
|
|
21
|
+
const resolveOrderId = async (credsPayload, orderIdentifier) => {
|
|
22
|
+
const { orderId, orderNumber } = orderIdentifier;
|
|
23
|
+
|
|
24
|
+
if (orderId) {
|
|
25
|
+
return {
|
|
26
|
+
ok: true,
|
|
27
|
+
data: orderId,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const orderResponse = await starshipitOrderGet(credsPayload, { orderNumber });
|
|
32
|
+
|
|
33
|
+
if (!orderResponse?.ok) {
|
|
34
|
+
return orderResponse;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const resolvedOrderId = orderResponse?.data?.order_id;
|
|
38
|
+
|
|
39
|
+
if (!resolvedOrderId) {
|
|
40
|
+
return {
|
|
41
|
+
ok: false,
|
|
42
|
+
error: {
|
|
43
|
+
code: 'ORDER_NOT_FOUND',
|
|
44
|
+
message: 'No order ID found',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
ok: true,
|
|
51
|
+
data: resolvedOrderId,
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const starshipitOrderUpdate = async (
|
|
56
|
+
credsPayload,
|
|
57
|
+
orderIdentifier,
|
|
58
|
+
updatePayload,
|
|
59
|
+
) => {
|
|
60
|
+
|
|
61
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
62
|
+
credsPayload,
|
|
63
|
+
orderIdentifier,
|
|
64
|
+
updatePayload,
|
|
65
|
+
});
|
|
66
|
+
if (rejectResponse) {
|
|
67
|
+
return rejectResponse;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const orderIdResponse = await resolveOrderId(credsPayload, orderIdentifier);
|
|
71
|
+
if (!orderIdResponse?.ok) {
|
|
72
|
+
return orderIdResponse;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return starshipitClient.fetch({
|
|
76
|
+
requestPayload: {
|
|
77
|
+
url: '/orders',
|
|
78
|
+
method: 'put',
|
|
79
|
+
body: {
|
|
80
|
+
order: {
|
|
81
|
+
order_id: orderIdResponse.data,
|
|
82
|
+
...updatePayload,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
context: {
|
|
87
|
+
credsPayload,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const funcApiConfig = {
|
|
93
|
+
argsWarden,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
module.exports = {
|
|
97
|
+
starshipitOrderUpdate,
|
|
98
|
+
funcApiConfig,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/*
|
|
102
|
+
curl -X POST "http://localhost:8000/starshipitOrderUpdate" \
|
|
103
|
+
-H "Content-Type: application/json" \
|
|
104
|
+
-d '{
|
|
105
|
+
"credsPayload": { "credsPath": "starshipit.acc" },
|
|
106
|
+
"orderIdentifier": { "orderNumber": "7029471248456" },
|
|
107
|
+
"updatePayload": { "destination": { "name": "Big Dog" } }
|
|
108
|
+
}'
|
|
109
|
+
*/
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// https://api-docs.starshipit.com/#abbdf631-21c8-472b-b2e7-b1b68b01f6d0
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { starshipitClient } = require('../starshipit/starshipit.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const starshipitOrdersListShipped = async (
|
|
12
|
+
credsPayload,
|
|
13
|
+
{
|
|
14
|
+
sinceLastUpdated,
|
|
15
|
+
idsOnly,
|
|
16
|
+
perPage,
|
|
17
|
+
} = {},
|
|
18
|
+
) => {
|
|
19
|
+
|
|
20
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
21
|
+
if (rejectResponse) {
|
|
22
|
+
return rejectResponse;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const response = await starshipitClient.fetch({
|
|
26
|
+
requestPayload: {
|
|
27
|
+
url: '/orders/shipped',
|
|
28
|
+
params: {
|
|
29
|
+
...sinceLastUpdated && { since_last_updated: sinceLastUpdated },
|
|
30
|
+
...idsOnly && { ids_only: idsOnly },
|
|
31
|
+
...perPage && { limit: perPage },
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
context: {
|
|
35
|
+
credsPayload,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (!response?.ok) {
|
|
40
|
+
return response;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
...response,
|
|
45
|
+
data: response.data?.orders || response.data?.order_ids || response.data,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const funcApiConfig = {
|
|
50
|
+
argsWarden,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
module.exports = {
|
|
54
|
+
starshipitOrdersListShipped,
|
|
55
|
+
funcApiConfig,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
curl -X POST "http://localhost:8000/starshipitOrdersListShipped" \
|
|
60
|
+
-H "Content-Type: application/json" \
|
|
61
|
+
-d '{
|
|
62
|
+
"credsPayload": { "credsPath": "starshipit.acc" }
|
|
63
|
+
}'
|
|
64
|
+
*/
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// https://api-docs.starshipit.com/#8cfbd1b2-bd08-4cec-966f-7104cc147aee
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { starshipitClient } = require('../starshipit/starshipit.utils');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
['sku'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const starshipitProductAdd = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
sku,
|
|
15
|
+
{
|
|
16
|
+
title,
|
|
17
|
+
customsDescription,
|
|
18
|
+
description,
|
|
19
|
+
country,
|
|
20
|
+
weight,
|
|
21
|
+
height,
|
|
22
|
+
length,
|
|
23
|
+
width,
|
|
24
|
+
hsCode,
|
|
25
|
+
color,
|
|
26
|
+
size,
|
|
27
|
+
barcode,
|
|
28
|
+
binLocation,
|
|
29
|
+
brand,
|
|
30
|
+
usage,
|
|
31
|
+
material,
|
|
32
|
+
model,
|
|
33
|
+
mid,
|
|
34
|
+
price,
|
|
35
|
+
dangerousGoodsType,
|
|
36
|
+
} = {},
|
|
37
|
+
) => {
|
|
38
|
+
|
|
39
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
40
|
+
credsPayload,
|
|
41
|
+
sku,
|
|
42
|
+
});
|
|
43
|
+
if (rejectResponse) {
|
|
44
|
+
return rejectResponse;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return starshipitClient.fetch({
|
|
48
|
+
requestPayload: {
|
|
49
|
+
url: '/products',
|
|
50
|
+
method: 'post',
|
|
51
|
+
body: {
|
|
52
|
+
product: {
|
|
53
|
+
sku,
|
|
54
|
+
...title && { title },
|
|
55
|
+
...customsDescription && { customs_description: customsDescription },
|
|
56
|
+
...description && { description },
|
|
57
|
+
...country && { country },
|
|
58
|
+
...weight && { weight },
|
|
59
|
+
...height && { height },
|
|
60
|
+
...length && { length },
|
|
61
|
+
...width && { width },
|
|
62
|
+
...hsCode && { hs_code: hsCode },
|
|
63
|
+
...color && { color },
|
|
64
|
+
...size && { size },
|
|
65
|
+
...barcode && { barcode },
|
|
66
|
+
...binLocation && { bin_location: binLocation },
|
|
67
|
+
...brand && { brand },
|
|
68
|
+
...usage && { usage },
|
|
69
|
+
...material && { material },
|
|
70
|
+
...model && { model },
|
|
71
|
+
...mid && { mid },
|
|
72
|
+
...price && { price },
|
|
73
|
+
...dangerousGoodsType && { dangerous_goods_type: dangerousGoodsType },
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
context: {
|
|
78
|
+
credsPayload,
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const funcApiConfig = {
|
|
84
|
+
argsWarden,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
module.exports = {
|
|
88
|
+
starshipitProductAdd,
|
|
89
|
+
funcApiConfig,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/*
|
|
93
|
+
curl -X POST "http://localhost:8000/starshipitProductAdd" \
|
|
94
|
+
-H "Content-Type: application/json" \
|
|
95
|
+
-d '{
|
|
96
|
+
"credsPayload": { "credsPath": "starshipit.acc" },
|
|
97
|
+
"sku": "WFAL48-1-S",
|
|
98
|
+
"options": { "title": "Example Product" }
|
|
99
|
+
}'
|
|
100
|
+
*/
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// https://api-docs.starshipit.com/#5edb43f1-432b-4d1a-bb31-e05db0c879e3
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { starshipitClient } = require('../starshipit/starshipit.utils');
|
|
6
|
+
|
|
7
|
+
const productIdsValidator = (productIds) => Array.isArray(productIds) && productIds.length > 0;
|
|
8
|
+
|
|
9
|
+
const argsWarden = new ArgsWarden([
|
|
10
|
+
['credsPayload', credsValidator],
|
|
11
|
+
['productIds', productIdsValidator],
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
const starshipitProductsDelete = async (
|
|
15
|
+
credsPayload,
|
|
16
|
+
productIds,
|
|
17
|
+
) => {
|
|
18
|
+
|
|
19
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
20
|
+
credsPayload,
|
|
21
|
+
productIds,
|
|
22
|
+
});
|
|
23
|
+
if (rejectResponse) {
|
|
24
|
+
return rejectResponse;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return starshipitClient.fetch({
|
|
28
|
+
requestPayload: {
|
|
29
|
+
url: '/products/delete',
|
|
30
|
+
method: 'delete',
|
|
31
|
+
body: {
|
|
32
|
+
product_ids: productIds,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
context: {
|
|
36
|
+
credsPayload,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const funcApiConfig = {
|
|
42
|
+
argsWarden,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
module.exports = {
|
|
46
|
+
starshipitProductsDelete,
|
|
47
|
+
funcApiConfig,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/*
|
|
51
|
+
curl -X POST "http://localhost:8000/starshipitProductsDelete" \
|
|
52
|
+
-H "Content-Type: application/json" \
|
|
53
|
+
-d '{
|
|
54
|
+
"credsPayload": { "credsPath": "starshipit.acc" },
|
|
55
|
+
"productIds": [5585356]
|
|
56
|
+
}'
|
|
57
|
+
*/
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// https://api-docs.starshipit.com/#ccf0f10f-e370-45c0-ba5c-13bfaac80ca6
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { starshipitGet } = require('../starshipit/starshipitGet');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const starshipitProductsGet = async (
|
|
12
|
+
credsPayload,
|
|
13
|
+
{
|
|
14
|
+
searchTerm,
|
|
15
|
+
...getterOptions
|
|
16
|
+
} = {},
|
|
17
|
+
) => {
|
|
18
|
+
|
|
19
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
20
|
+
if (rejectResponse) {
|
|
21
|
+
return rejectResponse;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return starshipitGet(credsPayload, '/products', {
|
|
25
|
+
nodeName: 'products',
|
|
26
|
+
params: {
|
|
27
|
+
...searchTerm && { search_term: searchTerm },
|
|
28
|
+
},
|
|
29
|
+
...getterOptions,
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const funcApiConfig = {
|
|
34
|
+
argsWarden,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
module.exports = {
|
|
38
|
+
starshipitProductsGet,
|
|
39
|
+
funcApiConfig,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
curl -X POST "http://localhost:8000/starshipitProductsGet" \
|
|
44
|
+
-H "Content-Type: application/json" \
|
|
45
|
+
-d '{
|
|
46
|
+
"credsPayload": { "credsPath": "starshipit.acc" },
|
|
47
|
+
"options": { "searchTerm": "WFAL48-1-S" }
|
|
48
|
+
}'
|
|
49
|
+
*/
|