@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,69 @@
|
|
|
1
|
+
// https://docs.github.com/en/rest/repos/repos#list-repositories-for-the-authenticated-user
|
|
2
|
+
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { githubGet } = require('../github/githubGet');
|
|
6
|
+
const { MAX_PER_PAGE } = require('../github/github.constants');
|
|
7
|
+
|
|
8
|
+
const argsWarden = new ArgsWarden([
|
|
9
|
+
['credsPayload', credsValidator],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const githubReposGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
{
|
|
15
|
+
org,
|
|
16
|
+
type,
|
|
17
|
+
sort,
|
|
18
|
+
direction,
|
|
19
|
+
perPage,
|
|
20
|
+
...getterOptions
|
|
21
|
+
} = {},
|
|
22
|
+
) => {
|
|
23
|
+
|
|
24
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
25
|
+
if (rejectResponse) {
|
|
26
|
+
return rejectResponse;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const url = org ? `/orgs/${ org }/repos` : '/user/repos';
|
|
30
|
+
|
|
31
|
+
const params = {
|
|
32
|
+
...type && { type },
|
|
33
|
+
...sort && { sort },
|
|
34
|
+
...direction && { direction },
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return githubGet(credsPayload, url, {
|
|
38
|
+
params,
|
|
39
|
+
perPage: perPage ?? MAX_PER_PAGE,
|
|
40
|
+
...getterOptions,
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const funcApiConfig = {
|
|
45
|
+
argsWarden,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
module.exports = {
|
|
49
|
+
githubReposGet,
|
|
50
|
+
funcApiConfig,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/*
|
|
54
|
+
curl -X POST "http://localhost:8000/githubReposGet" \
|
|
55
|
+
-H "Content-Type: application/json" \
|
|
56
|
+
-d '{
|
|
57
|
+
"credsPayload": { "credsPath": "github" }
|
|
58
|
+
}'
|
|
59
|
+
|
|
60
|
+
curl -X POST "http://localhost:8000/githubReposGet" \
|
|
61
|
+
-H "Content-Type: application/json" \
|
|
62
|
+
-d '{
|
|
63
|
+
"credsPayload": { "credsPath": "github" },
|
|
64
|
+
"options": {
|
|
65
|
+
"org": "GorgonFreeman",
|
|
66
|
+
"limit": 10
|
|
67
|
+
}
|
|
68
|
+
}'
|
|
69
|
+
*/
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// https://docs.github.com/en/rest/users/users#get-the-authenticated-user
|
|
2
|
+
// https://docs.github.com/en/rest/users/users#get-a-user
|
|
3
|
+
|
|
4
|
+
const { ArgsWarden } = require('../utils');
|
|
5
|
+
const { credsValidator } = require('../validators');
|
|
6
|
+
const { githubClient } = require('../github/github.utils');
|
|
7
|
+
|
|
8
|
+
const argsWarden = new ArgsWarden([
|
|
9
|
+
['credsPayload', credsValidator],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const githubUserGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
{
|
|
15
|
+
username,
|
|
16
|
+
params,
|
|
17
|
+
apiVersion,
|
|
18
|
+
} = {},
|
|
19
|
+
) => {
|
|
20
|
+
|
|
21
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
22
|
+
if (rejectResponse) {
|
|
23
|
+
return rejectResponse;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const url = username ? `/users/${ username }` : '/user';
|
|
27
|
+
|
|
28
|
+
return githubClient.fetch({
|
|
29
|
+
requestPayload: {
|
|
30
|
+
url,
|
|
31
|
+
params,
|
|
32
|
+
},
|
|
33
|
+
context: {
|
|
34
|
+
credsPayload,
|
|
35
|
+
apiVersion,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const funcApiConfig = {
|
|
41
|
+
argsWarden,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
module.exports = {
|
|
45
|
+
githubUserGet,
|
|
46
|
+
funcApiConfig,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
curl -X POST "http://localhost:8000/githubUserGet" \
|
|
51
|
+
-H "Content-Type: application/json" \
|
|
52
|
+
-d '{
|
|
53
|
+
"credsPayload": { "credsPath": "github" }
|
|
54
|
+
}'
|
|
55
|
+
|
|
56
|
+
curl -X POST "http://localhost:8000/githubUserGet" \
|
|
57
|
+
-H "Content-Type: application/json" \
|
|
58
|
+
-d '{
|
|
59
|
+
"credsPayload": { "credsPath": "github" },
|
|
60
|
+
"options": {
|
|
61
|
+
"username": "GorgonFreeman"
|
|
62
|
+
}
|
|
63
|
+
}'
|
|
64
|
+
*/
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const { LINEAR_GRAPHQL_URL } = require('../linear/linear.constants');
|
|
2
|
+
const { resolveCreds } = require('../pipelineSteps');
|
|
2
3
|
const {
|
|
3
4
|
FetchClient,
|
|
4
|
-
Chain,
|
|
5
5
|
fetchClientCommonSteps,
|
|
6
6
|
} = require('../utils');
|
|
7
7
|
|
|
8
|
-
const
|
|
8
|
+
const useAuthHeaders = async (state) => {
|
|
9
9
|
const { requestPayload, context } = state;
|
|
10
10
|
const { creds } = context;
|
|
11
11
|
const { API_KEY } = creds;
|
|
@@ -16,7 +16,6 @@ const addUrlAndAuthHeaders = async (state) => {
|
|
|
16
16
|
url: requestPayload.url || LINEAR_GRAPHQL_URL,
|
|
17
17
|
method: requestPayload.method || 'post',
|
|
18
18
|
headers: {
|
|
19
|
-
'Content-Type': 'application/json',
|
|
20
19
|
Authorization: API_KEY,
|
|
21
20
|
...requestPayload.headers,
|
|
22
21
|
},
|
|
@@ -24,18 +23,14 @@ const addUrlAndAuthHeaders = async (state) => {
|
|
|
24
23
|
};
|
|
25
24
|
};
|
|
26
25
|
|
|
27
|
-
const linearClientRequestPreparer = new Chain([
|
|
28
|
-
addUrlAndAuthHeaders,
|
|
29
|
-
]);
|
|
30
|
-
|
|
31
|
-
const linearClientResponseInterpreter = new Chain([
|
|
32
|
-
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
33
|
-
fetchClientCommonSteps.exitEarlyOnGraphqlErrors,
|
|
34
|
-
]);
|
|
35
|
-
|
|
36
26
|
const linearClient = new FetchClient({
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
pipeline: [
|
|
28
|
+
resolveCreds,
|
|
29
|
+
useAuthHeaders,
|
|
30
|
+
'fetch',
|
|
31
|
+
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
32
|
+
fetchClientCommonSteps.exitEarlyOnGraphqlErrors,
|
|
33
|
+
],
|
|
39
34
|
});
|
|
40
35
|
|
|
41
36
|
module.exports = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://linear.app/developers/graphql
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { ArgsWarden } = require('../utils');
|
|
4
4
|
const { credsValidator } = require('../validators');
|
|
5
5
|
const { linearClient } = require('../linear/linear.utils');
|
|
6
6
|
|
|
@@ -24,15 +24,14 @@ const linearIssuesGet = async (
|
|
|
24
24
|
return rejectResponse;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const creds = await credsFromPayload(credsPayload);
|
|
28
|
-
|
|
29
27
|
const filter = teamId
|
|
30
28
|
? { team: { id: { eq: teamId } } }
|
|
31
29
|
: undefined;
|
|
32
30
|
|
|
33
31
|
const response = await linearClient.fetch({
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
requestPayload: {
|
|
33
|
+
body: {
|
|
34
|
+
query: `
|
|
36
35
|
query IssuesGet($first: Int!, $filter: IssueFilter) {
|
|
37
36
|
issues(first: $first, filter: $filter) {
|
|
38
37
|
nodes {
|
|
@@ -58,12 +57,13 @@ const linearIssuesGet = async (
|
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
59
|
`,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
variables: {
|
|
61
|
+
first,
|
|
62
|
+
...(filter && { filter }),
|
|
63
|
+
},
|
|
64
64
|
},
|
|
65
65
|
},
|
|
66
|
-
context: {
|
|
66
|
+
context: { credsPayload },
|
|
67
67
|
inspect,
|
|
68
68
|
});
|
|
69
69
|
|
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
const { DEFAULT_API_VERSION } = require('../logiwa/logiwa.constants');
|
|
2
2
|
const { logiwaAuthGet } = require('../logiwa/logiwaAuthGet');
|
|
3
|
+
const { resolveCreds } = require('../pipelineSteps');
|
|
3
4
|
const {
|
|
4
5
|
FetchClient,
|
|
5
|
-
Chain,
|
|
6
6
|
appendUrlToBase,
|
|
7
|
-
credsFromPayload,
|
|
8
7
|
fetchClientCommonSteps,
|
|
9
8
|
} = require('../utils');
|
|
10
9
|
|
|
11
|
-
const
|
|
10
|
+
const useUrlAndAuthHeaders = async (state) => {
|
|
12
11
|
const { requestPayload, context } = state;
|
|
13
|
-
const {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
const {
|
|
13
|
+
apiVersion = DEFAULT_API_VERSION,
|
|
14
|
+
creds,
|
|
15
|
+
} = context;
|
|
16
|
+
|
|
17
|
+
const authResponse = await logiwaAuthGet(
|
|
18
|
+
{ credsObject: creds },
|
|
19
|
+
{ apiVersion },
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
if (!authResponse?.ok) {
|
|
23
|
+
return {
|
|
24
|
+
breakChain: true,
|
|
25
|
+
response: authResponse,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const { token } = authResponse.data;
|
|
22
30
|
const { BASE_URL } = creds;
|
|
23
31
|
|
|
24
32
|
return {
|
|
25
|
-
context: {
|
|
26
|
-
creds,
|
|
27
|
-
},
|
|
28
33
|
requestPayload: {
|
|
34
|
+
...requestPayload,
|
|
29
35
|
url: appendUrlToBase(`${ BASE_URL }/${ apiVersion }`, requestPayload.url),
|
|
30
36
|
headers: {
|
|
31
37
|
Authorization: `Bearer ${ token }`,
|
|
@@ -35,17 +41,13 @@ const addUrlAndAuthHeaders = async (state) => {
|
|
|
35
41
|
};
|
|
36
42
|
};
|
|
37
43
|
|
|
38
|
-
const logiwaClientRequestPreparer = new Chain([
|
|
39
|
-
addUrlAndAuthHeaders,
|
|
40
|
-
]);
|
|
41
|
-
|
|
42
|
-
const logiwaClientResponseInterpreter = new Chain([
|
|
43
|
-
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
44
|
-
]);
|
|
45
|
-
|
|
46
44
|
const logiwaClient = new FetchClient({
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
pipeline: [
|
|
46
|
+
resolveCreds,
|
|
47
|
+
useUrlAndAuthHeaders,
|
|
48
|
+
'fetch',
|
|
49
|
+
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
50
|
+
],
|
|
49
51
|
});
|
|
50
52
|
|
|
51
53
|
module.exports = {
|
|
@@ -39,9 +39,11 @@ const logiwaInventoriesGet = async (
|
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
return logiwaClient.fetch({
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
requestPayload: {
|
|
43
|
+
method: 'get',
|
|
44
|
+
url: `/Inventory/list/i/${ page }/s/${ perPage }`,
|
|
45
|
+
params,
|
|
46
|
+
},
|
|
45
47
|
context: {
|
|
46
48
|
credsPayload,
|
|
47
49
|
apiVersion,
|
|
@@ -26,8 +26,10 @@ const logiwaOrderGet = async (
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
return logiwaClient.fetch({
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
requestPayload: {
|
|
30
|
+
method: 'get',
|
|
31
|
+
url: `/ShipmentOrder/${ orderId }`,
|
|
32
|
+
},
|
|
31
33
|
context: {
|
|
32
34
|
credsPayload,
|
|
33
35
|
apiVersion,
|
|
@@ -57,9 +57,11 @@ const logiwaOrdersGet = async (
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
return logiwaClient.fetch({
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
requestPayload: {
|
|
61
|
+
method: 'get',
|
|
62
|
+
url: `/ShipmentOrder/list/i/${ page }/s/${ perPage }`,
|
|
63
|
+
params,
|
|
64
|
+
},
|
|
63
65
|
context: {
|
|
64
66
|
credsPayload,
|
|
65
67
|
apiVersion,
|
|
@@ -26,8 +26,10 @@ const logiwaProductGet = async (
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
return logiwaClient.fetch({
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
requestPayload: {
|
|
30
|
+
method: 'get',
|
|
31
|
+
url: `/Product/detail/${ productId }`,
|
|
32
|
+
},
|
|
31
33
|
context: {
|
|
32
34
|
credsPayload,
|
|
33
35
|
apiVersion,
|
|
@@ -45,9 +45,11 @@ const logiwaProductsGet = async (
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
return logiwaClient.fetch({
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
requestPayload: {
|
|
49
|
+
method: 'get',
|
|
50
|
+
url: `/Product/list/i/${ page }/s/${ perPage }`,
|
|
51
|
+
params,
|
|
52
|
+
},
|
|
51
53
|
context: {
|
|
52
54
|
credsPayload,
|
|
53
55
|
apiVersion,
|
|
@@ -100,9 +100,11 @@ const logiwaReportGetAvailableToPromiseSingle = async (
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
return logiwaClient.fetch({
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
requestPayload: {
|
|
104
|
+
method: 'get',
|
|
105
|
+
url: `/Report/AvailableToPromise/i/${ page }/s/${ perPage }`,
|
|
106
|
+
params,
|
|
107
|
+
},
|
|
106
108
|
context: {
|
|
107
109
|
credsPayload,
|
|
108
110
|
apiVersion,
|
|
@@ -33,9 +33,11 @@ const logiwaReportGetInventoryCalculation = async (
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
return logiwaClient.fetch({
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
requestPayload: {
|
|
37
|
+
method: 'get',
|
|
38
|
+
url: `/Report/InventoryCalculation/i/${ page }/s/${ perPage }`,
|
|
39
|
+
params,
|
|
40
|
+
},
|
|
39
41
|
context: {
|
|
40
42
|
credsPayload,
|
|
41
43
|
apiVersion,
|
|
@@ -37,9 +37,11 @@ const logiwaReportGetInventorySnapshot = async (
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
return logiwaClient.fetch({
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
requestPayload: {
|
|
41
|
+
method: 'get',
|
|
42
|
+
url: `/Report/InventorySnapshot/i/${ page }/s/${ perPage }`,
|
|
43
|
+
params,
|
|
44
|
+
},
|
|
43
45
|
context: {
|
|
44
46
|
credsPayload,
|
|
45
47
|
apiVersion,
|
|
@@ -43,9 +43,11 @@ const logiwaReportGetTotalInventory = async (
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
return logiwaClient.fetch({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
requestPayload: {
|
|
47
|
+
method: 'get',
|
|
48
|
+
url: `/Report/TotalInventory/i/${ page }/s/${ perPage }`,
|
|
49
|
+
params,
|
|
50
|
+
},
|
|
49
51
|
context: {
|
|
50
52
|
credsPayload,
|
|
51
53
|
apiVersion,
|
|
@@ -26,8 +26,10 @@ const logiwaWebhookStatusGet = async (
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
return logiwaClient.fetch({
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
requestPayload: {
|
|
30
|
+
method: 'get',
|
|
31
|
+
url: `/Webhook/status/${ subscriptionId }`,
|
|
32
|
+
},
|
|
31
33
|
context: {
|
|
32
34
|
credsPayload,
|
|
33
35
|
apiVersion,
|
|
@@ -30,12 +30,14 @@ const logiwaWebhookSubscribe = async (
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
return logiwaClient.fetch({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
requestPayload: {
|
|
34
|
+
method: 'post',
|
|
35
|
+
url: '/Webhook/create',
|
|
36
|
+
body: {
|
|
37
|
+
topic,
|
|
38
|
+
address: url,
|
|
39
|
+
...(clientIdentifier ? { clientIdentifier } : { ignoreClient: true }),
|
|
40
|
+
},
|
|
39
41
|
},
|
|
40
42
|
context: {
|
|
41
43
|
credsPayload,
|
|
@@ -26,8 +26,10 @@ const logiwaWebhookUnsubscribe = async (
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
return logiwaClient.fetch({
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
requestPayload: {
|
|
30
|
+
method: 'delete',
|
|
31
|
+
url: `/Webhook/unsubscribe/${ subscriptionId }`,
|
|
32
|
+
},
|
|
31
33
|
context: {
|
|
32
34
|
credsPayload,
|
|
33
35
|
apiVersion,
|
package/api/loop/loop.utils.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
const { LOOP_API_BASE_URL } = require('../loop/loop.constants');
|
|
2
|
+
const { resolveCreds, useBaseUrl } = require('../pipelineSteps');
|
|
2
3
|
const {
|
|
3
4
|
FetchClient,
|
|
4
|
-
Chain,
|
|
5
|
-
appendUrlToBase,
|
|
6
5
|
fetchClientCommonSteps,
|
|
7
6
|
} = require('../utils');
|
|
8
7
|
|
|
9
8
|
// TODO: Allow creds failure (e.g. missing API_KEY → INVALID_CREDS before fetch)
|
|
10
|
-
const
|
|
9
|
+
const useAuthHeaders = async (state) => {
|
|
11
10
|
const { requestPayload, context } = state;
|
|
12
11
|
const { creds } = context;
|
|
13
12
|
const { API_KEY } = creds;
|
|
@@ -15,9 +14,7 @@ const addUrlAndAuthHeaders = async (state) => {
|
|
|
15
14
|
return {
|
|
16
15
|
requestPayload: {
|
|
17
16
|
...requestPayload,
|
|
18
|
-
url: appendUrlToBase(LOOP_API_BASE_URL, requestPayload.url),
|
|
19
17
|
headers: {
|
|
20
|
-
'Content-Type': 'application/json',
|
|
21
18
|
'X-Authorization': API_KEY,
|
|
22
19
|
...requestPayload.headers,
|
|
23
20
|
},
|
|
@@ -25,17 +22,14 @@ const addUrlAndAuthHeaders = async (state) => {
|
|
|
25
22
|
};
|
|
26
23
|
};
|
|
27
24
|
|
|
28
|
-
const loopClientRequestPreparer = new Chain([
|
|
29
|
-
addUrlAndAuthHeaders,
|
|
30
|
-
]);
|
|
31
|
-
|
|
32
|
-
const loopClientResponseInterpreter = new Chain([
|
|
33
|
-
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
34
|
-
]);
|
|
35
|
-
|
|
36
25
|
const loopClient = new FetchClient({
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
pipeline: [
|
|
27
|
+
resolveCreds,
|
|
28
|
+
useBaseUrl(LOOP_API_BASE_URL),
|
|
29
|
+
useAuthHeaders,
|
|
30
|
+
'fetch',
|
|
31
|
+
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
32
|
+
],
|
|
39
33
|
});
|
|
40
34
|
|
|
41
35
|
module.exports = {
|
package/api/loop/loopGet.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const {
|
|
1
|
+
const { ArgsWarden, Getter } = require('../utils');
|
|
2
2
|
const { credsValidator } = require('../validators');
|
|
3
3
|
const { loopClient } = require('../loop/loop.utils');
|
|
4
4
|
const { MAX_PER_PAGE } = require('../loop/loop.constants');
|
|
@@ -9,7 +9,7 @@ const argsWarden = new ArgsWarden([
|
|
|
9
9
|
]);
|
|
10
10
|
|
|
11
11
|
const loopGetPacket = async (
|
|
12
|
-
|
|
12
|
+
credsPayload,
|
|
13
13
|
url,
|
|
14
14
|
{
|
|
15
15
|
params,
|
|
@@ -18,16 +18,18 @@ const loopGetPacket = async (
|
|
|
18
18
|
} = {},
|
|
19
19
|
) => {
|
|
20
20
|
return loopClient.fetch({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
requestPayload: {
|
|
22
|
+
url,
|
|
23
|
+
...(paginate && {
|
|
24
|
+
params: {
|
|
25
|
+
paginate: true,
|
|
26
|
+
pageSize: perPage,
|
|
27
|
+
...params,
|
|
28
|
+
},
|
|
29
|
+
}),
|
|
30
|
+
},
|
|
29
31
|
context: {
|
|
30
|
-
|
|
32
|
+
credsPayload,
|
|
31
33
|
},
|
|
32
34
|
});
|
|
33
35
|
};
|
|
@@ -44,10 +46,10 @@ const loopGetPaginator = async (currentParams, response) => {
|
|
|
44
46
|
return [true];
|
|
45
47
|
}
|
|
46
48
|
|
|
47
|
-
const [
|
|
49
|
+
const [credsPayload] = args;
|
|
48
50
|
|
|
49
51
|
return [false, {
|
|
50
|
-
args: [
|
|
52
|
+
args: [credsPayload, nextPageUrl],
|
|
51
53
|
options: {
|
|
52
54
|
paginate: false,
|
|
53
55
|
},
|
|
@@ -75,13 +77,9 @@ const loopGet = async (
|
|
|
75
77
|
return rejectResponse;
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
const creds = await credsFromPayload(credsPayload);
|
|
79
|
-
|
|
80
|
-
let firstError = null;
|
|
81
|
-
|
|
82
80
|
const getter = new Getter(
|
|
83
81
|
{
|
|
84
|
-
args: [
|
|
82
|
+
args: [credsPayload, url],
|
|
85
83
|
options: {
|
|
86
84
|
params,
|
|
87
85
|
perPage,
|
|
@@ -91,7 +89,6 @@ const loopGet = async (
|
|
|
91
89
|
func: loopGetPacket,
|
|
92
90
|
digester: (response) => {
|
|
93
91
|
if (!response?.ok) {
|
|
94
|
-
firstError = response;
|
|
95
92
|
return [];
|
|
96
93
|
}
|
|
97
94
|
|
|
@@ -112,11 +109,10 @@ const loopGet = async (
|
|
|
112
109
|
|
|
113
110
|
const data = await getter.run({ returnAll: true });
|
|
114
111
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return data;
|
|
112
|
+
return {
|
|
113
|
+
ok: true,
|
|
114
|
+
data,
|
|
115
|
+
};
|
|
120
116
|
};
|
|
121
117
|
|
|
122
118
|
const funcApiConfig = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// https://docs.loopreturns.com/api-reference/latest/return-data/get-return-details
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { objHasAny, ArgsWarden } = require('../utils');
|
|
4
4
|
const { credsValidator } = require('../validators');
|
|
5
5
|
const { loopClient } = require('../loop/loop.utils');
|
|
6
6
|
|
|
@@ -37,8 +37,6 @@ const loopReturnGet = async (
|
|
|
37
37
|
orderName,
|
|
38
38
|
} = returnIdentifier;
|
|
39
39
|
|
|
40
|
-
const creds = await credsFromPayload(credsPayload);
|
|
41
|
-
|
|
42
40
|
const params = {
|
|
43
41
|
...returnId && { return_id: returnId },
|
|
44
42
|
...orderId && { order_id: orderId },
|
|
@@ -46,10 +44,12 @@ const loopReturnGet = async (
|
|
|
46
44
|
};
|
|
47
45
|
|
|
48
46
|
return loopClient.fetch({
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
requestPayload: {
|
|
48
|
+
url: '/warehouse/return/details',
|
|
49
|
+
params,
|
|
50
|
+
},
|
|
51
51
|
context: {
|
|
52
|
-
|
|
52
|
+
credsPayload,
|
|
53
53
|
},
|
|
54
54
|
});
|
|
55
55
|
};
|