@foxtware/mineral 0.1.0 → 0.1.1

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 (59) hide show
  1. package/.creds.yml.sample +5 -0
  2. package/README.md +1 -1
  3. package/_build_scripts/publish.js +85 -0
  4. package/api/logiwa/logiwa.constants.js +8 -0
  5. package/api/logiwa/logiwa.utils.js +53 -0
  6. package/api/logiwa/logiwaAuthGet.js +86 -0
  7. package/api/logiwa/logiwaInventoriesGet.js +67 -0
  8. package/api/logiwa/logiwaOrderGet.js +54 -0
  9. package/api/logiwa/logiwaOrdersGet.js +92 -0
  10. package/api/logiwa/logiwaProductGet.js +54 -0
  11. package/api/logiwa/logiwaProductsGet.js +80 -0
  12. package/api/logiwa/logiwaReportGetAvailableToPromise.js +179 -0
  13. package/api/logiwa/logiwaReportGetInventoryCalculation.js +62 -0
  14. package/api/logiwa/logiwaReportGetInventorySnapshot.js +66 -0
  15. package/api/logiwa/logiwaReportGetTotalInventory.js +72 -0
  16. package/api/logiwa/logiwaWebhookStatusGet.js +54 -0
  17. package/api/logiwa/logiwaWebhookSubscribe.js +64 -0
  18. package/api/logiwa/logiwaWebhookUnsubscribe.js +54 -0
  19. package/api/logiwa/logiwaWebhooksGet.js +48 -0
  20. package/api/shopify/_example.get.js +46 -0
  21. package/api/shopify/shopifyAbandonedCheckoutsGet.js +46 -0
  22. package/api/shopify/shopifyArticlesGet.js +46 -0
  23. package/api/shopify/shopifyBlogsGet.js +46 -0
  24. package/api/shopify/shopifyBulkOperationsGet.js +46 -0
  25. package/api/shopify/shopifyCatalogsGet.js +46 -0
  26. package/api/shopify/shopifyChannelsGet.js +46 -0
  27. package/api/shopify/shopifyCheckoutAndAccountsConfigurationsGet.js +46 -0
  28. package/api/shopify/shopifyCollectionsGet.js +46 -0
  29. package/api/shopify/shopifyCustomersGet.js +2 -0
  30. package/api/shopify/shopifyDeliveryCustomizationsGet.js +46 -0
  31. package/api/shopify/shopifyDeliveryProfilesGet.js +46 -0
  32. package/api/shopify/shopifyDiscountNodesGet.js +46 -0
  33. package/api/shopify/shopifyDisputesGet.js +46 -0
  34. package/api/shopify/shopifyDraftOrdersGet.js +46 -0
  35. package/api/shopify/shopifyEventsGet.js +46 -0
  36. package/api/shopify/shopifyFilesGet.js +46 -0
  37. package/api/shopify/shopifyFulfillmentOrdersGet.js +46 -0
  38. package/api/shopify/shopifyGiftCardsGet.js +46 -0
  39. package/api/shopify/shopifyInventoryItemsGet.js +46 -0
  40. package/api/shopify/shopifyLocationsGet.js +46 -0
  41. package/api/shopify/shopifyMarketingEventsGet.js +46 -0
  42. package/api/shopify/shopifyMarketsGet.js +46 -0
  43. package/api/shopify/shopifyMenusGet.js +46 -0
  44. package/api/shopify/shopifyMetafieldDefinitionsGet.js +50 -0
  45. package/api/shopify/shopifyMetaobjectDefinitionsGet.js +46 -0
  46. package/api/shopify/shopifyMetaobjectsGet.js +50 -0
  47. package/api/shopify/shopifyPagesGet.js +46 -0
  48. package/api/shopify/shopifyPaymentCustomizationsGet.js +46 -0
  49. package/api/shopify/shopifyProductFeedsGet.js +46 -0
  50. package/api/shopify/shopifyProductVariantsGet.js +46 -0
  51. package/api/shopify/shopifyProductsGet.js +46 -0
  52. package/api/shopify/shopifyPublicationsGet.js +46 -0
  53. package/api/shopify/shopifySegmentsGet.js +46 -0
  54. package/api/shopify/shopifyUrlRedirectsGet.js +46 -0
  55. package/api/shopify/shopifyWebhookSubscriptionsGet.js +46 -0
  56. package/api/utils.js +4 -3
  57. package/api/workspace.js +43 -0
  58. package/package.json +5 -3
  59. package/server.js +205 -105
@@ -0,0 +1,179 @@
1
+ // https://myapi.logiwa.com/swagger/index.html#/Report/get_v3_1_Report_AvailableToPromise_i__index__s__size_
2
+
3
+ const { ArgsWarden, actionSingleOrMultiple } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { logiwaClient } = require('../logiwa/logiwa.utils');
6
+ const { DEFAULT_API_VERSION, MAX_PER_PAGE } = require('../logiwa/logiwa.constants');
7
+
8
+ const isSet = (value) => {
9
+ if (value === 0 || value === false || value === '') {
10
+ return true;
11
+ }
12
+
13
+ return Boolean(value);
14
+ };
15
+
16
+ const logiwaReportGetAvailableToPromiseSingle = async (
17
+ credsPayload,
18
+ {
19
+ apiVersion = DEFAULT_API_VERSION,
20
+ page = 0,
21
+ perPage = MAX_PER_PAGE,
22
+ sku_eq,
23
+ clientIdentifier_eq,
24
+ clientIdentifier_in,
25
+ warehouseIdentifier_eq,
26
+ warehouseIdentifier_in,
27
+ plannedAtpQuantity_eq,
28
+ plannedAtpQuantity_gt,
29
+ plannedAtpQuantity_lt,
30
+ plannedAtpQuantity_gte,
31
+ plannedAtpQuantity_lte,
32
+ totalStockQuantity_eq,
33
+ totalStockQuantity_gt,
34
+ totalStockQuantity_lt,
35
+ totalStockQuantity_gte,
36
+ totalStockQuantity_lte,
37
+ inventoryAtpQuantity_eq,
38
+ inventoryAtpQuantity_gt,
39
+ inventoryAtpQuantity_lt,
40
+ inventoryAtpQuantity_gte,
41
+ inventoryAtpQuantity_lte,
42
+ undamagedQuantity_eq,
43
+ undamagedQuantity_gt,
44
+ undamagedQuantity_lt,
45
+ undamagedQuantity_gte,
46
+ undamagedQuantity_lte,
47
+ currentAtpQuantity_eq,
48
+ currentAtpQuantity_gt,
49
+ currentAtpQuantity_lt,
50
+ currentAtpQuantity_gte,
51
+ currentAtpQuantity_lte,
52
+ } = {},
53
+ ) => {
54
+
55
+ const params = {
56
+ ...(sku_eq && { 'Sku.eq': sku_eq }),
57
+ ...(clientIdentifier_eq && { 'ClientIdentifier.eq': clientIdentifier_eq }),
58
+ ...(clientIdentifier_in && { 'ClientIdentifier.in': clientIdentifier_in }),
59
+ ...(warehouseIdentifier_eq && { 'WarehouseIdentifier.eq': warehouseIdentifier_eq }),
60
+ ...(warehouseIdentifier_in && { 'WarehouseIdentifier.in': warehouseIdentifier_in }),
61
+ ...(isSet(plannedAtpQuantity_eq) && { 'PlannedATPQuantity.eq': plannedAtpQuantity_eq }),
62
+ ...(isSet(plannedAtpQuantity_gt) && { 'PlannedATPQuantity.gt': plannedAtpQuantity_gt }),
63
+ ...(isSet(plannedAtpQuantity_lt) && { 'PlannedATPQuantity.lt': plannedAtpQuantity_lt }),
64
+ ...(isSet(plannedAtpQuantity_gte) && { 'PlannedATPQuantity.gte': plannedAtpQuantity_gte }),
65
+ ...(isSet(plannedAtpQuantity_lte) && { 'PlannedATPQuantity.lte': plannedAtpQuantity_lte }),
66
+ ...(apiVersion === 'v3.1' ? {
67
+ ...(isSet(totalStockQuantity_eq) && { 'TotalStockQuantity.eq': totalStockQuantity_eq }),
68
+ ...(isSet(totalStockQuantity_gt) && { 'TotalStockQuantity.gt': totalStockQuantity_gt }),
69
+ ...(isSet(totalStockQuantity_lt) && { 'TotalStockQuantity.lt': totalStockQuantity_lt }),
70
+ ...(isSet(totalStockQuantity_gte) && { 'TotalStockQuantity.gte': totalStockQuantity_gte }),
71
+ ...(isSet(totalStockQuantity_lte) && { 'TotalStockQuantity.lte': totalStockQuantity_lte }),
72
+ ...(isSet(inventoryAtpQuantity_eq) && { 'InventoryATPQuantity.eq': inventoryAtpQuantity_eq }),
73
+ ...(isSet(inventoryAtpQuantity_gt) && { 'InventoryATPQuantity.gt': inventoryAtpQuantity_gt }),
74
+ ...(isSet(inventoryAtpQuantity_lt) && { 'InventoryATPQuantity.lt': inventoryAtpQuantity_lt }),
75
+ ...(isSet(inventoryAtpQuantity_gte) && { 'InventoryATPQuantity.gte': inventoryAtpQuantity_gte }),
76
+ ...(isSet(inventoryAtpQuantity_lte) && { 'InventoryATPQuantity.lte': inventoryAtpQuantity_lte }),
77
+ } : {}),
78
+ ...(apiVersion === 'v3.2' ? {
79
+ ...(isSet(undamagedQuantity_eq) && { 'UndamagedQuantity.eq': undamagedQuantity_eq }),
80
+ ...(isSet(undamagedQuantity_gt) && { 'UndamagedQuantity.gt': undamagedQuantity_gt }),
81
+ ...(isSet(undamagedQuantity_lt) && { 'UndamagedQuantity.lt': undamagedQuantity_lt }),
82
+ ...(isSet(undamagedQuantity_gte) && { 'UndamagedQuantity.gte': undamagedQuantity_gte }),
83
+ ...(isSet(undamagedQuantity_lte) && { 'UndamagedQuantity.lte': undamagedQuantity_lte }),
84
+ ...(isSet(currentAtpQuantity_eq) && { 'CurrentATPQuantity.eq': currentAtpQuantity_eq }),
85
+ ...(isSet(currentAtpQuantity_gt) && { 'CurrentATPQuantity.gt': currentAtpQuantity_gt }),
86
+ ...(isSet(currentAtpQuantity_lt) && { 'CurrentATPQuantity.lt': currentAtpQuantity_lt }),
87
+ ...(isSet(currentAtpQuantity_gte) && { 'CurrentATPQuantity.gte': currentAtpQuantity_gte }),
88
+ ...(isSet(currentAtpQuantity_lte) && { 'CurrentATPQuantity.lte': currentAtpQuantity_lte }),
89
+ } : {}),
90
+ };
91
+
92
+ if (!Object.keys(params).length) {
93
+ return {
94
+ ok: false,
95
+ error: {
96
+ code: 'INVALID_CRITERIA',
97
+ message: 'At least one filter is required, and criteria must match the API version.',
98
+ },
99
+ };
100
+ }
101
+
102
+ return logiwaClient.fetch({
103
+ method: 'get',
104
+ url: `/Report/AvailableToPromise/i/${ page }/s/${ perPage }`,
105
+ params,
106
+ context: {
107
+ credsPayload,
108
+ apiVersion,
109
+ },
110
+ });
111
+ };
112
+
113
+ const argsWarden = new ArgsWarden([
114
+ ['credsPayload', credsValidator],
115
+ ['criteria'],
116
+ ]);
117
+
118
+ const logiwaReportGetAvailableToPromise = async (
119
+ credsPayload,
120
+ criteria,
121
+ {
122
+ queueRunOptions,
123
+ ...options
124
+ } = {},
125
+ ) => {
126
+
127
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
128
+ credsPayload,
129
+ criteria,
130
+ });
131
+ if (rejectResponse) {
132
+ return rejectResponse;
133
+ }
134
+
135
+ return actionSingleOrMultiple(
136
+ criteria,
137
+ logiwaReportGetAvailableToPromiseSingle,
138
+ (singleCriteria) => ({
139
+ args: [
140
+ credsPayload,
141
+ {
142
+ ...singleCriteria,
143
+ ...options,
144
+ },
145
+ ],
146
+ }),
147
+ {
148
+ ...(queueRunOptions ? { queueRunOptions } : {}),
149
+ },
150
+ );
151
+ };
152
+
153
+ const funcApiConfig = {
154
+ argsWarden,
155
+ };
156
+
157
+ module.exports = {
158
+ logiwaReportGetAvailableToPromise,
159
+ funcApiConfig,
160
+ };
161
+
162
+ /*
163
+ curl -X POST "http://localhost:8000/logiwaReportGetAvailableToPromise" \
164
+ -H "Content-Type: application/json" \
165
+ -d '{
166
+ "credsPayload": { "credsPath": "logiwa" },
167
+ "criteria": { "clientIdentifier_eq": "9f1ea39a-fccc-48af-8986-a35c34fcef8b" }
168
+ }'
169
+
170
+ curl -X POST "http://localhost:8000/logiwaReportGetAvailableToPromise" \
171
+ -H "Content-Type: application/json" \
172
+ -d '{
173
+ "credsPayload": { "credsPath": "logiwa" },
174
+ "criteria": [
175
+ { "sku_eq": "EXDAL355-15-S/M" },
176
+ { "sku_eq": "EXD535-1-XXS/XS" }
177
+ ]
178
+ }'
179
+ */
@@ -0,0 +1,62 @@
1
+ // https://myapi.logiwa.com/swagger/index.html#/Report/get_v3_1_Report_InventoryCalculation_i__index__s__size_
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { logiwaClient } = require('../logiwa/logiwa.utils');
6
+ const { MAX_PER_PAGE } = require('../logiwa/logiwa.constants');
7
+
8
+ const argsWarden = new ArgsWarden([
9
+ ['credsPayload', credsValidator],
10
+ ['warehouseIdentifier_eq'],
11
+ ]);
12
+
13
+ const logiwaReportGetInventoryCalculation = async (
14
+ credsPayload,
15
+ warehouseIdentifier_eq,
16
+ {
17
+ apiVersion,
18
+ page = 0,
19
+ perPage = MAX_PER_PAGE,
20
+ } = {},
21
+ ) => {
22
+
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ warehouseIdentifier_eq,
26
+ });
27
+ if (rejectResponse) {
28
+ return rejectResponse;
29
+ }
30
+
31
+ const params = {
32
+ 'WarehouseIdentifier.eq': warehouseIdentifier_eq,
33
+ };
34
+
35
+ return logiwaClient.fetch({
36
+ method: 'get',
37
+ url: `/Report/InventoryCalculation/i/${ page }/s/${ perPage }`,
38
+ params,
39
+ context: {
40
+ credsPayload,
41
+ apiVersion,
42
+ },
43
+ });
44
+ };
45
+
46
+ const funcApiConfig = {
47
+ argsWarden,
48
+ };
49
+
50
+ module.exports = {
51
+ logiwaReportGetInventoryCalculation,
52
+ funcApiConfig,
53
+ };
54
+
55
+ /*
56
+ curl -X POST "http://localhost:8000/logiwaReportGetInventoryCalculation" \
57
+ -H "Content-Type: application/json" \
58
+ -d '{
59
+ "credsPayload": { "credsPath": "logiwa" },
60
+ "warehouseIdentifier_eq": "cfbdf154-3052-4e18-84f3-b93b7cde2875"
61
+ }'
62
+ */
@@ -0,0 +1,66 @@
1
+ // https://myapi.logiwa.com/swagger/index.html#/Report/get_v3_1_Report_InventorySnapshot_i__index__s__size_
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { logiwaClient } = require('../logiwa/logiwa.utils');
6
+ const { MAX_PER_PAGE } = require('../logiwa/logiwa.constants');
7
+
8
+ const argsWarden = new ArgsWarden([
9
+ ['credsPayload', credsValidator],
10
+ ]);
11
+
12
+ const logiwaReportGetInventorySnapshot = async (
13
+ credsPayload,
14
+ {
15
+ apiVersion,
16
+ page = 0,
17
+ perPage = MAX_PER_PAGE,
18
+ warehouseIdentifier_eq,
19
+ clientIdentifier_eq,
20
+ locationIdentifier_eq,
21
+ sku_eq,
22
+ snapshotDate_bt,
23
+ } = {},
24
+ ) => {
25
+
26
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
27
+ if (rejectResponse) {
28
+ return rejectResponse;
29
+ }
30
+
31
+ const params = {
32
+ ...(warehouseIdentifier_eq && { 'WarehouseIdentifier.eq': warehouseIdentifier_eq }),
33
+ ...(clientIdentifier_eq && { 'ClientIdentifier.eq': clientIdentifier_eq }),
34
+ ...(locationIdentifier_eq && { 'LocationIdentifier.eq': locationIdentifier_eq }),
35
+ ...(sku_eq && { 'Sku.eq': sku_eq }),
36
+ ...(snapshotDate_bt && { 'SnapshotDate.bt': snapshotDate_bt }),
37
+ };
38
+
39
+ return logiwaClient.fetch({
40
+ method: 'get',
41
+ url: `/Report/InventorySnapshot/i/${ page }/s/${ perPage }`,
42
+ params,
43
+ context: {
44
+ credsPayload,
45
+ apiVersion,
46
+ },
47
+ });
48
+ };
49
+
50
+ const funcApiConfig = {
51
+ argsWarden,
52
+ };
53
+
54
+ module.exports = {
55
+ logiwaReportGetInventorySnapshot,
56
+ funcApiConfig,
57
+ };
58
+
59
+ /*
60
+ curl -X POST "http://localhost:8000/logiwaReportGetInventorySnapshot" \
61
+ -H "Content-Type: application/json" \
62
+ -d '{
63
+ "credsPayload": { "credsPath": "logiwa" },
64
+ "options": { "clientIdentifier_eq": "9f1ea39a-fccc-48af-8986-a35c34fcef8b" }
65
+ }'
66
+ */
@@ -0,0 +1,72 @@
1
+ // https://myapi.logiwa.com/swagger/index.html#/Report/get_v3_1_Report_TotalInventory_i__index__s__size_
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { logiwaClient } = require('../logiwa/logiwa.utils');
6
+ const { MAX_PER_PAGE } = require('../logiwa/logiwa.constants');
7
+
8
+ const argsWarden = new ArgsWarden([
9
+ ['credsPayload', credsValidator],
10
+ ]);
11
+
12
+ const logiwaReportGetTotalInventory = async (
13
+ credsPayload,
14
+ {
15
+ apiVersion,
16
+ page = 0,
17
+ perPage = MAX_PER_PAGE,
18
+ sku_eq,
19
+ clientIdentifier_eq,
20
+ clientIdentifier_in,
21
+ outOfStock_eq,
22
+ warehouseIdentifier_eq,
23
+ warehouseIdentifier_in,
24
+ productTypeName_eq,
25
+ productGroupName_eq,
26
+ } = {},
27
+ ) => {
28
+
29
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
30
+ if (rejectResponse) {
31
+ return rejectResponse;
32
+ }
33
+
34
+ const params = {
35
+ ...(sku_eq && { 'Sku.eq': sku_eq }),
36
+ ...(clientIdentifier_eq && { 'ClientIdentifier.eq': clientIdentifier_eq }),
37
+ ...(clientIdentifier_in && { 'ClientIdentifier.in': clientIdentifier_in }),
38
+ ...(outOfStock_eq !== undefined && { 'OutOfStock.eq': outOfStock_eq }),
39
+ ...(warehouseIdentifier_eq && { 'WarehouseIdentifier.eq': warehouseIdentifier_eq }),
40
+ ...(warehouseIdentifier_in && { 'WarehouseIdentifier.in': warehouseIdentifier_in }),
41
+ ...(productTypeName_eq && { 'ProductTypeName.eq': productTypeName_eq }),
42
+ ...(productGroupName_eq && { 'ProductGroupName.eq': productGroupName_eq }),
43
+ };
44
+
45
+ return logiwaClient.fetch({
46
+ method: 'get',
47
+ url: `/Report/TotalInventory/i/${ page }/s/${ perPage }`,
48
+ params,
49
+ context: {
50
+ credsPayload,
51
+ apiVersion,
52
+ },
53
+ });
54
+ };
55
+
56
+ const funcApiConfig = {
57
+ argsWarden,
58
+ };
59
+
60
+ module.exports = {
61
+ logiwaReportGetTotalInventory,
62
+ funcApiConfig,
63
+ };
64
+
65
+ /*
66
+ curl -X POST "http://localhost:8000/logiwaReportGetTotalInventory" \
67
+ -H "Content-Type: application/json" \
68
+ -d '{
69
+ "credsPayload": { "credsPath": "logiwa" },
70
+ "options": { "outOfStock_eq": true }
71
+ }'
72
+ */
@@ -0,0 +1,54 @@
1
+ // https://myapi.logiwa.com/swagger/index.html#/Webhook/get_v3_1_Webhook_status__identifier_
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { logiwaClient } = require('../logiwa/logiwa.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['subscriptionId'],
10
+ ]);
11
+
12
+ const logiwaWebhookStatusGet = async (
13
+ credsPayload,
14
+ subscriptionId,
15
+ {
16
+ apiVersion,
17
+ } = {},
18
+ ) => {
19
+
20
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
21
+ credsPayload,
22
+ subscriptionId,
23
+ });
24
+ if (rejectResponse) {
25
+ return rejectResponse;
26
+ }
27
+
28
+ return logiwaClient.fetch({
29
+ method: 'get',
30
+ url: `/Webhook/status/${ subscriptionId }`,
31
+ context: {
32
+ credsPayload,
33
+ apiVersion,
34
+ },
35
+ });
36
+ };
37
+
38
+ const funcApiConfig = {
39
+ argsWarden,
40
+ };
41
+
42
+ module.exports = {
43
+ logiwaWebhookStatusGet,
44
+ funcApiConfig,
45
+ };
46
+
47
+ /*
48
+ curl -X POST "http://localhost:8000/logiwaWebhookStatusGet" \
49
+ -H "Content-Type: application/json" \
50
+ -d '{
51
+ "credsPayload": { "credsPath": "logiwa" },
52
+ "subscriptionId": "68706c98-0198-4671-9a97-4b3e3e59a56d"
53
+ }'
54
+ */
@@ -0,0 +1,64 @@
1
+ // https://myapi.logiwa.com/swagger/index.html#/Webhook/post_v3_1_Webhook_create
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { logiwaClient } = require('../logiwa/logiwa.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['topic'],
10
+ ['url'],
11
+ ]);
12
+
13
+ const logiwaWebhookSubscribe = async (
14
+ credsPayload,
15
+ topic,
16
+ url,
17
+ {
18
+ apiVersion,
19
+ clientIdentifier,
20
+ } = {},
21
+ ) => {
22
+
23
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
24
+ credsPayload,
25
+ topic,
26
+ url,
27
+ });
28
+ if (rejectResponse) {
29
+ return rejectResponse;
30
+ }
31
+
32
+ return logiwaClient.fetch({
33
+ method: 'post',
34
+ url: '/Webhook/create',
35
+ body: {
36
+ topic,
37
+ address: url,
38
+ ...(clientIdentifier ? { clientIdentifier } : { ignoreClient: true }),
39
+ },
40
+ context: {
41
+ credsPayload,
42
+ apiVersion,
43
+ },
44
+ });
45
+ };
46
+
47
+ const funcApiConfig = {
48
+ argsWarden,
49
+ };
50
+
51
+ module.exports = {
52
+ logiwaWebhookSubscribe,
53
+ funcApiConfig,
54
+ };
55
+
56
+ /*
57
+ curl -X POST "http://localhost:8000/logiwaWebhookSubscribe" \
58
+ -H "Content-Type: application/json" \
59
+ -d '{
60
+ "credsPayload": { "credsPath": "logiwa" },
61
+ "topic": "wms/inventory/available",
62
+ "url": "https://example.com/webhook"
63
+ }'
64
+ */
@@ -0,0 +1,54 @@
1
+ // https://myapi.logiwa.com/swagger/index.html#/Webhook/delete_v3_1_Webhook_unsubscribe__subscriptionIdentifier_
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { logiwaClient } = require('../logiwa/logiwa.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ['subscriptionId'],
10
+ ]);
11
+
12
+ const logiwaWebhookUnsubscribe = async (
13
+ credsPayload,
14
+ subscriptionId,
15
+ {
16
+ apiVersion,
17
+ } = {},
18
+ ) => {
19
+
20
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
21
+ credsPayload,
22
+ subscriptionId,
23
+ });
24
+ if (rejectResponse) {
25
+ return rejectResponse;
26
+ }
27
+
28
+ return logiwaClient.fetch({
29
+ method: 'delete',
30
+ url: `/Webhook/unsubscribe/${ subscriptionId }`,
31
+ context: {
32
+ credsPayload,
33
+ apiVersion,
34
+ },
35
+ });
36
+ };
37
+
38
+ const funcApiConfig = {
39
+ argsWarden,
40
+ };
41
+
42
+ module.exports = {
43
+ logiwaWebhookUnsubscribe,
44
+ funcApiConfig,
45
+ };
46
+
47
+ /*
48
+ curl -X POST "http://localhost:8000/logiwaWebhookUnsubscribe" \
49
+ -H "Content-Type: application/json" \
50
+ -d '{
51
+ "credsPayload": { "credsPath": "logiwa" },
52
+ "subscriptionId": "68706c98-0198-4671-9a97-4b3e3e59a56d"
53
+ }'
54
+ */
@@ -0,0 +1,48 @@
1
+ // https://myapi.logiwa.com/swagger/index.html#/Webhook/get_v3_1_Webhook_list
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { logiwaClient } = require('../logiwa/logiwa.utils');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ]);
10
+
11
+ const logiwaWebhooksGet = async (
12
+ credsPayload,
13
+ {
14
+ apiVersion,
15
+ } = {},
16
+ ) => {
17
+
18
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
19
+ if (rejectResponse) {
20
+ return rejectResponse;
21
+ }
22
+
23
+ return logiwaClient.fetch({
24
+ method: 'get',
25
+ url: '/Webhook/list',
26
+ context: {
27
+ credsPayload,
28
+ apiVersion,
29
+ },
30
+ });
31
+ };
32
+
33
+ const funcApiConfig = {
34
+ argsWarden,
35
+ };
36
+
37
+ module.exports = {
38
+ logiwaWebhooksGet,
39
+ funcApiConfig,
40
+ };
41
+
42
+ /*
43
+ curl -X POST "http://localhost:8000/logiwaWebhooksGet" \
44
+ -H "Content-Type: application/json" \
45
+ -d '{
46
+ "credsPayload": { "credsPath": "logiwa" }
47
+ }'
48
+ */
@@ -0,0 +1,46 @@
1
+ // https://shopify.dev/docs/api/admin-graphql/latest/queries/things
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { shopifyGet } = require('./shopifyGet');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ]);
10
+
11
+ const shopifyThingsGet = async (
12
+ credsPayload,
13
+ {
14
+ ...getterOptions // e.g. limit
15
+ } = {},
16
+ ) => {
17
+
18
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
19
+ credsPayload,
20
+ });
21
+ if (rejectResponse) {
22
+ return rejectResponse;
23
+ }
24
+
25
+ return await shopifyGet(credsPayload, 'thing', { ...getterOptions });
26
+ };
27
+
28
+ const funcApiConfig = {
29
+ argsWarden,
30
+ };
31
+
32
+ module.exports = {
33
+ shopifyThingsGet,
34
+ funcApiConfig,
35
+ };
36
+
37
+ /*
38
+ curl -X POST "http://localhost:8000/shopifyThingsGet" \
39
+ -H "Content-Type: application/json" \
40
+ -d '{
41
+ "credsPayload": { "credsPath": "shopify.au" },
42
+ "options": {
43
+ "limit": 10
44
+ }
45
+ }'
46
+ */
@@ -0,0 +1,46 @@
1
+ // https://shopify.dev/docs/api/admin-graphql/latest/queries/abandonedCheckouts
2
+
3
+ const { ArgsWarden } = require('../utils');
4
+ const { credsValidator } = require('../validators');
5
+ const { shopifyGet } = require('./shopifyGet');
6
+
7
+ const argsWarden = new ArgsWarden([
8
+ ['credsPayload', credsValidator],
9
+ ]);
10
+
11
+ const shopifyAbandonedCheckoutsGet = async (
12
+ credsPayload,
13
+ {
14
+ ...getterOptions // e.g. limit
15
+ } = {},
16
+ ) => {
17
+
18
+ const rejectResponse = await argsWarden.responseIfRejectingArgs({
19
+ credsPayload,
20
+ });
21
+ if (rejectResponse) {
22
+ return rejectResponse;
23
+ }
24
+
25
+ return await shopifyGet(credsPayload, 'abandonedCheckout', { ...getterOptions });
26
+ };
27
+
28
+ const funcApiConfig = {
29
+ argsWarden,
30
+ };
31
+
32
+ module.exports = {
33
+ shopifyAbandonedCheckoutsGet,
34
+ funcApiConfig,
35
+ };
36
+
37
+ /*
38
+ curl -X POST "http://localhost:8000/shopifyAbandonedCheckoutsGet" \
39
+ -H "Content-Type: application/json" \
40
+ -d '{
41
+ "credsPayload": { "credsPath": "shopify.au" },
42
+ "options": {
43
+ "limit": 10
44
+ }
45
+ }'
46
+ */