@foxtware/mineral 0.1.28 → 0.1.30

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 (95) hide show
  1. package/.creds.yml.sample +35 -2
  2. package/AGENTS.md +7 -0
  3. package/_build_scripts/createNewFunction.js +26 -3
  4. package/api/dpd/docs.md +6 -0
  5. package/api/dpd/dpd.constants.js +9 -0
  6. package/api/dpd/dpd.utils.js +145 -0
  7. package/api/dpd/dpdTrackingGet.js +64 -0
  8. package/api/dropbox/docs.md +7 -0
  9. package/api/dropbox/dropbox.constants.js +10 -0
  10. package/api/dropbox/dropbox.utils.js +67 -0
  11. package/api/dropbox/dropboxAccountGet.js +64 -0
  12. package/api/dropbox/dropboxFileCopy.js +67 -0
  13. package/api/dropbox/dropboxFileDelete.js +89 -0
  14. package/api/dropbox/dropboxFileDownload.js +139 -0
  15. package/api/dropbox/dropboxFileMetadataGet.js +100 -0
  16. package/api/dropbox/dropboxFileMove.js +67 -0
  17. package/api/dropbox/dropboxFileUpload.js +129 -0
  18. package/api/dropbox/dropboxFolderCreate.js +68 -0
  19. package/api/dropbox/dropboxFolderList.js +66 -0
  20. package/api/dropbox/dropboxGet.js +158 -0
  21. package/api/dropbox/dropboxSearch.js +161 -0
  22. package/api/dropbox/dropboxSharedLinkCreate.js +68 -0
  23. package/api/dropbox/dropboxSpaceUsageGet.js +55 -0
  24. package/api/dropbox/dropboxTemporaryLinkGet.js +75 -0
  25. package/api/fedex/docs.md +6 -0
  26. package/api/fedex/fedex.constants.js +11 -0
  27. package/api/fedex/fedex.utils.js +151 -0
  28. package/api/fedex/fedexTrackingGet.js +76 -0
  29. package/api/google/docs.md +1 -0
  30. package/api/google/google.constants.js +1 -0
  31. package/api/google/google.utils.js +21 -0
  32. package/api/google/googleanalyticsMetadataGet.js +62 -0
  33. package/api/google/googleanalyticsRealtimeReportRun.js +103 -0
  34. package/api/google/googleanalyticsReportRun.js +114 -0
  35. package/api/paypal/docs.md +14 -0
  36. package/api/paypal/paypal.constants.js +13 -0
  37. package/api/paypal/paypal.utils.js +166 -0
  38. package/api/paypal/paypalAccessTokenGet.js +81 -0
  39. package/api/paypal/paypalAuthorizationCapture.js +75 -0
  40. package/api/paypal/paypalAuthorizationGet.js +57 -0
  41. package/api/paypal/paypalBalancesGet.js +65 -0
  42. package/api/paypal/paypalCaptureGet.js +57 -0
  43. package/api/paypal/paypalCaptureRefund.js +78 -0
  44. package/api/paypal/paypalOrderAuthorize.js +69 -0
  45. package/api/paypal/paypalOrderCapture.js +69 -0
  46. package/api/paypal/paypalOrderCreate.js +81 -0
  47. package/api/paypal/paypalOrderGet.js +57 -0
  48. package/api/paypal/paypalRefundGet.js +57 -0
  49. package/api/paypal/paypalTransactionsGet.js +101 -0
  50. package/api/paypal/paypalUserInfoGet.js +62 -0
  51. package/api/royalmail/docs.md +6 -0
  52. package/api/royalmail/royalmail.constants.js +7 -0
  53. package/api/royalmail/royalmail.utils.js +55 -0
  54. package/api/royalmail/royalmailTrackingGet.js +70 -0
  55. package/api/shopify/shopify.utils.js +65 -4
  56. package/api/shopify/shopifyMetaobjectCreate.js +13 -6
  57. package/api/shopify/shopifyMetaobjectDelete.js +90 -0
  58. package/api/shopify/shopifyMetaobjectGet.js +80 -0
  59. package/api/shopify/shopifyMetaobjectUpdate.js +108 -0
  60. package/api/shopify/shopifyStorefrontSearch.js +158 -0
  61. package/api/spotify/docs.md +8 -0
  62. package/api/spotify/spotify.constants.js +12 -0
  63. package/api/spotify/spotify.utils.js +106 -0
  64. package/api/spotify/spotifyAlbumGet.js +76 -0
  65. package/api/spotify/spotifyAlbumTracksGet.js +49 -0
  66. package/api/spotify/spotifyArtistAlbumsGet.js +55 -0
  67. package/api/spotify/spotifyArtistGet.js +71 -0
  68. package/api/spotify/spotifyArtistTopTracksGet.js +56 -0
  69. package/api/spotify/spotifyGet.js +171 -0
  70. package/api/spotify/spotifyMeGet.js +48 -0
  71. package/api/spotify/spotifyPlayerCurrentlyPlayingGet.js +62 -0
  72. package/api/spotify/spotifyPlayerDevicesGet.js +51 -0
  73. package/api/spotify/spotifyPlayerGet.js +63 -0
  74. package/api/spotify/spotifyPlayerNext.js +55 -0
  75. package/api/spotify/spotifyPlayerPause.js +55 -0
  76. package/api/spotify/spotifyPlayerPlay.js +70 -0
  77. package/api/spotify/spotifyPlayerPrevious.js +55 -0
  78. package/api/spotify/spotifyPlaylistCreate.js +63 -0
  79. package/api/spotify/spotifyPlaylistGet.js +91 -0
  80. package/api/spotify/spotifyPlaylistItemsAdd.js +61 -0
  81. package/api/spotify/spotifyPlaylistItemsGet.js +58 -0
  82. package/api/spotify/spotifyPlaylistItemsRemove.js +67 -0
  83. package/api/spotify/spotifyPlaylistUpdate.js +64 -0
  84. package/api/spotify/spotifyPlaylistsGet.js +47 -0
  85. package/api/spotify/spotifySavedTracksGet.js +46 -0
  86. package/api/spotify/spotifySavedTracksRemove.js +59 -0
  87. package/api/spotify/spotifySavedTracksSave.js +59 -0
  88. package/api/spotify/spotifySearch.js +174 -0
  89. package/api/spotify/spotifyTrackGet.js +76 -0
  90. package/api/starshipit/starshipitProductUpdate.js +102 -0
  91. package/api/starshipit/starshipitProductsGet.js +2 -2
  92. package/api/stylearcade/stylearcadeGet.js +5 -2
  93. package/api/utils.js +39 -0
  94. package/package.json +1 -1
  95. package/server.js +3 -1
@@ -0,0 +1,75 @@
1
+ // https://developer.paypal.com/docs/api/payments/v2/#authorizations_capture
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { paypalClient } = require('../paypal/paypal.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['authorizationId'],
10
+ ]);
11
+
12
+ const paypalAuthorizationCapture = async (
13
+ credsPayload,
14
+ authorizationId,
15
+ {
16
+ capture,
17
+ prefer = 'return=representation',
18
+ requestId,
19
+ fetchClient = paypalClient,
20
+ } = {},
21
+ ) => {
22
+
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ authorizationId,
26
+ });
27
+ if (rejectResponse) {
28
+ return rejectResponse;
29
+ }
30
+
31
+ const headers = {
32
+ Prefer: prefer,
33
+ };
34
+ if (requestId) {
35
+ headers['PayPal-Request-Id'] = requestId;
36
+ }
37
+
38
+ const response = await fetchClient.fetch({
39
+ requestPayload: {
40
+ method: 'post',
41
+ url: `/v2/payments/authorizations/${ encodeURIComponent(authorizationId) }/capture`,
42
+ headers,
43
+ body: capture !== undefined ? capture : {},
44
+ },
45
+ context: {
46
+ credsPayload,
47
+ },
48
+ });
49
+
50
+ return response;
51
+ };
52
+
53
+ const funcApiConfig = {
54
+ argsWarden,
55
+ };
56
+
57
+ module.exports = {
58
+ paypalAuthorizationCapture,
59
+ funcApiConfig,
60
+ };
61
+
62
+ /*
63
+ curl -X POST "http://localhost:8000/paypalAuthorizationCapture" \
64
+ -H "Content-Type: application/json" \
65
+ -d '{
66
+ "credsPayload": { "credsPath": "paypal" },
67
+ "authorizationId": "0VF52814937998046",
68
+ "options": {
69
+ "capture": {
70
+ "amount": { "value": "10.00", "currency_code": "USD" },
71
+ "final_capture": true
72
+ }
73
+ }
74
+ }'
75
+ */
@@ -0,0 +1,57 @@
1
+ // https://developer.paypal.com/docs/api/payments/v2/#authorizations_get
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { paypalClient } = require('../paypal/paypal.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['authorizationId'],
10
+ ]);
11
+
12
+ const paypalAuthorizationGet = async (
13
+ credsPayload,
14
+ authorizationId,
15
+ {
16
+ fetchClient = paypalClient,
17
+ } = {},
18
+ ) => {
19
+
20
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
21
+ credsPayload,
22
+ authorizationId,
23
+ });
24
+ if (rejectResponse) {
25
+ return rejectResponse;
26
+ }
27
+
28
+ const response = await fetchClient.fetch({
29
+ requestPayload: {
30
+ method: 'get',
31
+ url: `/v2/payments/authorizations/${ encodeURIComponent(authorizationId) }`,
32
+ },
33
+ context: {
34
+ credsPayload,
35
+ },
36
+ });
37
+
38
+ return response;
39
+ };
40
+
41
+ const funcApiConfig = {
42
+ argsWarden,
43
+ };
44
+
45
+ module.exports = {
46
+ paypalAuthorizationGet,
47
+ funcApiConfig,
48
+ };
49
+
50
+ /*
51
+ curl -X POST "http://localhost:8000/paypalAuthorizationGet" \
52
+ -H "Content-Type: application/json" \
53
+ -d '{
54
+ "credsPayload": { "credsPath": "paypal" },
55
+ "authorizationId": "0VF52814937998046"
56
+ }'
57
+ */
@@ -0,0 +1,65 @@
1
+ // https://developer.paypal.com/docs/api/transaction-search/v1/#balances_get
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { paypalClient } = require('../paypal/paypal.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ]);
10
+
11
+ /**
12
+ * List balances for the account. Optional asOfTime is ISO-8601.
13
+ */
14
+ const paypalBalancesGet = async (
15
+ credsPayload,
16
+ {
17
+ asOfTime,
18
+ currencyCode,
19
+ fetchClient = paypalClient,
20
+ } = {},
21
+ ) => {
22
+
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ });
26
+ if (rejectResponse) {
27
+ return rejectResponse;
28
+ }
29
+
30
+ const response = await fetchClient.fetch({
31
+ requestPayload: {
32
+ method: 'get',
33
+ url: '/v1/reporting/balances',
34
+ params: {
35
+ ...(asOfTime ? { as_of_time: asOfTime } : {}),
36
+ ...(currencyCode ? { currency_code: currencyCode } : {}),
37
+ },
38
+ },
39
+ context: {
40
+ credsPayload,
41
+ },
42
+ });
43
+
44
+ return response;
45
+ };
46
+
47
+ const funcApiConfig = {
48
+ argsWarden,
49
+ };
50
+
51
+ module.exports = {
52
+ paypalBalancesGet,
53
+ funcApiConfig,
54
+ };
55
+
56
+ /*
57
+ curl -X POST "http://localhost:8000/paypalBalancesGet" \
58
+ -H "Content-Type: application/json" \
59
+ -d '{
60
+ "credsPayload": { "credsPath": "paypal" },
61
+ "options": {
62
+ "currencyCode": "USD"
63
+ }
64
+ }'
65
+ */
@@ -0,0 +1,57 @@
1
+ // https://developer.paypal.com/docs/api/payments/v2/#captures_get
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { paypalClient } = require('../paypal/paypal.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['captureId'],
10
+ ]);
11
+
12
+ const paypalCaptureGet = async (
13
+ credsPayload,
14
+ captureId,
15
+ {
16
+ fetchClient = paypalClient,
17
+ } = {},
18
+ ) => {
19
+
20
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
21
+ credsPayload,
22
+ captureId,
23
+ });
24
+ if (rejectResponse) {
25
+ return rejectResponse;
26
+ }
27
+
28
+ const response = await fetchClient.fetch({
29
+ requestPayload: {
30
+ method: 'get',
31
+ url: `/v2/payments/captures/${ encodeURIComponent(captureId) }`,
32
+ },
33
+ context: {
34
+ credsPayload,
35
+ },
36
+ });
37
+
38
+ return response;
39
+ };
40
+
41
+ const funcApiConfig = {
42
+ argsWarden,
43
+ };
44
+
45
+ module.exports = {
46
+ paypalCaptureGet,
47
+ funcApiConfig,
48
+ };
49
+
50
+ /*
51
+ curl -X POST "http://localhost:8000/paypalCaptureGet" \
52
+ -H "Content-Type: application/json" \
53
+ -d '{
54
+ "credsPayload": { "credsPath": "paypal" },
55
+ "captureId": "2GG279541U471931P"
56
+ }'
57
+ */
@@ -0,0 +1,78 @@
1
+ // https://developer.paypal.com/docs/api/payments/v2/#captures_refund
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { paypalClient } = require('../paypal/paypal.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['captureId'],
10
+ ]);
11
+
12
+ /**
13
+ * Refund a captured payment. Optional `refund` body can include amount,
14
+ * invoice_id, note_to_payer, etc. Omit body (or pass {}) for a full refund.
15
+ */
16
+ const paypalCaptureRefund = async (
17
+ credsPayload,
18
+ captureId,
19
+ {
20
+ refund,
21
+ prefer = 'return=representation',
22
+ requestId,
23
+ fetchClient = paypalClient,
24
+ } = {},
25
+ ) => {
26
+
27
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
28
+ credsPayload,
29
+ captureId,
30
+ });
31
+ if (rejectResponse) {
32
+ return rejectResponse;
33
+ }
34
+
35
+ const headers = {
36
+ Prefer: prefer,
37
+ };
38
+ if (requestId) {
39
+ headers['PayPal-Request-Id'] = requestId;
40
+ }
41
+
42
+ const response = await fetchClient.fetch({
43
+ requestPayload: {
44
+ method: 'post',
45
+ url: `/v2/payments/captures/${ encodeURIComponent(captureId) }/refund`,
46
+ headers,
47
+ body: refund !== undefined ? refund : {},
48
+ },
49
+ context: {
50
+ credsPayload,
51
+ },
52
+ });
53
+
54
+ return response;
55
+ };
56
+
57
+ const funcApiConfig = {
58
+ argsWarden,
59
+ };
60
+
61
+ module.exports = {
62
+ paypalCaptureRefund,
63
+ funcApiConfig,
64
+ };
65
+
66
+ /*
67
+ curl -X POST "http://localhost:8000/paypalCaptureRefund" \
68
+ -H "Content-Type: application/json" \
69
+ -d '{
70
+ "credsPayload": { "credsPath": "paypal" },
71
+ "captureId": "2GG279541U471931P",
72
+ "options": {
73
+ "refund": {
74
+ "amount": { "value": "10.00", "currency_code": "USD" }
75
+ }
76
+ }
77
+ }'
78
+ */
@@ -0,0 +1,69 @@
1
+ // https://developer.paypal.com/docs/api/orders/v2/#orders_authorize
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { paypalClient } = require('../paypal/paypal.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['orderId'],
10
+ ]);
11
+
12
+ const paypalOrderAuthorize = async (
13
+ credsPayload,
14
+ orderId,
15
+ {
16
+ body,
17
+ prefer = 'return=representation',
18
+ requestId,
19
+ fetchClient = paypalClient,
20
+ } = {},
21
+ ) => {
22
+
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ orderId,
26
+ });
27
+ if (rejectResponse) {
28
+ return rejectResponse;
29
+ }
30
+
31
+ const headers = {
32
+ Prefer: prefer,
33
+ };
34
+ if (requestId) {
35
+ headers['PayPal-Request-Id'] = requestId;
36
+ }
37
+
38
+ const response = await fetchClient.fetch({
39
+ requestPayload: {
40
+ method: 'post',
41
+ url: `/v2/checkout/orders/${ encodeURIComponent(orderId) }/authorize`,
42
+ headers,
43
+ ...(body !== undefined ? { body } : { body: {} }),
44
+ },
45
+ context: {
46
+ credsPayload,
47
+ },
48
+ });
49
+
50
+ return response;
51
+ };
52
+
53
+ const funcApiConfig = {
54
+ argsWarden,
55
+ };
56
+
57
+ module.exports = {
58
+ paypalOrderAuthorize,
59
+ funcApiConfig,
60
+ };
61
+
62
+ /*
63
+ curl -X POST "http://localhost:8000/paypalOrderAuthorize" \
64
+ -H "Content-Type: application/json" \
65
+ -d '{
66
+ "credsPayload": { "credsPath": "paypal" },
67
+ "orderId": "5O190127TN364715T"
68
+ }'
69
+ */
@@ -0,0 +1,69 @@
1
+ // https://developer.paypal.com/docs/api/orders/v2/#orders_capture
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { paypalClient } = require('../paypal/paypal.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['orderId'],
10
+ ]);
11
+
12
+ const paypalOrderCapture = async (
13
+ credsPayload,
14
+ orderId,
15
+ {
16
+ body,
17
+ prefer = 'return=representation',
18
+ requestId,
19
+ fetchClient = paypalClient,
20
+ } = {},
21
+ ) => {
22
+
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ orderId,
26
+ });
27
+ if (rejectResponse) {
28
+ return rejectResponse;
29
+ }
30
+
31
+ const headers = {
32
+ Prefer: prefer,
33
+ };
34
+ if (requestId) {
35
+ headers['PayPal-Request-Id'] = requestId;
36
+ }
37
+
38
+ const response = await fetchClient.fetch({
39
+ requestPayload: {
40
+ method: 'post',
41
+ url: `/v2/checkout/orders/${ encodeURIComponent(orderId) }/capture`,
42
+ headers,
43
+ ...(body !== undefined ? { body } : { body: {} }),
44
+ },
45
+ context: {
46
+ credsPayload,
47
+ },
48
+ });
49
+
50
+ return response;
51
+ };
52
+
53
+ const funcApiConfig = {
54
+ argsWarden,
55
+ };
56
+
57
+ module.exports = {
58
+ paypalOrderCapture,
59
+ funcApiConfig,
60
+ };
61
+
62
+ /*
63
+ curl -X POST "http://localhost:8000/paypalOrderCapture" \
64
+ -H "Content-Type: application/json" \
65
+ -d '{
66
+ "credsPayload": { "credsPath": "paypal" },
67
+ "orderId": "5O190127TN364715T"
68
+ }'
69
+ */
@@ -0,0 +1,81 @@
1
+ // https://developer.paypal.com/docs/api/orders/v2/#orders_create
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { paypalClient } = require('../paypal/paypal.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['order'],
10
+ ]);
11
+
12
+ /**
13
+ * Create a PayPal order.
14
+ * `order` is the full Orders v2 create payload, e.g.:
15
+ * {
16
+ * intent: 'CAPTURE',
17
+ * purchase_units: [{ amount: { currency_code: 'USD', value: '10.00' } }],
18
+ * }
19
+ */
20
+ const paypalOrderCreate = async (
21
+ credsPayload,
22
+ order,
23
+ {
24
+ prefer = 'return=representation',
25
+ requestId,
26
+ fetchClient = paypalClient,
27
+ } = {},
28
+ ) => {
29
+
30
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
31
+ credsPayload,
32
+ order,
33
+ });
34
+ if (rejectResponse) {
35
+ return rejectResponse;
36
+ }
37
+
38
+ const headers = {
39
+ Prefer: prefer,
40
+ };
41
+ if (requestId) {
42
+ headers['PayPal-Request-Id'] = requestId;
43
+ }
44
+
45
+ const response = await fetchClient.fetch({
46
+ requestPayload: {
47
+ method: 'post',
48
+ url: '/v2/checkout/orders',
49
+ headers,
50
+ body: order,
51
+ },
52
+ context: {
53
+ credsPayload,
54
+ },
55
+ });
56
+
57
+ return response;
58
+ };
59
+
60
+ const funcApiConfig = {
61
+ argsWarden,
62
+ };
63
+
64
+ module.exports = {
65
+ paypalOrderCreate,
66
+ funcApiConfig,
67
+ };
68
+
69
+ /*
70
+ curl -X POST "http://localhost:8000/paypalOrderCreate" \
71
+ -H "Content-Type: application/json" \
72
+ -d '{
73
+ "credsPayload": { "credsPath": "paypal" },
74
+ "order": {
75
+ "intent": "CAPTURE",
76
+ "purchase_units": [{
77
+ "amount": { "currency_code": "USD", "value": "10.00" }
78
+ }]
79
+ }
80
+ }'
81
+ */
@@ -0,0 +1,57 @@
1
+ // https://developer.paypal.com/docs/api/orders/v2/#orders_get
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { paypalClient } = require('../paypal/paypal.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['orderId'],
10
+ ]);
11
+
12
+ const paypalOrderGet = async (
13
+ credsPayload,
14
+ orderId,
15
+ {
16
+ fetchClient = paypalClient,
17
+ } = {},
18
+ ) => {
19
+
20
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
21
+ credsPayload,
22
+ orderId,
23
+ });
24
+ if (rejectResponse) {
25
+ return rejectResponse;
26
+ }
27
+
28
+ const response = await fetchClient.fetch({
29
+ requestPayload: {
30
+ method: 'get',
31
+ url: `/v2/checkout/orders/${ encodeURIComponent(orderId) }`,
32
+ },
33
+ context: {
34
+ credsPayload,
35
+ },
36
+ });
37
+
38
+ return response;
39
+ };
40
+
41
+ const funcApiConfig = {
42
+ argsWarden,
43
+ };
44
+
45
+ module.exports = {
46
+ paypalOrderGet,
47
+ funcApiConfig,
48
+ };
49
+
50
+ /*
51
+ curl -X POST "http://localhost:8000/paypalOrderGet" \
52
+ -H "Content-Type: application/json" \
53
+ -d '{
54
+ "credsPayload": { "credsPath": "paypal" },
55
+ "orderId": "5O190127TN364715T"
56
+ }'
57
+ */
@@ -0,0 +1,57 @@
1
+ // https://developer.paypal.com/docs/api/payments/v2/#refunds_get
2
+
3
+ const { credsValidator } = require('../validators');
4
+ const { ArgsWarden } = require('../utils');
5
+ const { paypalClient } = require('../paypal/paypal.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['refundId'],
10
+ ]);
11
+
12
+ const paypalRefundGet = async (
13
+ credsPayload,
14
+ refundId,
15
+ {
16
+ fetchClient = paypalClient,
17
+ } = {},
18
+ ) => {
19
+
20
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
21
+ credsPayload,
22
+ refundId,
23
+ });
24
+ if (rejectResponse) {
25
+ return rejectResponse;
26
+ }
27
+
28
+ const response = await fetchClient.fetch({
29
+ requestPayload: {
30
+ method: 'get',
31
+ url: `/v2/payments/refunds/${ encodeURIComponent(refundId) }`,
32
+ },
33
+ context: {
34
+ credsPayload,
35
+ },
36
+ });
37
+
38
+ return response;
39
+ };
40
+
41
+ const funcApiConfig = {
42
+ argsWarden,
43
+ };
44
+
45
+ module.exports = {
46
+ paypalRefundGet,
47
+ funcApiConfig,
48
+ };
49
+
50
+ /*
51
+ curl -X POST "http://localhost:8000/paypalRefundGet" \
52
+ -H "Content-Type: application/json" \
53
+ -d '{
54
+ "credsPayload": { "credsPath": "paypal" },
55
+ "refundId": "1JU08902781691411"
56
+ }'
57
+ */