@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.
- package/.creds.yml.sample +5 -0
- package/README.md +1 -1
- package/_build_scripts/publish.js +85 -0
- package/api/logiwa/logiwa.constants.js +8 -0
- package/api/logiwa/logiwa.utils.js +53 -0
- package/api/logiwa/logiwaAuthGet.js +86 -0
- package/api/logiwa/logiwaInventoriesGet.js +67 -0
- package/api/logiwa/logiwaOrderGet.js +54 -0
- package/api/logiwa/logiwaOrdersGet.js +92 -0
- package/api/logiwa/logiwaProductGet.js +54 -0
- package/api/logiwa/logiwaProductsGet.js +80 -0
- package/api/logiwa/logiwaReportGetAvailableToPromise.js +179 -0
- package/api/logiwa/logiwaReportGetInventoryCalculation.js +62 -0
- package/api/logiwa/logiwaReportGetInventorySnapshot.js +66 -0
- package/api/logiwa/logiwaReportGetTotalInventory.js +72 -0
- package/api/logiwa/logiwaWebhookStatusGet.js +54 -0
- package/api/logiwa/logiwaWebhookSubscribe.js +64 -0
- package/api/logiwa/logiwaWebhookUnsubscribe.js +54 -0
- package/api/logiwa/logiwaWebhooksGet.js +48 -0
- package/api/shopify/_example.get.js +46 -0
- package/api/shopify/shopifyAbandonedCheckoutsGet.js +46 -0
- package/api/shopify/shopifyArticlesGet.js +46 -0
- package/api/shopify/shopifyBlogsGet.js +46 -0
- package/api/shopify/shopifyBulkOperationsGet.js +46 -0
- package/api/shopify/shopifyCatalogsGet.js +46 -0
- package/api/shopify/shopifyChannelsGet.js +46 -0
- package/api/shopify/shopifyCheckoutAndAccountsConfigurationsGet.js +46 -0
- package/api/shopify/shopifyCollectionsGet.js +46 -0
- package/api/shopify/shopifyCustomersGet.js +2 -0
- package/api/shopify/shopifyDeliveryCustomizationsGet.js +46 -0
- package/api/shopify/shopifyDeliveryProfilesGet.js +46 -0
- package/api/shopify/shopifyDiscountNodesGet.js +46 -0
- package/api/shopify/shopifyDisputesGet.js +46 -0
- package/api/shopify/shopifyDraftOrdersGet.js +46 -0
- package/api/shopify/shopifyEventsGet.js +46 -0
- package/api/shopify/shopifyFilesGet.js +46 -0
- package/api/shopify/shopifyFulfillmentOrdersGet.js +46 -0
- package/api/shopify/shopifyGiftCardsGet.js +46 -0
- package/api/shopify/shopifyInventoryItemsGet.js +46 -0
- package/api/shopify/shopifyLocationsGet.js +46 -0
- package/api/shopify/shopifyMarketingEventsGet.js +46 -0
- package/api/shopify/shopifyMarketsGet.js +46 -0
- package/api/shopify/shopifyMenusGet.js +46 -0
- package/api/shopify/shopifyMetafieldDefinitionsGet.js +50 -0
- package/api/shopify/shopifyMetaobjectDefinitionsGet.js +46 -0
- package/api/shopify/shopifyMetaobjectsGet.js +50 -0
- package/api/shopify/shopifyPagesGet.js +46 -0
- package/api/shopify/shopifyPaymentCustomizationsGet.js +46 -0
- package/api/shopify/shopifyProductFeedsGet.js +46 -0
- package/api/shopify/shopifyProductVariantsGet.js +46 -0
- package/api/shopify/shopifyProductsGet.js +46 -0
- package/api/shopify/shopifyPublicationsGet.js +46 -0
- package/api/shopify/shopifySegmentsGet.js +46 -0
- package/api/shopify/shopifyUrlRedirectsGet.js +46 -0
- package/api/shopify/shopifyWebhookSubscriptionsGet.js +46 -0
- package/api/utils.js +4 -3
- package/api/workspace.js +43 -0
- package/package.json +5 -3
- package/server.js +205 -105
package/.creds.yml.sample
CHANGED
|
@@ -8,6 +8,11 @@ peoplevox:
|
|
|
8
8
|
USERNAME: ______________________________
|
|
9
9
|
PASSWORD: ______________________________
|
|
10
10
|
|
|
11
|
+
logiwa:
|
|
12
|
+
BASE_URL: https://myapi.logiwa.com
|
|
13
|
+
EMAIL: _________________________________
|
|
14
|
+
PASSWORD: ______________________________
|
|
15
|
+
|
|
11
16
|
youtube:
|
|
12
17
|
API_KEY: _______________________________
|
|
13
18
|
|
package/README.md
CHANGED
|
@@ -49,4 +49,4 @@ The [bedrock](https://github.com/GorgonFreeman/bedrock) middleware, refactored f
|
|
|
49
49
|
}
|
|
50
50
|
```
|
|
51
51
|
- **Monorepo structure**
|
|
52
|
-
Mineral gets pushed to from a larger repo that can also contain private functions. Mineral should be strictly useful stuff for the public, and can be used standalone, but needs to be instantiated for serving, setting stuff like which creds file to use. This allows it to be used as part of another repo in the same HTTP/curl way as by itself.
|
|
52
|
+
Mineral gets pushed to from a larger repo that can also contain private functions. Mineral should be strictly useful stuff for the public, and can be used standalone, but needs to be instantiated for serving, setting stuff like which creds file to use. This allows it to be used as part of another repo in the same HTTP/curl way as by itself. Pass `--workspace` to locate `.creds.yml` and `--api_dirs` to serve additional function directories.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const readline = require('readline');
|
|
4
|
+
const { execSync } = require('child_process');
|
|
5
|
+
|
|
6
|
+
const mineralRoot = path.join(__dirname, '..');
|
|
7
|
+
const packageJsonPath = path.join(mineralRoot, 'package.json');
|
|
8
|
+
|
|
9
|
+
const readPackageJson = () => JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
10
|
+
|
|
11
|
+
const writePackageJson = (packageJson) => {
|
|
12
|
+
fs.writeFileSync(packageJsonPath, `${ JSON.stringify(packageJson, null, 2) }\n`);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const bumpPatch = (version) => {
|
|
16
|
+
const [major, minor, patch] = version.split('.').map((part) => Number(part) || 0);
|
|
17
|
+
return [major, minor, patch + 1].join('.');
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const getPublishedVersion = () => {
|
|
21
|
+
try {
|
|
22
|
+
return execSync('npm view @foxtware/mineral version', {
|
|
23
|
+
cwd: mineralRoot,
|
|
24
|
+
encoding: 'utf8',
|
|
25
|
+
}).trim();
|
|
26
|
+
} catch {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const ensureLoggedIn = () => {
|
|
32
|
+
try {
|
|
33
|
+
execSync('npm whoami', {
|
|
34
|
+
cwd: mineralRoot,
|
|
35
|
+
encoding: 'utf8',
|
|
36
|
+
stdio: 'pipe',
|
|
37
|
+
});
|
|
38
|
+
} catch {
|
|
39
|
+
throw new Error('Not logged in to npm. Run `npm login` with an account that can publish @foxtware/mineral.');
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const askWithDefault = async (question, defaultAnswer) => {
|
|
44
|
+
const rl = readline.createInterface({
|
|
45
|
+
input: process.stdin,
|
|
46
|
+
output: process.stdout,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const answer = await new Promise((resolve) => {
|
|
50
|
+
rl.question(`${ question } [${ defaultAnswer }] `, resolve);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
rl.close();
|
|
54
|
+
return answer.trim() || defaultAnswer;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const publish = async () => {
|
|
58
|
+
ensureLoggedIn();
|
|
59
|
+
|
|
60
|
+
const packageJson = readPackageJson();
|
|
61
|
+
const localVersion = packageJson.version;
|
|
62
|
+
const publishedVersion = getPublishedVersion();
|
|
63
|
+
|
|
64
|
+
let version = localVersion;
|
|
65
|
+
|
|
66
|
+
if (localVersion === publishedVersion) {
|
|
67
|
+
const suggestedVersion = bumpPatch(localVersion);
|
|
68
|
+
version = await askWithDefault('What version should we use?', suggestedVersion);
|
|
69
|
+
|
|
70
|
+
packageJson.version = version;
|
|
71
|
+
writePackageJson(packageJson);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
execSync('npm publish', {
|
|
75
|
+
cwd: mineralRoot,
|
|
76
|
+
stdio: 'inherit',
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
console.log(`Published @foxtware/mineral@${ version }`);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
publish().catch((error) => {
|
|
83
|
+
console.error(error);
|
|
84
|
+
process.exit(1);
|
|
85
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const { DEFAULT_API_VERSION } = require('../logiwa/logiwa.constants');
|
|
2
|
+
const { logiwaAuthGet } = require('../logiwa/logiwaAuthGet');
|
|
3
|
+
const {
|
|
4
|
+
FetchClient,
|
|
5
|
+
Chain,
|
|
6
|
+
appendUrlToBase,
|
|
7
|
+
credsFromPayload,
|
|
8
|
+
fetchClientCommonSteps,
|
|
9
|
+
} = require('../utils');
|
|
10
|
+
|
|
11
|
+
const addUrlAndAuthHeaders = async (state) => {
|
|
12
|
+
const { requestPayload, context } = state;
|
|
13
|
+
const { credsPayload, apiVersion = DEFAULT_API_VERSION } = context;
|
|
14
|
+
|
|
15
|
+
const creds = context.creds ?? await credsFromPayload(credsPayload);
|
|
16
|
+
const authResponse = await logiwaAuthGet(credsPayload);
|
|
17
|
+
const { data } = authResponse;
|
|
18
|
+
const { token } = data;
|
|
19
|
+
|
|
20
|
+
// TODO: Handle failed auth
|
|
21
|
+
|
|
22
|
+
const { BASE_URL } = creds;
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
context: {
|
|
26
|
+
creds,
|
|
27
|
+
},
|
|
28
|
+
requestPayload: {
|
|
29
|
+
url: appendUrlToBase(`${ BASE_URL }/${ apiVersion }`, requestPayload.url),
|
|
30
|
+
headers: {
|
|
31
|
+
Authorization: `Bearer ${ token }`,
|
|
32
|
+
...requestPayload.headers,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const logiwaClientRequestPreparer = new Chain([
|
|
39
|
+
addUrlAndAuthHeaders,
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
const logiwaClientResponseInterpreter = new Chain([
|
|
43
|
+
fetchClientCommonSteps.exitEarlyOnNotOk,
|
|
44
|
+
]);
|
|
45
|
+
|
|
46
|
+
const logiwaClient = new FetchClient({
|
|
47
|
+
requestPreparer: logiwaClientRequestPreparer,
|
|
48
|
+
responseInterpreter: logiwaClientResponseInterpreter,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
module.exports = {
|
|
52
|
+
logiwaClient,
|
|
53
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// https://myapi.logiwa.com/swagger/index.html
|
|
2
|
+
|
|
3
|
+
const { credsFromPayload, customFetch, appendUrlToBase, ArgsWarden } = require('../utils');
|
|
4
|
+
const { credsValidator } = require('../validators');
|
|
5
|
+
const { DEFAULT_API_VERSION } = require('./logiwa.constants');
|
|
6
|
+
|
|
7
|
+
const argsWarden = new ArgsWarden([
|
|
8
|
+
['credsPayload', credsValidator],
|
|
9
|
+
]);
|
|
10
|
+
|
|
11
|
+
const logiwaAuthGet = async (
|
|
12
|
+
credsPayload,
|
|
13
|
+
{
|
|
14
|
+
apiVersion = DEFAULT_API_VERSION,
|
|
15
|
+
} = {},
|
|
16
|
+
) => {
|
|
17
|
+
|
|
18
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
19
|
+
if (rejectResponse) {
|
|
20
|
+
return rejectResponse;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const creds = await credsFromPayload(credsPayload);
|
|
24
|
+
const {
|
|
25
|
+
BASE_URL,
|
|
26
|
+
EMAIL,
|
|
27
|
+
PASSWORD,
|
|
28
|
+
} = creds;
|
|
29
|
+
|
|
30
|
+
if (!EMAIL || !PASSWORD) {
|
|
31
|
+
return {
|
|
32
|
+
ok: false,
|
|
33
|
+
error: {
|
|
34
|
+
code: 'INVALID_CREDS',
|
|
35
|
+
message: 'EMAIL and PASSWORD are required.',
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const url = appendUrlToBase(BASE_URL, `/${ apiVersion }/Authorize/token`);
|
|
41
|
+
|
|
42
|
+
const response = await customFetch(
|
|
43
|
+
url,
|
|
44
|
+
{
|
|
45
|
+
method: 'post',
|
|
46
|
+
body: {
|
|
47
|
+
email: EMAIL,
|
|
48
|
+
password: PASSWORD,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
return response;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!response.data?.token) {
|
|
58
|
+
return {
|
|
59
|
+
ok: false,
|
|
60
|
+
error: {
|
|
61
|
+
code: 'AUTH_FAILED',
|
|
62
|
+
message: 'Logiwa did not return a token.',
|
|
63
|
+
details: response.data,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return response;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const funcApiConfig = {
|
|
72
|
+
argsWarden,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
module.exports = {
|
|
76
|
+
logiwaAuthGet,
|
|
77
|
+
funcApiConfig,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/*
|
|
81
|
+
curl -X POST "http://localhost:8000/logiwaAuthGet" \
|
|
82
|
+
-H "Content-Type: application/json" \
|
|
83
|
+
-d '{
|
|
84
|
+
"credsPayload": { "credsPath": "logiwa" }
|
|
85
|
+
}'
|
|
86
|
+
*/
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// https://myapi.logiwa.com/swagger/index.html#/Inventory/get_v3_1_Inventory_list_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 logiwaInventoriesGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
{
|
|
15
|
+
apiVersion,
|
|
16
|
+
page = 0,
|
|
17
|
+
perPage = MAX_PER_PAGE,
|
|
18
|
+
sku_eq,
|
|
19
|
+
clientIdentifier_eq,
|
|
20
|
+
warehouseIdentifier_eq,
|
|
21
|
+
inventoryStatusId_eq,
|
|
22
|
+
location_eq,
|
|
23
|
+
useSnapshotData_eq,
|
|
24
|
+
} = {},
|
|
25
|
+
) => {
|
|
26
|
+
|
|
27
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
28
|
+
if (rejectResponse) {
|
|
29
|
+
return rejectResponse;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const params = {
|
|
33
|
+
...(sku_eq && { 'Sku.eq': sku_eq }),
|
|
34
|
+
...(clientIdentifier_eq && { 'ClientIdentifier.eq': clientIdentifier_eq }),
|
|
35
|
+
...(warehouseIdentifier_eq && { 'WarehouseIdentifier.eq': warehouseIdentifier_eq }),
|
|
36
|
+
...(inventoryStatusId_eq && { 'InventoryStatusId.eq': inventoryStatusId_eq }),
|
|
37
|
+
...(location_eq && { 'Location.eq': location_eq }),
|
|
38
|
+
...(useSnapshotData_eq && { 'UseSnapshotData.eq': useSnapshotData_eq }),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return logiwaClient.fetch({
|
|
42
|
+
method: 'get',
|
|
43
|
+
url: `/Inventory/list/i/${ page }/s/${ perPage }`,
|
|
44
|
+
params,
|
|
45
|
+
context: {
|
|
46
|
+
credsPayload,
|
|
47
|
+
apiVersion,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const funcApiConfig = {
|
|
53
|
+
argsWarden,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
module.exports = {
|
|
57
|
+
logiwaInventoriesGet,
|
|
58
|
+
funcApiConfig,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/*
|
|
62
|
+
curl -X POST "http://localhost:8000/logiwaInventoriesGet" \
|
|
63
|
+
-H "Content-Type: application/json" \
|
|
64
|
+
-d '{
|
|
65
|
+
"credsPayload": { "credsPath": "logiwa" }
|
|
66
|
+
}'
|
|
67
|
+
*/
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// https://myapi.logiwa.com/swagger/index.html#/ShipmentOrder/get_v3_1_ShipmentOrder__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
|
+
['orderId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const logiwaOrderGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
orderId, // Logiwa order UUID
|
|
15
|
+
{
|
|
16
|
+
apiVersion,
|
|
17
|
+
} = {},
|
|
18
|
+
) => {
|
|
19
|
+
|
|
20
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
21
|
+
credsPayload,
|
|
22
|
+
orderId,
|
|
23
|
+
});
|
|
24
|
+
if (rejectResponse) {
|
|
25
|
+
return rejectResponse;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return logiwaClient.fetch({
|
|
29
|
+
method: 'get',
|
|
30
|
+
url: `/ShipmentOrder/${ orderId }`,
|
|
31
|
+
context: {
|
|
32
|
+
credsPayload,
|
|
33
|
+
apiVersion,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const funcApiConfig = {
|
|
39
|
+
argsWarden,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
module.exports = {
|
|
43
|
+
logiwaOrderGet,
|
|
44
|
+
funcApiConfig,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
curl -X POST "http://localhost:8000/logiwaOrderGet" \
|
|
49
|
+
-H "Content-Type: application/json" \
|
|
50
|
+
-d '{
|
|
51
|
+
"credsPayload": { "credsPath": "logiwa" },
|
|
52
|
+
"orderId": "d53b375b-835d-4450-b71b-65e333f6709b"
|
|
53
|
+
}'
|
|
54
|
+
*/
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// https://myapi.logiwa.com/swagger/index.html#/ShipmentOrder/get_v3_1_ShipmentOrder_list_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 logiwaOrdersGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
{
|
|
15
|
+
apiVersion,
|
|
16
|
+
page = 0,
|
|
17
|
+
perPage = MAX_PER_PAGE,
|
|
18
|
+
sku_eq,
|
|
19
|
+
updatedDateTime_bt,
|
|
20
|
+
code_eq,
|
|
21
|
+
warehouseIdentifier_eq,
|
|
22
|
+
warehouseIdentifier_in,
|
|
23
|
+
identifier_eq,
|
|
24
|
+
clientIdentifier_eq,
|
|
25
|
+
clientIdentifier_in,
|
|
26
|
+
createdDateTime_bt,
|
|
27
|
+
actualShipmentDate_bt,
|
|
28
|
+
shipmentOrderDate_bt,
|
|
29
|
+
status_in,
|
|
30
|
+
status_eq,
|
|
31
|
+
expectedShipmentDate_bt,
|
|
32
|
+
shipmentOrderTypeName_eq,
|
|
33
|
+
} = {},
|
|
34
|
+
) => {
|
|
35
|
+
|
|
36
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
37
|
+
if (rejectResponse) {
|
|
38
|
+
return rejectResponse;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const params = {
|
|
42
|
+
...(sku_eq && { 'Sku.eq': sku_eq }),
|
|
43
|
+
...(updatedDateTime_bt && { 'UpdatedDateTime.bt': updatedDateTime_bt }),
|
|
44
|
+
...(code_eq && { 'Code.eq': code_eq }),
|
|
45
|
+
...(warehouseIdentifier_eq && { 'WarehouseIdentifier.eq': warehouseIdentifier_eq }),
|
|
46
|
+
...(warehouseIdentifier_in && { 'WarehouseIdentifier.in': warehouseIdentifier_in }),
|
|
47
|
+
...(identifier_eq && { 'Identifier.eq': identifier_eq }),
|
|
48
|
+
...(clientIdentifier_eq && { 'ClientIdentifier.eq': clientIdentifier_eq }),
|
|
49
|
+
...(clientIdentifier_in && { 'ClientIdentifier.in': clientIdentifier_in }),
|
|
50
|
+
...(createdDateTime_bt && { 'CreatedDateTime.bt': createdDateTime_bt }),
|
|
51
|
+
...(actualShipmentDate_bt && { 'ActualShipmentDate.bt': actualShipmentDate_bt }),
|
|
52
|
+
...(shipmentOrderDate_bt && { 'ShipmentOrderDate.bt': shipmentOrderDate_bt }),
|
|
53
|
+
...(status_in && { 'Status.in': status_in }),
|
|
54
|
+
...(status_eq && { 'Status.eq': status_eq }),
|
|
55
|
+
...(expectedShipmentDate_bt && { 'ExpectedShipmentDate.bt': expectedShipmentDate_bt }),
|
|
56
|
+
...(shipmentOrderTypeName_eq && { 'ShipmentOrderTypeName.eq': shipmentOrderTypeName_eq }),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return logiwaClient.fetch({
|
|
60
|
+
method: 'get',
|
|
61
|
+
url: `/ShipmentOrder/list/i/${ page }/s/${ perPage }`,
|
|
62
|
+
params,
|
|
63
|
+
context: {
|
|
64
|
+
credsPayload,
|
|
65
|
+
apiVersion,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const funcApiConfig = {
|
|
71
|
+
argsWarden,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
module.exports = {
|
|
75
|
+
logiwaOrdersGet,
|
|
76
|
+
funcApiConfig,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/*
|
|
80
|
+
curl -X POST "http://localhost:8000/logiwaOrdersGet" \
|
|
81
|
+
-H "Content-Type: application/json" \
|
|
82
|
+
-d '{
|
|
83
|
+
"credsPayload": { "credsPath": "logiwa" }
|
|
84
|
+
}'
|
|
85
|
+
|
|
86
|
+
curl -X POST "http://localhost:8000/logiwaOrdersGet" \
|
|
87
|
+
-H "Content-Type: application/json" \
|
|
88
|
+
-d '{
|
|
89
|
+
"credsPayload": { "credsPath": "logiwa" },
|
|
90
|
+
"options": { "code_eq": "#USA5674542" }
|
|
91
|
+
}'
|
|
92
|
+
*/
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// https://myapi.logiwa.com/swagger/index.html#/Product/get_v3_1_Product_detail__id_
|
|
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
|
+
['productId'],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const logiwaProductGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
productId,
|
|
15
|
+
{
|
|
16
|
+
apiVersion,
|
|
17
|
+
} = {},
|
|
18
|
+
) => {
|
|
19
|
+
|
|
20
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({
|
|
21
|
+
credsPayload,
|
|
22
|
+
productId,
|
|
23
|
+
});
|
|
24
|
+
if (rejectResponse) {
|
|
25
|
+
return rejectResponse;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return logiwaClient.fetch({
|
|
29
|
+
method: 'get',
|
|
30
|
+
url: `/Product/detail/${ productId }`,
|
|
31
|
+
context: {
|
|
32
|
+
credsPayload,
|
|
33
|
+
apiVersion,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const funcApiConfig = {
|
|
39
|
+
argsWarden,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
module.exports = {
|
|
43
|
+
logiwaProductGet,
|
|
44
|
+
funcApiConfig,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/*
|
|
48
|
+
curl -X POST "http://localhost:8000/logiwaProductGet" \
|
|
49
|
+
-H "Content-Type: application/json" \
|
|
50
|
+
-d '{
|
|
51
|
+
"credsPayload": { "credsPath": "logiwa" },
|
|
52
|
+
"productId": "261a02aa-ce5a-4b06-a528-d419e0aa87a1"
|
|
53
|
+
}'
|
|
54
|
+
*/
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// https://myapi.logiwa.com/swagger/index.html#/Product/get_v3_1_Product_list_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 logiwaProductsGet = async (
|
|
13
|
+
credsPayload,
|
|
14
|
+
{
|
|
15
|
+
apiVersion,
|
|
16
|
+
page = 0,
|
|
17
|
+
perPage = MAX_PER_PAGE,
|
|
18
|
+
sku_eq,
|
|
19
|
+
fnsku_eq,
|
|
20
|
+
clientIdentifier_eq,
|
|
21
|
+
clientIdentifier_in,
|
|
22
|
+
identifier_eq,
|
|
23
|
+
createdDateTime_bt,
|
|
24
|
+
updatedDateTime_bt,
|
|
25
|
+
productTypeName_eq,
|
|
26
|
+
productGroupName_eq,
|
|
27
|
+
} = {},
|
|
28
|
+
) => {
|
|
29
|
+
|
|
30
|
+
const rejectResponse = await argsWarden.responseIfRejectingArgs({ credsPayload });
|
|
31
|
+
if (rejectResponse) {
|
|
32
|
+
return rejectResponse;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const params = {
|
|
36
|
+
...(sku_eq && { 'Sku.eq': sku_eq }),
|
|
37
|
+
...(fnsku_eq && { 'FNSKU.eq': fnsku_eq }),
|
|
38
|
+
...(clientIdentifier_eq && { 'ClientIdentifier.eq': clientIdentifier_eq }),
|
|
39
|
+
...(clientIdentifier_in && { 'ClientIdentifier.in': clientIdentifier_in }),
|
|
40
|
+
...(identifier_eq && { 'Identifier.eq': identifier_eq }),
|
|
41
|
+
...(createdDateTime_bt && { 'CreatedDateTime.bt': createdDateTime_bt }),
|
|
42
|
+
...(updatedDateTime_bt && { 'UpdatedDateTime.bt': updatedDateTime_bt }),
|
|
43
|
+
...(productTypeName_eq && { 'ProductTypeName.eq': productTypeName_eq }),
|
|
44
|
+
...(productGroupName_eq && { 'ProductGroupName.eq': productGroupName_eq }),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return logiwaClient.fetch({
|
|
48
|
+
method: 'get',
|
|
49
|
+
url: `/Product/list/i/${ page }/s/${ perPage }`,
|
|
50
|
+
params,
|
|
51
|
+
context: {
|
|
52
|
+
credsPayload,
|
|
53
|
+
apiVersion,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const funcApiConfig = {
|
|
59
|
+
argsWarden,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
module.exports = {
|
|
63
|
+
logiwaProductsGet,
|
|
64
|
+
funcApiConfig,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/*
|
|
68
|
+
curl -X POST "http://localhost:8000/logiwaProductsGet" \
|
|
69
|
+
-H "Content-Type: application/json" \
|
|
70
|
+
-d '{
|
|
71
|
+
"credsPayload": { "credsPath": "logiwa" }
|
|
72
|
+
}'
|
|
73
|
+
|
|
74
|
+
curl -X POST "http://localhost:8000/logiwaProductsGet" \
|
|
75
|
+
-H "Content-Type: application/json" \
|
|
76
|
+
-d '{
|
|
77
|
+
"credsPayload": { "credsPath": "logiwa" },
|
|
78
|
+
"options": { "sku_eq": "EXD1684-2-L" }
|
|
79
|
+
}'
|
|
80
|
+
*/
|