@foxtware/mineral 0.1.8 → 0.1.10
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 +43 -1
- 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.constants.js +7 -0
- package/api/loop/loop.utils.js +37 -0
- package/api/loop/loopAllowlistItemsGet.js +42 -0
- package/api/loop/loopBlocklistItemsGet.js +46 -0
- package/api/loop/loopDestinationsGet.js +42 -0
- package/api/loop/loopGet.js +139 -0
- package/api/loop/loopReturnGet.js +73 -0
- package/api/loop/loopReturnsGet.js +46 -0
- package/api/peoplevox/peoplevox.constants.js +1 -1
- package/api/peoplevox/peoplevox.sessions.js +54 -0
- package/api/peoplevox/peoplevox.utils.js +67 -31
- 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 +18 -24
- package/api/shopify/shopifyBulkMutationDo.js +211 -0
- package/api/shopify/shopifyBulkOperationGet.js +86 -0
- package/api/shopify/shopifyBulkOperationRunMutation.js +83 -0
- package/api/shopify/shopifyCheckoutAndAccountsConfigurationUpdate.js +79 -0
- package/api/shopify/shopifyCollectionGet.js +7 -7
- 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/shopifyTagsAdd.js +1 -1
- package/api/shopify/shopifyTagsAddBulk.js +90 -0
- package/api/shopify/shopifyTagsRemove.js +1 -1
- 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 +48 -0
- package/api/stripe/stripe.constants.js +5 -0
- package/api/stripe/stripe.utils.js +42 -0
- package/api/stripe/stripeCardCharge.js +98 -0
- package/api/stripe/stripeCardTokenCreate.js +70 -0
- package/api/stripe/stripeChargeCapture.js +63 -0
- package/api/stripe/stripeChargeCreate.js +70 -0
- package/api/stripe/stripeChargeGet.js +51 -0
- package/api/stripe/stripeChargesGet.js +52 -0
- package/api/stripe/stripeRefundCreate.js +64 -0
- package/api/stripe/stripeRefundGet.js +51 -0
- package/api/stripe/stripeRefundsGet.js +52 -0
- package/api/stripe/stripeTokenGet.js +51 -0
- 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/supabase/supabase.utils.js +52 -0
- package/api/supabase/supabaseRowDelete.js +95 -0
- package/api/supabase/supabaseRowGet.js +58 -0
- package/api/supabase/supabaseRowInsert.js +56 -0
- package/api/supabase/supabaseRowUpdate.js +58 -0
- package/api/supabase/supabaseRpc.js +61 -0
- package/api/supabase/supabaseTableGet.js +44 -0
- package/api/supabase/supabaseTableGetAll.js +86 -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/upstash/upstash.utils.js +36 -0
- package/api/upstash/upstashDel.js +46 -0
- package/api/upstash/upstashExists.js +46 -0
- package/api/upstash/upstashGet.js +46 -0
- package/api/upstash/upstashSet.js +64 -0
- package/api/utils.js +90 -76
- package/api/validators.js +1 -1
- package/api/workable/workable.constants.js +3 -0
- package/api/workable/workable.utils.js +41 -0
- package/api/workable/workableGet.js +151 -0
- package/api/workable/workableJobCandidateCreate.js +87 -0
- package/api/workable/workableJobGet.js +52 -0
- package/api/workable/workableJobMembersGet.js +52 -0
- package/api/workable/workableJobStagesGet.js +52 -0
- package/api/workable/workableJobsGet.js +78 -0
- 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/hosting/.hosting.yml.sample +9 -11
- package/hosting/copyCredsToEnv.js +58 -2
- package/hosting/deployFromHostingYml.js +9 -2
- package/hosting/hosting.utils.js +3 -2
- package/package.json +3 -1
- package/server.utils.js +1 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// https://workable.readme.io/reference/jobs
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { workableGet } = require('../workable/workableGet');
|
|
6
|
+
const { MAX_PER_PAGE } = require('../workable/workable.constants');
|
|
7
|
+
|
|
8
|
+
const argsWarden = new ArgsWarden([
|
|
9
|
+
['credsPayload', credsValidator],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const workableJobsGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
{
|
|
15
|
+
state,
|
|
16
|
+
sinceId,
|
|
17
|
+
maxId,
|
|
18
|
+
createdAfter,
|
|
19
|
+
updatedAfter,
|
|
20
|
+
includeFields,
|
|
21
|
+
perPage,
|
|
22
|
+
...getterOptions
|
|
23
|
+
} = {},
|
|
24
|
+
) => {
|
|
25
|
+
|
|
26
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
27
|
+
if (rejectResponse) {
|
|
28
|
+
return rejectResponse;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const normalisedIncludeFields = Array.isArray(includeFields)
|
|
32
|
+
? includeFields.join(',')
|
|
33
|
+
: includeFields;
|
|
34
|
+
|
|
35
|
+
const params = {
|
|
36
|
+
...state !== undefined && { state },
|
|
37
|
+
...sinceId !== undefined && { since_id: sinceId },
|
|
38
|
+
...maxId !== undefined && { max_id: maxId },
|
|
39
|
+
...createdAfter !== undefined && { created_after: createdAfter },
|
|
40
|
+
...updatedAfter !== undefined && { updated_after: updatedAfter },
|
|
41
|
+
...normalisedIncludeFields !== undefined && { include_fields: normalisedIncludeFields },
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return workableGet(credsPayload, '/jobs', {
|
|
45
|
+
params,
|
|
46
|
+
perPage: perPage ?? MAX_PER_PAGE,
|
|
47
|
+
resultsKey: 'jobs',
|
|
48
|
+
...getterOptions,
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const funcApiConfig = {
|
|
53
|
+
argsWarden,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
module.exports = {
|
|
57
|
+
workableJobsGet,
|
|
58
|
+
funcApiConfig,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
curl -X POST "http://localhost:8000/workableJobsGet" \
|
|
63
|
+
-H "Content-Type: application/json" \
|
|
64
|
+
-d '{
|
|
65
|
+
"credsPayload": { "credsPath": "workable" }
|
|
66
|
+
}'
|
|
67
|
+
|
|
68
|
+
curl -X POST "http://localhost:8000/workableJobsGet" \
|
|
69
|
+
-H "Content-Type: application/json" \
|
|
70
|
+
-d '{
|
|
71
|
+
"credsPayload": { "credsPath": "workable" },
|
|
72
|
+
"options": {
|
|
73
|
+
"state": "published",
|
|
74
|
+
"perPage": 10,
|
|
75
|
+
"includeFields": ["description", "requirements"]
|
|
76
|
+
}
|
|
77
|
+
}'
|
|
78
|
+
*/
|
package/api/yotpo/yotpo.utils.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const {
|
|
2
|
-
BASE_URL,
|
|
3
|
-
DEFAULT_API_VERSION,
|
|
1
|
+
const {
|
|
2
|
+
BASE_URL,
|
|
3
|
+
DEFAULT_API_VERSION,
|
|
4
4
|
} = require('../yotpo/yotpo.constants');
|
|
5
|
-
const {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
appendUrlToBase,
|
|
9
|
-
fetchClientCommonSteps,
|
|
5
|
+
const { resolveCreds } = require('../pipelineSteps');
|
|
6
|
+
const {
|
|
7
|
+
FetchClient,
|
|
8
|
+
appendUrlToBase,
|
|
9
|
+
fetchClientCommonSteps,
|
|
10
10
|
} = require('../utils');
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const useUrlAndAuthHeaders = async (state) => {
|
|
13
13
|
const { requestPayload, context } = state;
|
|
14
|
-
const {
|
|
14
|
+
const { apiVersion = DEFAULT_API_VERSION, creds } = context;
|
|
15
15
|
const { API_KEY, GUID } = creds;
|
|
16
16
|
|
|
17
17
|
return {
|
|
@@ -19,7 +19,6 @@ const addUrlAndAuthHeaders = async (state) => {
|
|
|
19
19
|
...requestPayload,
|
|
20
20
|
url: appendUrlToBase(`${ BASE_URL }/${ apiVersion }`, requestPayload.url),
|
|
21
21
|
headers: {
|
|
22
|
-
'Content-Type': 'application/json',
|
|
23
22
|
'x-api-key': API_KEY,
|
|
24
23
|
'x-guid': GUID,
|
|
25
24
|
...requestPayload.headers,
|
|
@@ -28,18 +27,14 @@ const addUrlAndAuthHeaders = async (state) => {
|
|
|
28
27
|
};
|
|
29
28
|
};
|
|
30
29
|
|
|
31
|
-
const yotpoClientRequestPreparer = new Chain([
|
|
32
|
-
addUrlAndAuthHeaders,
|
|
33
|
-
]);
|
|
34
|
-
|
|
35
|
-
const yotpoClientResponseInterpreter = new Chain([
|
|
36
|
-
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
37
|
-
fetchClientCommonSteps.digToPath,
|
|
38
|
-
]);
|
|
39
|
-
|
|
40
30
|
const yotpoClient = new FetchClient({
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
pipeline: [
|
|
32
|
+
resolveCreds,
|
|
33
|
+
useUrlAndAuthHeaders,
|
|
34
|
+
'fetch',
|
|
35
|
+
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
36
|
+
fetchClientCommonSteps.digToPath,
|
|
37
|
+
],
|
|
43
38
|
});
|
|
44
39
|
|
|
45
40
|
module.exports = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://loyaltyapi.yotpo.com/reference/get-active-campaigns
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
4
|
const { credsValidator } = require('../validators');
|
|
5
5
|
const { yotpoClient } = require('../yotpo/yotpo.utils');
|
|
6
6
|
|
|
@@ -22,8 +22,6 @@ const yotpoCampaignsGet = async (
|
|
|
22
22
|
return rejectResponse;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const creds = await credsFromPayload(credsPayload);
|
|
26
|
-
|
|
27
25
|
const {
|
|
28
26
|
customerId,
|
|
29
27
|
customerEmail,
|
|
@@ -36,10 +34,12 @@ const yotpoCampaignsGet = async (
|
|
|
36
34
|
};
|
|
37
35
|
|
|
38
36
|
const response = await yotpoClient.fetch({
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
requestPayload: {
|
|
38
|
+
url: '/campaigns',
|
|
39
|
+
params,
|
|
40
|
+
},
|
|
41
41
|
context: {
|
|
42
|
-
|
|
42
|
+
credsPayload,
|
|
43
43
|
apiVersion,
|
|
44
44
|
},
|
|
45
45
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://loyaltyapi.yotpo.com/reference/record-a-customer-action
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { objHasAny, ArgsWarden } = require('../utils');
|
|
4
4
|
const { credsValidator } = require('../validators');
|
|
5
5
|
const { yotpoClient } = require('../yotpo/yotpo.utils');
|
|
6
6
|
|
|
@@ -43,8 +43,6 @@ const yotpoCustomerActionRecord = async (
|
|
|
43
43
|
return rejectResponse;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const creds = await credsFromPayload(credsPayload);
|
|
47
|
-
|
|
48
46
|
const {
|
|
49
47
|
customerId,
|
|
50
48
|
customerEmail,
|
|
@@ -63,11 +61,13 @@ const yotpoCustomerActionRecord = async (
|
|
|
63
61
|
};
|
|
64
62
|
|
|
65
63
|
const response = await yotpoClient.fetch({
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
requestPayload: {
|
|
65
|
+
url: '/actions',
|
|
66
|
+
method: 'post',
|
|
67
|
+
body,
|
|
68
|
+
},
|
|
69
69
|
context: {
|
|
70
|
-
|
|
70
|
+
credsPayload,
|
|
71
71
|
apiVersion,
|
|
72
72
|
},
|
|
73
73
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://loyaltyapi.yotpo.com/reference/get-customer-anniversary
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
4
|
const { credsValidator } = require('../validators');
|
|
5
5
|
const { yotpoClient } = require('../yotpo/yotpo.utils');
|
|
6
6
|
|
|
@@ -25,15 +25,15 @@ const yotpoCustomerAnniversaryGet = async (
|
|
|
25
25
|
return rejectResponse;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
const creds = await credsFromPayload(credsPayload);
|
|
29
|
-
|
|
30
28
|
const response = await yotpoClient.fetch({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
requestPayload: {
|
|
30
|
+
url: '/customer_anniversary',
|
|
31
|
+
params: {
|
|
32
|
+
customer_email: customerEmail,
|
|
33
|
+
},
|
|
34
34
|
},
|
|
35
35
|
context: {
|
|
36
|
-
|
|
36
|
+
credsPayload,
|
|
37
37
|
apiVersion,
|
|
38
38
|
},
|
|
39
39
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://loyaltyapi.yotpo.com/reference/createupdate-customer-anniversary
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
4
|
const { credsValidator } = require('../validators');
|
|
5
5
|
const { yotpoClient } = require('../yotpo/yotpo.utils');
|
|
6
6
|
|
|
@@ -35,8 +35,6 @@ const yotpoCustomerAnniversarySet = async (
|
|
|
35
35
|
return rejectResponse;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const creds = await credsFromPayload(credsPayload);
|
|
39
|
-
|
|
40
38
|
const body = {
|
|
41
39
|
customer_email: customerEmail,
|
|
42
40
|
day: Number(day),
|
|
@@ -45,11 +43,13 @@ const yotpoCustomerAnniversarySet = async (
|
|
|
45
43
|
};
|
|
46
44
|
|
|
47
45
|
const response = await yotpoClient.fetch({
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
requestPayload: {
|
|
47
|
+
url: '/customer_anniversary',
|
|
48
|
+
method: 'post',
|
|
49
|
+
body,
|
|
50
|
+
},
|
|
51
51
|
context: {
|
|
52
|
-
|
|
52
|
+
credsPayload,
|
|
53
53
|
apiVersion,
|
|
54
54
|
},
|
|
55
55
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://loyaltyapi.yotpo.com/reference/set-customer-birthday
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { objHasAny, ArgsWarden } = require('../utils');
|
|
4
4
|
const { credsValidator } = require('../validators');
|
|
5
5
|
const { yotpoClient } = require('../yotpo/yotpo.utils');
|
|
6
6
|
|
|
@@ -42,8 +42,6 @@ const yotpoCustomerBirthdaySet = async (
|
|
|
42
42
|
return rejectResponse;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const creds = await credsFromPayload(credsPayload);
|
|
46
|
-
|
|
47
45
|
const {
|
|
48
46
|
customerId,
|
|
49
47
|
customerEmail,
|
|
@@ -58,11 +56,13 @@ const yotpoCustomerBirthdaySet = async (
|
|
|
58
56
|
};
|
|
59
57
|
|
|
60
58
|
const response = await yotpoClient.fetch({
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
requestPayload: {
|
|
60
|
+
url: '/customer_birthdays',
|
|
61
|
+
method: 'post',
|
|
62
|
+
body,
|
|
63
|
+
},
|
|
64
64
|
context: {
|
|
65
|
-
|
|
65
|
+
credsPayload,
|
|
66
66
|
apiVersion,
|
|
67
67
|
},
|
|
68
68
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://loyaltyapi.yotpo.com/reference/fetch-customer-details
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { objHasAny, ArgsWarden } = require('../utils');
|
|
4
4
|
const { credsValidator } = require('../validators');
|
|
5
5
|
const { yotpoClient } = require('../yotpo/yotpo.utils');
|
|
6
6
|
|
|
@@ -37,8 +37,6 @@ const yotpoCustomerGet = async (
|
|
|
37
37
|
return rejectResponse;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
const creds = await credsFromPayload(credsPayload);
|
|
41
|
-
|
|
42
40
|
const {
|
|
43
41
|
customerId,
|
|
44
42
|
customerEmail,
|
|
@@ -57,10 +55,12 @@ const yotpoCustomerGet = async (
|
|
|
57
55
|
};
|
|
58
56
|
|
|
59
57
|
const response = await yotpoClient.fetch({
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
requestPayload: {
|
|
59
|
+
url: '/customers',
|
|
60
|
+
params,
|
|
61
|
+
},
|
|
62
62
|
context: {
|
|
63
|
-
|
|
63
|
+
credsPayload,
|
|
64
64
|
apiVersion,
|
|
65
65
|
},
|
|
66
66
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://loyaltyapi.yotpo.com/reference/adjust-a-customers-point-balance
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { objHasAny, ArgsWarden } = require('../utils');
|
|
4
4
|
const { credsValidator } = require('../validators');
|
|
5
5
|
const { yotpoClient } = require('../yotpo/yotpo.utils');
|
|
6
6
|
|
|
@@ -40,8 +40,6 @@ const yotpoCustomerPointsAdjust = async (
|
|
|
40
40
|
return rejectResponse;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const creds = await credsFromPayload(credsPayload);
|
|
44
|
-
|
|
45
43
|
const {
|
|
46
44
|
customerId,
|
|
47
45
|
customerEmail,
|
|
@@ -57,11 +55,13 @@ const yotpoCustomerPointsAdjust = async (
|
|
|
57
55
|
};
|
|
58
56
|
|
|
59
57
|
const response = await yotpoClient.fetch({
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
requestPayload: {
|
|
59
|
+
url: '/points/adjust',
|
|
60
|
+
method: 'post',
|
|
61
|
+
body,
|
|
62
|
+
},
|
|
63
63
|
context: {
|
|
64
|
-
|
|
64
|
+
credsPayload,
|
|
65
65
|
apiVersion,
|
|
66
66
|
},
|
|
67
67
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://loyaltyapi.yotpo.com/reference/createupdate-customer-records
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
4
|
const { credsValidator } = require('../validators');
|
|
5
5
|
const { yotpoClient } = require('../yotpo/yotpo.utils');
|
|
6
6
|
|
|
@@ -37,8 +37,6 @@ const yotpoCustomerUpsert = async (
|
|
|
37
37
|
return rejectResponse;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
const creds = await credsFromPayload(credsPayload);
|
|
41
|
-
|
|
42
40
|
const body = {
|
|
43
41
|
email,
|
|
44
42
|
...(id && { id }),
|
|
@@ -55,11 +53,13 @@ const yotpoCustomerUpsert = async (
|
|
|
55
53
|
};
|
|
56
54
|
|
|
57
55
|
const response = await yotpoClient.fetch({
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
requestPayload: {
|
|
57
|
+
url: '/customers',
|
|
58
|
+
method: 'post',
|
|
59
|
+
body,
|
|
60
|
+
},
|
|
61
61
|
context: {
|
|
62
|
-
|
|
62
|
+
credsPayload,
|
|
63
63
|
apiVersion,
|
|
64
64
|
},
|
|
65
65
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://loyaltyapi.yotpo.com/reference/fetch-all-recently-updated-customers
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
4
|
const { credsValidator } = require('../validators');
|
|
5
5
|
const { yotpoClient } = require('../yotpo/yotpo.utils');
|
|
6
6
|
|
|
@@ -22,18 +22,18 @@ const yotpoCustomersRecentGet = async (
|
|
|
22
22
|
return rejectResponse;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const creds = await credsFromPayload(credsPayload);
|
|
26
|
-
|
|
27
25
|
const params = {
|
|
28
26
|
...(pageInfo && { page_info: pageInfo }),
|
|
29
27
|
...(perPage !== undefined && { per_page: perPage }),
|
|
30
28
|
};
|
|
31
29
|
|
|
32
30
|
const response = await yotpoClient.fetch({
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
requestPayload: {
|
|
32
|
+
url: '/customers/recent',
|
|
33
|
+
params,
|
|
34
|
+
},
|
|
35
35
|
context: {
|
|
36
|
-
|
|
36
|
+
credsPayload,
|
|
37
37
|
apiVersion,
|
|
38
38
|
},
|
|
39
39
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://loyaltyapi.yotpo.com/reference/create-redemption
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { objHasAny, ArgsWarden } = require('../utils');
|
|
4
4
|
const { credsValidator } = require('../validators');
|
|
5
5
|
const { yotpoClient } = require('../yotpo/yotpo.utils');
|
|
6
6
|
|
|
@@ -43,8 +43,6 @@ const yotpoRedemptionCreate = async (
|
|
|
43
43
|
return rejectResponse;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
const creds = await credsFromPayload(credsPayload);
|
|
47
|
-
|
|
48
46
|
const {
|
|
49
47
|
customerId,
|
|
50
48
|
customerEmail,
|
|
@@ -64,11 +62,13 @@ const yotpoRedemptionCreate = async (
|
|
|
64
62
|
};
|
|
65
63
|
|
|
66
64
|
const response = await yotpoClient.fetch({
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
requestPayload: {
|
|
66
|
+
url: '/redemptions',
|
|
67
|
+
method: 'post',
|
|
68
|
+
body,
|
|
69
|
+
},
|
|
70
70
|
context: {
|
|
71
|
-
|
|
71
|
+
credsPayload,
|
|
72
72
|
apiVersion,
|
|
73
73
|
},
|
|
74
74
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://loyaltyapi.yotpo.com/reference/fetch-active-redemption-options
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
4
|
const { credsValidator } = require('../validators');
|
|
5
5
|
const { yotpoClient } = require('../yotpo/yotpo.utils');
|
|
6
6
|
|
|
@@ -23,8 +23,6 @@ const yotpoRedemptionOptionsGet = async (
|
|
|
23
23
|
return rejectResponse;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const creds = await credsFromPayload(credsPayload);
|
|
27
|
-
|
|
28
26
|
const {
|
|
29
27
|
customerId,
|
|
30
28
|
customerEmail,
|
|
@@ -40,10 +38,12 @@ const yotpoRedemptionOptionsGet = async (
|
|
|
40
38
|
};
|
|
41
39
|
|
|
42
40
|
const response = await yotpoClient.fetch({
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
requestPayload: {
|
|
42
|
+
url: '/redemption_options',
|
|
43
|
+
params,
|
|
44
|
+
},
|
|
45
45
|
context: {
|
|
46
|
-
|
|
46
|
+
credsPayload,
|
|
47
47
|
apiVersion,
|
|
48
48
|
},
|
|
49
49
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://loyaltyapi.yotpo.com/reference/fetch-vip-tiers
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
4
|
const { credsValidator } = require('../validators');
|
|
5
5
|
const { yotpoClient } = require('../yotpo/yotpo.utils');
|
|
6
6
|
|
|
@@ -20,12 +20,12 @@ const yotpoVipTiersGet = async (
|
|
|
20
20
|
return rejectResponse;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const creds = await credsFromPayload(credsPayload);
|
|
24
|
-
|
|
25
23
|
const response = await yotpoClient.fetch({
|
|
26
|
-
|
|
24
|
+
requestPayload: {
|
|
25
|
+
url: '/vip_tiers',
|
|
26
|
+
},
|
|
27
27
|
context: {
|
|
28
|
-
|
|
28
|
+
credsPayload,
|
|
29
29
|
apiVersion,
|
|
30
30
|
},
|
|
31
31
|
});
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
const { YOUTUBE_API_BASE } = require('../youtube/youtube.constants');
|
|
2
|
+
const { resolveCreds, useBaseUrl } = require('../pipelineSteps');
|
|
3
|
+
const {
|
|
4
|
+
FetchClient,
|
|
5
|
+
} = require('../utils');
|
|
6
|
+
|
|
7
|
+
const useApiKeyParam = async (state) => {
|
|
8
|
+
const { requestPayload, context } = state;
|
|
9
|
+
const { creds } = context;
|
|
10
|
+
const { API_KEY } = creds;
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
requestPayload: {
|
|
14
|
+
...requestPayload,
|
|
15
|
+
params: {
|
|
16
|
+
key: API_KEY,
|
|
17
|
+
...requestPayload.params,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const interpretYoutubeResponse = async (state) => {
|
|
24
|
+
const { response } = state;
|
|
25
|
+
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
const youtubeError = response.error?.details?.error;
|
|
28
|
+
|
|
29
|
+
if (youtubeError) {
|
|
30
|
+
return {
|
|
31
|
+
response: {
|
|
32
|
+
ok: false,
|
|
33
|
+
error: {
|
|
34
|
+
code: youtubeError.code,
|
|
35
|
+
message: youtubeError.message,
|
|
36
|
+
details: youtubeError,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
breakChain: true,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return { breakChain: true };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const { data } = response;
|
|
47
|
+
|
|
48
|
+
if (data?.error) {
|
|
49
|
+
return {
|
|
50
|
+
response: {
|
|
51
|
+
ok: false,
|
|
52
|
+
error: {
|
|
53
|
+
code: data.error.code,
|
|
54
|
+
message: data.error.message,
|
|
55
|
+
details: data.error,
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
breakChain: true,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return {};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const youtubeClient = new FetchClient({
|
|
66
|
+
pipeline: [
|
|
67
|
+
resolveCreds,
|
|
68
|
+
useBaseUrl(YOUTUBE_API_BASE),
|
|
69
|
+
useApiKeyParam,
|
|
70
|
+
'fetch',
|
|
71
|
+
interpretYoutubeResponse,
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
module.exports = {
|
|
76
|
+
youtubeClient,
|
|
77
|
+
};
|