Skip to content

Commit 6c51dd2

Browse files
committed
feat(orderdesk): skip updating inventory by default
1 parent 45c5903 commit 6c51dd2

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

src/functions/datastore-integration-orderdesk/DataStore.js

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ class DataStore extends DataStoreBase {
2727
this.domain = "app.orderdesk.me";
2828
this.api = "api/v2/";
2929
this.setCredentials();
30+
this.setDefaultConfig();
31+
}
32+
33+
/**
34+
* @inheritdoc
35+
*/
36+
setCredentials() {
37+
const credentials = this.parseConfigCredentials(config);
38+
if (!credentials.key || !credentials.id) {
39+
throw new Error("Environment variables for OrderDesk store id and/or API key are missing.");
40+
}
41+
this.credentials = credentials;
42+
}
43+
44+
/**
45+
* If no value is set for the skip update inventory option, skip all inventories.
46+
*/
47+
setDefaultConfig() {
48+
if (!config.datastore.skipUpdate.inventory) {
49+
this.skipUpdate.inventory.all = true;
50+
}
3051
}
3152

3253
/**:
@@ -42,17 +63,6 @@ class DataStore extends DataStoreBase {
4263
}
4364
}
4465

45-
/**
46-
* @inheritdoc
47-
*/
48-
setCredentials() {
49-
const credentials = this.parseConfigCredentials(config);
50-
if (!credentials.key || !credentials.id) {
51-
throw new Error("Environment variables for OrderDesk store id and/or API key are missing.");
52-
}
53-
this.credentials = credentials;
54-
}
55-
5666
parseConfigCredentials(config) {
5767
const rawCredentials = config.datastore.credentials;
5868
let matched;

test/functions/datastore-integration-orderdesk/DataStore.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ describe("OrderDesk Datastore", function() {
8383
describe("Update OrderDesk items", function() {
8484

8585
describe("Does not update to invalid states", function () {
86+
config.datastore.skipUpdate.inventory = '__NONE__';
8687
const odClient = new DataStore();
8788
const fullItem = orderDeskFullItem();
8889
for (let k of Object.keys(fullItem)) {
@@ -95,6 +96,7 @@ describe("OrderDesk Datastore", function() {
9596
});
9697

9798
describe("Sends an appropriate PUT request", async function () {
99+
config.datastore.skipUpdate.inventory = '__NONE__';
98100
const odClient = new DataStore();
99101
const fullItem = orderDeskFullItem();
100102
const prevfetch = DataStore.__get__('fetch');

0 commit comments

Comments
 (0)