@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.
Files changed (159) hide show
  1. package/.creds.yml.sample +27 -6
  2. package/AGENTS.md +6 -1
  3. package/README.md +1 -1
  4. package/api/bleckmann/.gitkeep +0 -0
  5. package/api/bleckmann/bleckmann.constants.js +8 -0
  6. package/api/bleckmann/bleckmann.utils.js +32 -0
  7. package/api/bleckmann/bleckmannAsnGet.js +52 -0
  8. package/api/bleckmann/bleckmannAsnsGet.js +65 -0
  9. package/api/constants.js +2 -1
  10. package/api/github/github.constants.js +11 -0
  11. package/api/github/github.utils.js +65 -0
  12. package/api/github/githubGet.js +144 -0
  13. package/api/github/githubIssueCreate.js +71 -0
  14. package/api/github/githubIssueGet.js +65 -0
  15. package/api/github/githubIssueUpdate.js +71 -0
  16. package/api/github/githubIssuesGet.js +74 -0
  17. package/api/github/githubPullRequestCreate.js +74 -0
  18. package/api/github/githubPullRequestGet.js +65 -0
  19. package/api/github/githubPullRequestMerge.js +77 -0
  20. package/api/github/githubPullRequestUpdate.js +72 -0
  21. package/api/github/githubPullRequestsGet.js +74 -0
  22. package/api/github/githubRepoCreate.js +80 -0
  23. package/api/github/githubRepoDelete.js +60 -0
  24. package/api/github/githubRepoGet.js +61 -0
  25. package/api/github/githubRepoUpdate.js +68 -0
  26. package/api/github/githubReposGet.js +69 -0
  27. package/api/github/githubUserGet.js +64 -0
  28. package/api/linear/linear.utils.js +9 -14
  29. package/api/linear/linearIssuesGet.js +9 -9
  30. package/api/logiwa/logiwa.utils.js +27 -25
  31. package/api/logiwa/logiwaInventoriesGet.js +5 -3
  32. package/api/logiwa/logiwaOrderGet.js +4 -2
  33. package/api/logiwa/logiwaOrdersGet.js +5 -3
  34. package/api/logiwa/logiwaProductGet.js +4 -2
  35. package/api/logiwa/logiwaProductsGet.js +5 -3
  36. package/api/logiwa/logiwaReportGetAvailableToPromise.js +5 -3
  37. package/api/logiwa/logiwaReportGetInventoryCalculation.js +5 -3
  38. package/api/logiwa/logiwaReportGetInventorySnapshot.js +5 -3
  39. package/api/logiwa/logiwaReportGetTotalInventory.js +5 -3
  40. package/api/logiwa/logiwaWebhookStatusGet.js +4 -2
  41. package/api/logiwa/logiwaWebhookSubscribe.js +8 -6
  42. package/api/logiwa/logiwaWebhookUnsubscribe.js +4 -2
  43. package/api/logiwa/logiwaWebhooksGet.js +4 -2
  44. package/api/loop/loop.utils.js +9 -15
  45. package/api/loop/loopGet.js +20 -24
  46. package/api/loop/loopReturnGet.js +6 -6
  47. package/api/peoplevox/peoplevox.constants.js +1 -1
  48. package/api/peoplevox/peoplevox.sessions.js +0 -33
  49. package/api/peoplevox/peoplevox.utils.js +63 -19
  50. package/api/peoplevox/peoplevoxGetSingle.js +7 -5
  51. package/api/peoplevox/peoplevoxOrderEdit.js +7 -5
  52. package/api/peoplevox/peoplevoxReportGet.js +11 -9
  53. package/api/pipelineSteps.js +49 -0
  54. package/api/shopify/shopify.utils.js +93 -22
  55. package/api/shopify/shopifyBulkMutationDo.js +211 -0
  56. package/api/shopify/shopifyBulkOperationGet.js +86 -0
  57. package/api/shopify/shopifyBulkOperationRunMutation.js +83 -0
  58. package/api/shopify/shopifyBulkOperationRunQuery.js +70 -0
  59. package/api/shopify/shopifyBulkQueryDo.js +127 -0
  60. package/api/shopify/shopifyCheckoutAndAccountsConfigurationUpdate.js +79 -0
  61. package/api/shopify/shopifyCollectionGet.js +6 -6
  62. package/api/shopify/shopifyCustomerGet.js +6 -6
  63. package/api/shopify/shopifyGet.js +18 -13
  64. package/api/shopify/shopifyGetSingle.js +9 -9
  65. package/api/shopify/shopifyMutationDo.js +6 -6
  66. package/api/shopify/shopifyOrdersGet.js +11 -11
  67. package/api/shopify/shopifyStagedUploadCreate.js +96 -0
  68. package/api/shopify/shopifyTagsAddBulk.js +77 -0
  69. package/api/slack/slack.utils.js +10 -19
  70. package/api/slack/slackMessagePost.js +11 -11
  71. package/api/starshipit/starshipit.constants.js +8 -0
  72. package/api/starshipit/starshipit.utils.js +71 -0
  73. package/api/starshipit/starshipitAddressCreate.js +77 -0
  74. package/api/starshipit/starshipitAddressDelete.js +55 -0
  75. package/api/starshipit/starshipitAddressUpdate.js +69 -0
  76. package/api/starshipit/starshipitAddressesGet.js +52 -0
  77. package/api/starshipit/starshipitGet.js +146 -0
  78. package/api/starshipit/starshipitOrderDelete.js +102 -0
  79. package/api/starshipit/starshipitOrderGet.js +74 -0
  80. package/api/starshipit/starshipitOrderUpdate.js +109 -0
  81. package/api/starshipit/starshipitOrdersListShipped.js +64 -0
  82. package/api/starshipit/starshipitProductAdd.js +100 -0
  83. package/api/starshipit/starshipitProductsDelete.js +57 -0
  84. package/api/starshipit/starshipitProductsGet.js +49 -0
  85. package/api/starshipit/starshipitTrackingGet.js +69 -0
  86. package/api/stripe/_example.js +7 -7
  87. package/api/stripe/stripe.utils.js +9 -14
  88. package/api/stripe/stripeCardTokenCreate.js +11 -11
  89. package/api/stripe/stripeChargeCapture.js +11 -11
  90. package/api/stripe/stripeChargeCreate.js +11 -11
  91. package/api/stripe/stripeChargeGet.js +5 -5
  92. package/api/stripe/stripeChargesGet.js +6 -6
  93. package/api/stripe/stripeRefundCreate.js +10 -10
  94. package/api/stripe/stripeRefundGet.js +5 -5
  95. package/api/stripe/stripeRefundsGet.js +6 -6
  96. package/api/stripe/stripeTokenGet.js +5 -5
  97. package/api/stylearcade/stylearcade.constants.js +5 -0
  98. package/api/stylearcade/stylearcade.utils.js +40 -0
  99. package/api/stylearcade/stylearcadeDataGet.js +62 -0
  100. package/api/stylearcade/stylearcadeGet.js +133 -0
  101. package/api/stylearcade/stylearcadeMetadataGet.js +47 -0
  102. package/api/threeclicks/threeclicks.constants.js +8 -0
  103. package/api/threeclicks/threeclicks.utils.js +119 -0
  104. package/api/threeclicks/threeclicksCollectionsGet.js +40 -0
  105. package/api/threeclicks/threeclicksGet.js +138 -0
  106. package/api/threeclicks/threeclicksKeycodeCreate.js +55 -0
  107. package/api/threeclicks/threeclicksKeycodeGet.js +47 -0
  108. package/api/threeclicks/threeclicksPurchaseOrderCreate.js +34 -0
  109. package/api/threeclicks/threeclicksPurchaseOrderCreateBulk.js +34 -0
  110. package/api/threeclicks/threeclicksPurchaseOrderGet.js +33 -0
  111. package/api/threeclicks/threeclicksPurchaseOrderQuantitiesGet.js +33 -0
  112. package/api/threeclicks/threeclicksPurchaseOrderQuantityCreate.js +34 -0
  113. package/api/threeclicks/threeclicksPurchaseOrderQuantityCreateBulk.js +34 -0
  114. package/api/threeclicks/threeclicksPurchaseOrderQuantityUpdate.js +46 -0
  115. package/api/threeclicks/threeclicksPurchaseOrderQuantityUpdateBulk.js +46 -0
  116. package/api/threeclicks/threeclicksPurchaseOrderUpdate.js +35 -0
  117. package/api/threeclicks/threeclicksPurchaseOrdersGet.js +30 -0
  118. package/api/threeclicks/threeclicksShipmentCreate.js +34 -0
  119. package/api/threeclicks/threeclicksShipmentGet.js +33 -0
  120. package/api/threeclicks/threeclicksShipmentOrderAdd.js +38 -0
  121. package/api/threeclicks/threeclicksShipmentOrderQuantityCreate.js +35 -0
  122. package/api/threeclicks/threeclicksShipmentQuantityUpdate.js +35 -0
  123. package/api/threeclicks/threeclicksShipmentStatusUpdate.js +45 -0
  124. package/api/threeclicks/threeclicksShipmentsGet.js +52 -0
  125. package/api/threeclicks/threeclicksSignatureCalculate.js +73 -0
  126. package/api/threeclicks/threeclicksStyleCodesGet.js +46 -0
  127. package/api/threeclicks/threeclicksStyleColourCreate.js +47 -0
  128. package/api/threeclicks/threeclicksStyleColourDelete.js +34 -0
  129. package/api/threeclicks/threeclicksStyleCreate.js +44 -0
  130. package/api/threeclicks/threeclicksStyleDelete.js +33 -0
  131. package/api/threeclicks/threeclicksStyleGet.js +43 -0
  132. package/api/threeclicks/threeclicksStylePriceUpdate.js +70 -0
  133. package/api/threeclicks/threeclicksStyleUpdate.js +47 -0
  134. package/api/threeclicks/threeclicksStylesGet.js +45 -0
  135. package/api/utils.js +85 -117
  136. package/api/validators.js +1 -1
  137. package/api/workable/workable.utils.js +8 -13
  138. package/api/workable/workableGet.js +16 -11
  139. package/api/workable/workableJobCandidateCreate.js +10 -10
  140. package/api/workable/workableJobGet.js +5 -5
  141. package/api/workable/workableJobMembersGet.js +5 -5
  142. package/api/workable/workableJobStagesGet.js +5 -5
  143. package/api/yotpo/yotpo.utils.js +17 -22
  144. package/api/yotpo/yotpoCampaignsGet.js +6 -6
  145. package/api/yotpo/yotpoCustomerActionRecord.js +7 -7
  146. package/api/yotpo/yotpoCustomerAnniversaryGet.js +7 -7
  147. package/api/yotpo/yotpoCustomerAnniversarySet.js +7 -7
  148. package/api/yotpo/yotpoCustomerBirthdaySet.js +7 -7
  149. package/api/yotpo/yotpoCustomerGet.js +6 -6
  150. package/api/yotpo/yotpoCustomerPointsAdjust.js +7 -7
  151. package/api/yotpo/yotpoCustomerUpsert.js +7 -7
  152. package/api/yotpo/yotpoCustomersRecentGet.js +6 -6
  153. package/api/yotpo/yotpoRedemptionCreate.js +7 -7
  154. package/api/yotpo/yotpoRedemptionOptionsGet.js +6 -6
  155. package/api/yotpo/yotpoVipTiersGet.js +5 -5
  156. package/api/youtube/youtube.constants.js +5 -0
  157. package/api/youtube/youtube.utils.js +77 -0
  158. package/api/youtube/youtubeChannelVideosGet.js +25 -70
  159. package/package.json +1 -1
@@ -0,0 +1,69 @@
1
+ // https://api-docs.starshipit.com/#05a846b9-0128-4dd3-80e4-e6008aef9b94
2
+
3
+ const { objHasAny, ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { starshipitClient } = require('../starshipit/starshipit.utils');
6
+
7
+ const trackingIdentifierValidator = (trackingIdentifier) => {
8
+ return objHasAny(trackingIdentifier, [
9
+ 'trackingNumber',
10
+ 'orderNumber',
11
+ ]);
12
+ };
13
+
14
+ const argsWarden = new ArgsWarden([
15
+ ['credsPayload', credsValidator],
16
+ ['trackingIdentifier', trackingIdentifierValidator],
17
+ ]);
18
+
19
+ const starshipitTrackingGet = async (
20
+ credsPayload,
21
+ trackingIdentifier,
22
+ ) => {
23
+
24
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
25
+ credsPayload,
26
+ trackingIdentifier,
27
+ });
28
+ if (rejectResponse) {
29
+ return rejectResponse;
30
+ }
31
+
32
+ const {
33
+ trackingNumber,
34
+ orderNumber,
35
+ } = trackingIdentifier;
36
+
37
+ const response = await starshipitClient.fetch({
38
+ requestPayload: {
39
+ url: '/track',
40
+ params: {
41
+ ...trackingNumber && { tracking_number: trackingNumber },
42
+ ...orderNumber && { order_number: orderNumber },
43
+ },
44
+ },
45
+ context: {
46
+ credsPayload,
47
+ },
48
+ });
49
+
50
+ return response;
51
+ };
52
+
53
+ const funcApiConfig = {
54
+ argsWarden,
55
+ };
56
+
57
+ module.exports = {
58
+ starshipitTrackingGet,
59
+ funcApiConfig,
60
+ };
61
+
62
+ /*
63
+ curl -X POST "http://localhost:8000/starshipitTrackingGet" \
64
+ -H "Content-Type: application/json" \
65
+ -d '{
66
+ "credsPayload": { "credsPath": "starshipit.wf" },
67
+ "trackingIdentifier": { "orderNumber": "7726760919112" }
68
+ }'
69
+ */
@@ -1,4 +1,4 @@
1
- const { credsFromPayload, ArgsWarden } = require('../utils');
1
+ const { ArgsWarden } = require('../utils');
2
2
  const { credsValidator } = require('../validators');
3
3
  const { stripeClient } = require('../stripe/stripe.utils');
4
4
 
@@ -17,13 +17,13 @@ const FUNC = async (
17
17
  return rejectResponse;
18
18
  }
19
19
 
20
- const creds = await credsFromPayload(credsPayload);
21
-
22
20
  const response = await stripeClient.fetch({
23
- url: '/things',
24
- method: 'post',
25
- body: { arg },
26
- context: { creds },
21
+ requestPayload: {
22
+ url: '/things',
23
+ method: 'post',
24
+ body: { arg },
25
+ },
26
+ context: { credsPayload },
27
27
  });
28
28
 
29
29
  return response;
@@ -1,12 +1,11 @@
1
1
  const { BASE_URL } = require('../stripe/stripe.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
- const addUrlAndAuthHeaders = async (state) => {
8
+ const useAuthHeaders = async (state) => {
10
9
  const { requestPayload, context } = state;
11
10
  const { creds } = context;
12
11
  const { API_KEY } = creds;
@@ -18,7 +17,6 @@ const addUrlAndAuthHeaders = async (state) => {
18
17
  return {
19
18
  requestPayload: {
20
19
  ...requestPayload,
21
- url: appendUrlToBase(BASE_URL, requestPayload.url),
22
20
  headers: {
23
21
  'Content-Type': 'application/x-www-form-urlencoded',
24
22
  Authorization: `Bearer ${ API_KEY }`,
@@ -29,17 +27,14 @@ const addUrlAndAuthHeaders = async (state) => {
29
27
  };
30
28
  };
31
29
 
32
- const stripeClientRequestPreparer = new Chain([
33
- addUrlAndAuthHeaders,
34
- ]);
35
-
36
- const stripeClientResponseInterpreter = new Chain([
37
- fetchClientCommonSteps.exitEarlyOnNotOk,
38
- ]);
39
-
40
30
  const stripeClient = new FetchClient({
41
- requestPreparer: stripeClientRequestPreparer,
42
- responseInterpreter: stripeClientResponseInterpreter,
31
+ pipeline: [
32
+ resolveCreds,
33
+ useBaseUrl(BASE_URL),
34
+ useAuthHeaders,
35
+ 'fetch',
36
+ fetchClientCommonSteps.exitEarlyOnNotOk,
37
+ ],
43
38
  });
44
39
 
45
40
  module.exports = {
@@ -1,6 +1,6 @@
1
1
  // https://docs.stripe.com/api/tokens/create_card
2
2
 
3
- const { credsFromPayload, ArgsWarden } = require('../utils');
3
+ const { ArgsWarden } = require('../utils');
4
4
  const { credsValidator } = require('../validators');
5
5
  const { stripeClient } = require('../stripe/stripe.utils');
6
6
 
@@ -31,18 +31,18 @@ const stripeCardTokenCreate = async (
31
31
  return rejectResponse;
32
32
  }
33
33
 
34
- const creds = await credsFromPayload(credsPayload);
35
-
36
34
  const response = await stripeClient.fetch({
37
- url: '/tokens',
38
- method: 'post',
39
- body: {
40
- 'card[number]': cardNumber,
41
- 'card[exp_month]': expiryMonth,
42
- 'card[exp_year]': expiryYear,
43
- 'card[cvc]': cvc,
35
+ requestPayload: {
36
+ url: '/tokens',
37
+ method: 'post',
38
+ body: {
39
+ 'card[number]': cardNumber,
40
+ 'card[exp_month]': expiryMonth,
41
+ 'card[exp_year]': expiryYear,
42
+ 'card[cvc]': cvc,
43
+ },
44
44
  },
45
- context: { creds },
45
+ context: { credsPayload },
46
46
  });
47
47
 
48
48
  return response;
@@ -1,6 +1,6 @@
1
1
  // https://docs.stripe.com/api/charges/capture
2
2
 
3
- const { credsFromPayload, ArgsWarden } = require('../utils');
3
+ const { ArgsWarden } = require('../utils');
4
4
  const { credsValidator } = require('../validators');
5
5
  const { stripeClient } = require('../stripe/stripe.utils');
6
6
 
@@ -25,17 +25,17 @@ const stripeChargeCapture = async (
25
25
  return rejectResponse;
26
26
  }
27
27
 
28
- const creds = await credsFromPayload(credsPayload);
29
-
30
28
  const response = await stripeClient.fetch({
31
- url: `/charges/${ chargeId }/capture`,
32
- method: 'post',
33
- ...(amountCents && {
34
- body: {
35
- amount: amountCents,
36
- },
37
- }),
38
- context: { creds },
29
+ requestPayload: {
30
+ url: `/charges/${ chargeId }/capture`,
31
+ method: 'post',
32
+ ...(amountCents && {
33
+ body: {
34
+ amount: amountCents,
35
+ },
36
+ }),
37
+ },
38
+ context: { credsPayload },
39
39
  });
40
40
 
41
41
  return response;
@@ -1,6 +1,6 @@
1
1
  // https://docs.stripe.com/api/charges/create
2
2
 
3
- const { credsFromPayload, ArgsWarden } = require('../utils');
3
+ const { ArgsWarden } = require('../utils');
4
4
  const { credsValidator } = require('../validators');
5
5
  const { stripeClient } = require('../stripe/stripe.utils');
6
6
 
@@ -31,18 +31,18 @@ const stripeChargeCreate = async (
31
31
  return rejectResponse;
32
32
  }
33
33
 
34
- const creds = await credsFromPayload(credsPayload);
35
-
36
34
  const response = await stripeClient.fetch({
37
- url: '/charges',
38
- method: 'post',
39
- body: {
40
- amount: amountCents,
41
- currency,
42
- source,
43
- description,
35
+ requestPayload: {
36
+ url: '/charges',
37
+ method: 'post',
38
+ body: {
39
+ amount: amountCents,
40
+ currency,
41
+ source,
42
+ description,
43
+ },
44
44
  },
45
- context: { creds },
45
+ context: { credsPayload },
46
46
  });
47
47
 
48
48
  return response;
@@ -1,6 +1,6 @@
1
1
  // https://docs.stripe.com/api/charges/retrieve
2
2
 
3
- const { credsFromPayload, ArgsWarden } = require('../utils');
3
+ const { ArgsWarden } = require('../utils');
4
4
  const { credsValidator } = require('../validators');
5
5
  const { stripeClient } = require('../stripe/stripe.utils');
6
6
 
@@ -22,11 +22,11 @@ const stripeChargeGet = async (
22
22
  return rejectResponse;
23
23
  }
24
24
 
25
- const creds = await credsFromPayload(credsPayload);
26
-
27
25
  const response = await stripeClient.fetch({
28
- url: `/charges/${ chargeId }`,
29
- context: { creds },
26
+ requestPayload: {
27
+ url: `/charges/${ chargeId }`,
28
+ },
29
+ context: { credsPayload },
30
30
  });
31
31
 
32
32
  return response;
@@ -1,6 +1,6 @@
1
1
  // https://docs.stripe.com/api/charges/list
2
2
 
3
- const { credsFromPayload, ArgsWarden } = require('../utils');
3
+ const { ArgsWarden } = require('../utils');
4
4
  const { credsValidator } = require('../validators');
5
5
  const { stripeClient } = require('../stripe/stripe.utils');
6
6
 
@@ -20,12 +20,12 @@ const stripeChargesGet = async (
20
20
  return rejectResponse;
21
21
  }
22
22
 
23
- const creds = await credsFromPayload(credsPayload);
24
-
25
23
  const response = await stripeClient.fetch({
26
- url: '/charges',
27
- params,
28
- context: { creds },
24
+ requestPayload: {
25
+ url: '/charges',
26
+ params,
27
+ },
28
+ context: { credsPayload },
29
29
  });
30
30
 
31
31
  return response;
@@ -1,6 +1,6 @@
1
1
  // https://docs.stripe.com/api/refunds/create
2
2
 
3
- const { credsFromPayload, ArgsWarden } = require('../utils');
3
+ const { ArgsWarden } = require('../utils');
4
4
  const { credsValidator } = require('../validators');
5
5
  const { stripeClient } = require('../stripe/stripe.utils');
6
6
 
@@ -26,17 +26,17 @@ const stripeRefundCreate = async (
26
26
  return rejectResponse;
27
27
  }
28
28
 
29
- const creds = await credsFromPayload(credsPayload);
30
-
31
29
  const response = await stripeClient.fetch({
32
- url: '/refunds',
33
- method: 'post',
34
- body: {
35
- charge: chargeId,
36
- ...amountCents && { amount: amountCents },
37
- ...reason && { reason },
30
+ requestPayload: {
31
+ url: '/refunds',
32
+ method: 'post',
33
+ body: {
34
+ charge: chargeId,
35
+ ...amountCents && { amount: amountCents },
36
+ ...reason && { reason },
37
+ },
38
38
  },
39
- context: { creds },
39
+ context: { credsPayload },
40
40
  });
41
41
 
42
42
  return response;
@@ -1,6 +1,6 @@
1
1
  // https://docs.stripe.com/api/refunds/retrieve
2
2
 
3
- const { credsFromPayload, ArgsWarden } = require('../utils');
3
+ const { ArgsWarden } = require('../utils');
4
4
  const { credsValidator } = require('../validators');
5
5
  const { stripeClient } = require('../stripe/stripe.utils');
6
6
 
@@ -22,11 +22,11 @@ const stripeRefundGet = async (
22
22
  return rejectResponse;
23
23
  }
24
24
 
25
- const creds = await credsFromPayload(credsPayload);
26
-
27
25
  const response = await stripeClient.fetch({
28
- url: `/refunds/${ refundId }`,
29
- context: { creds },
26
+ requestPayload: {
27
+ url: `/refunds/${ refundId }`,
28
+ },
29
+ context: { credsPayload },
30
30
  });
31
31
 
32
32
  return response;
@@ -1,6 +1,6 @@
1
1
  // https://docs.stripe.com/api/refunds/list
2
2
 
3
- const { credsFromPayload, ArgsWarden } = require('../utils');
3
+ const { ArgsWarden } = require('../utils');
4
4
  const { credsValidator } = require('../validators');
5
5
  const { stripeClient } = require('../stripe/stripe.utils');
6
6
 
@@ -20,12 +20,12 @@ const stripeRefundsGet = async (
20
20
  return rejectResponse;
21
21
  }
22
22
 
23
- const creds = await credsFromPayload(credsPayload);
24
-
25
23
  const response = await stripeClient.fetch({
26
- url: '/refunds',
27
- params,
28
- context: { creds },
24
+ requestPayload: {
25
+ url: '/refunds',
26
+ params,
27
+ },
28
+ context: { credsPayload },
29
29
  });
30
30
 
31
31
  return response;
@@ -1,6 +1,6 @@
1
1
  // https://docs.stripe.com/api/tokens/retrieve
2
2
 
3
- const { credsFromPayload, ArgsWarden } = require('../utils');
3
+ const { ArgsWarden } = require('../utils');
4
4
  const { credsValidator } = require('../validators');
5
5
  const { stripeClient } = require('../stripe/stripe.utils');
6
6
 
@@ -22,11 +22,11 @@ const stripeTokenGet = async (
22
22
  return rejectResponse;
23
23
  }
24
24
 
25
- const creds = await credsFromPayload(credsPayload);
26
-
27
25
  const response = await stripeClient.fetch({
28
- url: `/tokens/${ tokenId }`,
29
- context: { creds },
26
+ requestPayload: {
27
+ url: `/tokens/${ tokenId }`,
28
+ },
29
+ context: { credsPayload },
30
30
  });
31
31
 
32
32
  return response;
@@ -0,0 +1,5 @@
1
+ const MAX_PER_PAGE = 100;
2
+
3
+ module.exports = {
4
+ MAX_PER_PAGE,
5
+ };
@@ -0,0 +1,40 @@
1
+ const { resolveCreds, useBaseUrl } = require('../pipelineSteps');
2
+ const {
3
+ FetchClient,
4
+ fetchClientCommonSteps,
5
+ } = require('../utils');
6
+
7
+ const useStylearcadeBaseUrl = async (state) => {
8
+ const { creds } = state.context;
9
+ return useBaseUrl(creds.BASE_URL)(state);
10
+ };
11
+
12
+ const useAuthHeaders = async (state) => {
13
+ const { requestPayload, context } = state;
14
+ const { creds } = context;
15
+ const { API_KEY } = creds;
16
+
17
+ return {
18
+ requestPayload: {
19
+ ...requestPayload,
20
+ headers: {
21
+ 'Api-Key': API_KEY,
22
+ ...requestPayload.headers,
23
+ },
24
+ },
25
+ };
26
+ };
27
+
28
+ const stylearcadeClient = new FetchClient({
29
+ pipeline: [
30
+ resolveCreds,
31
+ useStylearcadeBaseUrl,
32
+ useAuthHeaders,
33
+ 'fetch',
34
+ fetchClientCommonSteps.exitEarlyOnNotOk,
35
+ ],
36
+ });
37
+
38
+ module.exports = {
39
+ stylearcadeClient,
40
+ };
@@ -0,0 +1,62 @@
1
+ // https://stylearcade.gitlab.io/api-docs/range-plan
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { stylearcadeGet, stylearcadeGetter } = require('../stylearcade/stylearcadeGet');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ]);
10
+
11
+ const stylearcadeDataGet = async (
12
+ credsPayload,
13
+ options = {},
14
+ ) => {
15
+
16
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
17
+ if (rejectResponse) {
18
+ return rejectResponse;
19
+ }
20
+
21
+ return stylearcadeGet(credsPayload, {
22
+ nodeName: 'records',
23
+ ...options,
24
+ });
25
+ };
26
+
27
+ const stylearcadeDataGetter = async (
28
+ credsPayload,
29
+ options = {},
30
+ ) => {
31
+
32
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
33
+ if (rejectResponse) {
34
+ return rejectResponse;
35
+ }
36
+
37
+ return stylearcadeGetter(credsPayload, {
38
+ nodeName: 'records',
39
+ ...options,
40
+ });
41
+ };
42
+
43
+ const funcApiConfig = {
44
+ argsWarden,
45
+ };
46
+
47
+ module.exports = {
48
+ stylearcadeDataGet,
49
+ stylearcadeDataGetter,
50
+ funcApiConfig,
51
+ };
52
+
53
+ /*
54
+ curl -X POST "http://localhost:8000/stylearcadeDataGet" \
55
+ -H "Content-Type: application/json" \
56
+ -d '{
57
+ "credsPayload": { "credsPath": "stylearcade" },
58
+ "options": {
59
+ "limit": 2000
60
+ }
61
+ }'
62
+ */
@@ -0,0 +1,133 @@
1
+ const { ArgsWarden, Getter } = require('../utils');
2
+ const { credsValidator } = require('../validators');
3
+ const { stylearcadeClient } = require('../stylearcade/stylearcade.utils');
4
+ const { MAX_PER_PAGE } = require('../stylearcade/stylearcade.constants');
5
+
6
+ const argsWarden = new ArgsWarden([
7
+ ['credsPayload', credsValidator],
8
+ ]);
9
+
10
+ const stylearcadeGetPacket = async (
11
+ credsPayload,
12
+ {
13
+ params,
14
+ perPage = MAX_PER_PAGE,
15
+ url = '/export',
16
+ } = {},
17
+ ) => {
18
+ return stylearcadeClient.fetch({
19
+ requestPayload: {
20
+ url,
21
+ params: {
22
+ limit: perPage,
23
+ ...params,
24
+ },
25
+ },
26
+ context: {
27
+ credsPayload,
28
+ },
29
+ });
30
+ };
31
+
32
+ const stylearcadeGetPaginator = async (currentParams, response) => {
33
+ if (!response?.ok) {
34
+ return [true];
35
+ }
36
+
37
+ const { nextCursor } = response.data || {};
38
+
39
+ if (!nextCursor) {
40
+ return [true];
41
+ }
42
+
43
+ const { args, options } = currentParams;
44
+
45
+ return [false, {
46
+ args,
47
+ options: {
48
+ ...options,
49
+ params: {
50
+ ...options.params,
51
+ cursor: nextCursor,
52
+ },
53
+ },
54
+ }];
55
+ };
56
+
57
+ const stylearcadeGetDigester = (response, nodeName) => {
58
+ if (!response?.ok) {
59
+ return [];
60
+ }
61
+
62
+ return response?.data?.[nodeName] ?? [];
63
+ };
64
+
65
+ const stylearcadeGet = async (
66
+ returnGetter,
67
+
68
+ credsPayload,
69
+ {
70
+ params,
71
+ perPage = MAX_PER_PAGE,
72
+ nodeName = 'records',
73
+ url = '/export',
74
+ ...getterOptions
75
+ } = {},
76
+ ) => {
77
+
78
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
79
+ credsPayload,
80
+ });
81
+ if (rejectResponse) {
82
+ return rejectResponse;
83
+ }
84
+
85
+ const getter = new Getter(
86
+ {
87
+ args: [credsPayload],
88
+ options: {
89
+ params,
90
+ perPage,
91
+ url,
92
+ },
93
+ },
94
+ {
95
+ func: stylearcadeGetPacket,
96
+ digester: (response) => stylearcadeGetDigester(response, nodeName),
97
+ paginator: stylearcadeGetPaginator,
98
+ ...getterOptions,
99
+ },
100
+ );
101
+
102
+ if (returnGetter) {
103
+ return getter;
104
+ }
105
+
106
+ const data = await getter.run({ returnAll: true });
107
+
108
+ return {
109
+ ok: true,
110
+ data,
111
+ };
112
+ };
113
+
114
+ const funcApiConfig = {
115
+ argsWarden,
116
+ };
117
+
118
+ module.exports = {
119
+ stylearcadeGet: (...args) => stylearcadeGet(false, ...args),
120
+ stylearcadeGetter: (...args) => stylearcadeGet(true, ...args),
121
+ funcApiConfig,
122
+ };
123
+
124
+ /*
125
+ curl -X POST "http://localhost:8000/stylearcadeGet" \
126
+ -H "Content-Type: application/json" \
127
+ -d '{
128
+ "credsPayload": { "credsPath": "stylearcade" },
129
+ "options": {
130
+ "limit": 10
131
+ }
132
+ }'
133
+ */