merchi_sdk_js 0.4.11 → 0.5.0
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/package.json +1 -1
- package/src/domain.js +153 -0
- package/src/draft_template.js +3 -0
- package/src/merchi.js +3 -0
- package/src/product.js +3 -0
- package/src/shipment.js +2 -0
- package/src/shipment_log.js +74 -0
package/package.json
CHANGED
package/src/domain.js
CHANGED
|
@@ -253,6 +253,159 @@ export function Domain() {
|
|
|
253
253
|
this.isUnrestricted = function () {
|
|
254
254
|
return this.domainType() === domainTypesInts.get('Unrestricted');
|
|
255
255
|
}
|
|
256
|
+
|
|
257
|
+
function parsePayloadAndCallbacks(payload, success, error) {
|
|
258
|
+
if (typeof payload === 'function') {
|
|
259
|
+
return {payload: {}, success: payload, error: success};
|
|
260
|
+
}
|
|
261
|
+
return {payload: payload || {}, success: success, error: error};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function appendPayload(request, payload) {
|
|
265
|
+
Object.keys(payload).forEach(function(key) {
|
|
266
|
+
var value = payload[key];
|
|
267
|
+
if (value === undefined) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (value !== null && typeof value === 'object') {
|
|
271
|
+
request.data().add(key, JSON.stringify(value));
|
|
272
|
+
} else {
|
|
273
|
+
request.data().add(key, value);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function sendStorefrontRequest(resource, method, payload, success, error) {
|
|
279
|
+
var request = new Request();
|
|
280
|
+
request.resource(resource).method(method);
|
|
281
|
+
request.query().add('skip_rights', 'y');
|
|
282
|
+
if (payload) {
|
|
283
|
+
appendPayload(request, payload);
|
|
284
|
+
}
|
|
285
|
+
function handleResponse(status, data) {
|
|
286
|
+
if (status >= 200 && status < 300) {
|
|
287
|
+
if (success) {
|
|
288
|
+
success(data);
|
|
289
|
+
}
|
|
290
|
+
} else if (error) {
|
|
291
|
+
error(status, data);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function handleError(status, data) {
|
|
295
|
+
if (error) {
|
|
296
|
+
error(status, data);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
request.responseHandler(handleResponse).errorHandler(handleError);
|
|
300
|
+
request.send();
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
this.getStorefrontV2 = function (success, error) {
|
|
304
|
+
sendStorefrontRequest(
|
|
305
|
+
'/domains/' + this.id() + '/storefront_v2/',
|
|
306
|
+
'GET',
|
|
307
|
+
null,
|
|
308
|
+
success,
|
|
309
|
+
error
|
|
310
|
+
);
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
this.provisionStorefrontV2 = function (payload, success, error) {
|
|
314
|
+
var args = parsePayloadAndCallbacks(payload, success, error);
|
|
315
|
+
sendStorefrontRequest(
|
|
316
|
+
'/domains/' + this.id() + '/storefront_v2/provision/',
|
|
317
|
+
'POST',
|
|
318
|
+
args.payload,
|
|
319
|
+
args.success,
|
|
320
|
+
args.error
|
|
321
|
+
);
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
this.createStorefrontChangeRequest = function (payload, success, error) {
|
|
325
|
+
var args = parsePayloadAndCallbacks(payload, success, error);
|
|
326
|
+
sendStorefrontRequest(
|
|
327
|
+
'/domains/' + this.id() + '/storefront_v2/requests/',
|
|
328
|
+
'POST',
|
|
329
|
+
args.payload,
|
|
330
|
+
args.success,
|
|
331
|
+
args.error
|
|
332
|
+
);
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
this.getStorefrontChangeRequest = function (requestId, success, error) {
|
|
336
|
+
sendStorefrontRequest(
|
|
337
|
+
'/storefront_change_requests/' + requestId + '/',
|
|
338
|
+
'GET',
|
|
339
|
+
null,
|
|
340
|
+
success,
|
|
341
|
+
error
|
|
342
|
+
);
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
this.runStorefrontChangeRequest = function (requestId, payload, success, error) {
|
|
346
|
+
var args = parsePayloadAndCallbacks(payload, success, error);
|
|
347
|
+
sendStorefrontRequest(
|
|
348
|
+
'/storefront_change_requests/' + requestId + '/run/',
|
|
349
|
+
'POST',
|
|
350
|
+
args.payload,
|
|
351
|
+
args.success,
|
|
352
|
+
args.error
|
|
353
|
+
);
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
this.approveStorefrontChangeRequest = function (requestId, payload, success, error) {
|
|
357
|
+
var args = parsePayloadAndCallbacks(payload, success, error);
|
|
358
|
+
sendStorefrontRequest(
|
|
359
|
+
'/storefront_change_requests/' + requestId + '/approve/',
|
|
360
|
+
'POST',
|
|
361
|
+
args.payload,
|
|
362
|
+
args.success,
|
|
363
|
+
args.error
|
|
364
|
+
);
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
this.rejectStorefrontChangeRequest = function (requestId, payload, success, error) {
|
|
368
|
+
var args = parsePayloadAndCallbacks(payload, success, error);
|
|
369
|
+
sendStorefrontRequest(
|
|
370
|
+
'/storefront_change_requests/' + requestId + '/reject/',
|
|
371
|
+
'POST',
|
|
372
|
+
args.payload,
|
|
373
|
+
args.success,
|
|
374
|
+
args.error
|
|
375
|
+
);
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
this.getStorefrontV2Deployments = function (success, error) {
|
|
379
|
+
sendStorefrontRequest(
|
|
380
|
+
'/domains/' + this.id() + '/storefront_v2/deployments/',
|
|
381
|
+
'GET',
|
|
382
|
+
null,
|
|
383
|
+
success,
|
|
384
|
+
error
|
|
385
|
+
);
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
this.getStorefrontV2DeploymentLogs = function (deploymentId, success, error) {
|
|
389
|
+
sendStorefrontRequest(
|
|
390
|
+
'/domains/' + this.id() + '/storefront_v2/deployments/' +
|
|
391
|
+
deploymentId + '/logs/',
|
|
392
|
+
'GET',
|
|
393
|
+
null,
|
|
394
|
+
success,
|
|
395
|
+
error
|
|
396
|
+
);
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
this.rollbackStorefrontV2 = function (payload, success, error) {
|
|
400
|
+
var args = parsePayloadAndCallbacks(payload, success, error);
|
|
401
|
+
sendStorefrontRequest(
|
|
402
|
+
'/domains/' + this.id() + '/storefront_v2/rollback/',
|
|
403
|
+
'POST',
|
|
404
|
+
args.payload,
|
|
405
|
+
args.success,
|
|
406
|
+
args.error
|
|
407
|
+
);
|
|
408
|
+
};
|
|
256
409
|
}
|
|
257
410
|
|
|
258
411
|
export function Domains() {
|
package/src/draft_template.js
CHANGED
|
@@ -24,6 +24,9 @@ export function DraftTemplate() {
|
|
|
24
24
|
addPropertyTo(this, 'height');
|
|
25
25
|
addPropertyTo(this, 'width');
|
|
26
26
|
addPropertyTo(this, 'draftPreviewLayer', DraftPreviewLayer);
|
|
27
|
+
addPropertyTo(this, 'customisationMap');
|
|
28
|
+
addPropertyTo(this, 'customisationMapSource');
|
|
29
|
+
addPropertyTo(this, 'customisationMapFileId');
|
|
27
30
|
|
|
28
31
|
this.create = function (options) {
|
|
29
32
|
var data = serialise(this),
|
package/src/merchi.js
CHANGED
|
@@ -62,6 +62,7 @@ import { ProductionComment } from './production_comment.js';
|
|
|
62
62
|
import { PhoneNumber, PhoneNumbers } from './phone_number.js';
|
|
63
63
|
import { Session, Sessions } from './session.js';
|
|
64
64
|
import { Shipment, Shipments } from './shipment.js';
|
|
65
|
+
import { ShipmentLog, ShipmentLogs } from './shipment_log.js';
|
|
65
66
|
import { ShipmentMethod, ShipmentMethods } from './shipment_method.js';
|
|
66
67
|
import { ShipmentMethodVariation, ShipmentMethodVariations } from
|
|
67
68
|
'./shipment_method_variation.js';
|
|
@@ -981,6 +982,8 @@ export function merchi(backendUri, websocketUri) {
|
|
|
981
982
|
'removeUnstoredFiles': removeUnstoredFiles,
|
|
982
983
|
'Shipment': Shipment,
|
|
983
984
|
'shipments': new Shipments(),
|
|
985
|
+
'ShipmentLog': ShipmentLog,
|
|
986
|
+
'shipmentLogs': new ShipmentLogs(),
|
|
984
987
|
'ShipmentMethod': ShipmentMethod,
|
|
985
988
|
'shipmentMethods': new ShipmentMethods(),
|
|
986
989
|
'ShipmentMethodVariation': ShipmentMethodVariation,
|
package/src/product.js
CHANGED
|
@@ -42,10 +42,12 @@ export function Product() {
|
|
|
42
42
|
addPropertyTo(this, 'independent');
|
|
43
43
|
addPropertyTo(this, 'productType');
|
|
44
44
|
addPropertyTo(this, 'description');
|
|
45
|
+
addPropertyTo(this, 'aiContextDrafting');
|
|
45
46
|
addPropertyTo(this, 'notes');
|
|
46
47
|
addPropertyTo(this, 'spProductId');
|
|
47
48
|
addPropertyTo(this, 'shopifyProductId');
|
|
48
49
|
addPropertyTo(this, 'minimum');
|
|
50
|
+
addPropertyTo(this, 'defaultQuantity')
|
|
49
51
|
addPropertyTo(this, 'minimumPrice')
|
|
50
52
|
addPropertyTo(this, 'minimumPerGroup');
|
|
51
53
|
addPropertyTo(this, 'deliveryDaysNormal');
|
|
@@ -116,6 +118,7 @@ export function Product() {
|
|
|
116
118
|
addPropertyTo(this, 'shipmentMethods', ShipmentMethod);
|
|
117
119
|
addPropertyTo(this, 'seoDomainPages', SeoDomainPage);
|
|
118
120
|
addPropertyTo(this, 'aiContext');
|
|
121
|
+
addPropertyTo(this, 'aiContextDrafting');
|
|
119
122
|
addPropertyTo(this, 'internalUseNotes');
|
|
120
123
|
addPropertyTo(this, 'internalUseAiContext');
|
|
121
124
|
addPropertyTo(this, 'groupsFirst');
|
package/src/shipment.js
CHANGED
|
@@ -12,6 +12,7 @@ import { Invoice } from './invoice.js';
|
|
|
12
12
|
import { Job } from './job.js';
|
|
13
13
|
import { MerchiFile } from './merchi_file.js';
|
|
14
14
|
import { ShipmentItem } from './shipment_item.js';
|
|
15
|
+
import { ShipmentLog } from './shipment_log.js';
|
|
15
16
|
import { ShipmentMethod } from './shipment_method.js';
|
|
16
17
|
import { Reminder } from './reminder.js';
|
|
17
18
|
import { InternalTag } from './internal_tag.js';
|
|
@@ -60,6 +61,7 @@ export function Shipment() {
|
|
|
60
61
|
addPropertyTo(this, 'shipmentMethod', ShipmentMethod);
|
|
61
62
|
addPropertyTo(this, 'internalTags', InternalTag);
|
|
62
63
|
addPropertyTo(this, 'reminders', Reminder);
|
|
64
|
+
addPropertyTo(this, 'logs', ShipmentLog);
|
|
63
65
|
|
|
64
66
|
this.get = function (success, error, embed) {
|
|
65
67
|
var self = this;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { generateUUID } from './uuid.js';
|
|
2
|
+
import {
|
|
3
|
+
addPropertyTo,
|
|
4
|
+
serialise,
|
|
5
|
+
create,
|
|
6
|
+
enumerateFiles,
|
|
7
|
+
fromJson,
|
|
8
|
+
getOne,
|
|
9
|
+
getList,
|
|
10
|
+
fromJsonList,
|
|
11
|
+
} from './model.js';
|
|
12
|
+
import { Shipment } from './shipment.js';
|
|
13
|
+
import { User } from './user.js';
|
|
14
|
+
|
|
15
|
+
export function ShipmentLog() {
|
|
16
|
+
this.resource = '/shipment_logs';
|
|
17
|
+
this.json = 'shipmentLog';
|
|
18
|
+
this.temporaryId = generateUUID();
|
|
19
|
+
|
|
20
|
+
addPropertyTo(this, 'id');
|
|
21
|
+
addPropertyTo(this, 'shipment', Shipment);
|
|
22
|
+
addPropertyTo(this, 'user', User);
|
|
23
|
+
addPropertyTo(this, 'sourceType');
|
|
24
|
+
addPropertyTo(this, 'message');
|
|
25
|
+
addPropertyTo(this, 'detailJson');
|
|
26
|
+
addPropertyTo(this, 'createdAt');
|
|
27
|
+
|
|
28
|
+
this.create = function (options) {
|
|
29
|
+
var data = serialise(this),
|
|
30
|
+
self = this;
|
|
31
|
+
function handleResponse(result) {
|
|
32
|
+
options.success(fromJson(self, result[self.json]));
|
|
33
|
+
}
|
|
34
|
+
create({
|
|
35
|
+
resource: this.resource,
|
|
36
|
+
parameters: data[0],
|
|
37
|
+
files: enumerateFiles(data[1]),
|
|
38
|
+
success: handleResponse,
|
|
39
|
+
as_domain: options.as_domain,
|
|
40
|
+
error: options.error,
|
|
41
|
+
embed: options.embed,
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
this.get = function (success, error, embed) {
|
|
46
|
+
var self = this;
|
|
47
|
+
function handleResponse(result) {
|
|
48
|
+
success(
|
|
49
|
+
fromJson(self, result[self.json], { makesDirty: false })
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
getOne({
|
|
53
|
+
resource: this.resource,
|
|
54
|
+
id: this.id(),
|
|
55
|
+
success: handleResponse,
|
|
56
|
+
error: error,
|
|
57
|
+
embed: embed,
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function ShipmentLogs() {
|
|
63
|
+
this.resource = '/shipment_logs';
|
|
64
|
+
this.json = 'shipmentLogs';
|
|
65
|
+
this.single = ShipmentLog;
|
|
66
|
+
|
|
67
|
+
this.get = function (success, error, parameters) {
|
|
68
|
+
var self = this;
|
|
69
|
+
function handleResponse(result) {
|
|
70
|
+
success(fromJsonList(self, result, { makesDirty: false }));
|
|
71
|
+
}
|
|
72
|
+
getList(this.resource, handleResponse, error, parameters || {});
|
|
73
|
+
};
|
|
74
|
+
}
|