btrz-api-client 9.0.0 → 9.1.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.
|
@@ -450,6 +450,45 @@ function cartFactory({
|
|
|
450
450
|
});
|
|
451
451
|
}
|
|
452
452
|
};
|
|
453
|
+
const expirationTime = {
|
|
454
|
+
/**
|
|
455
|
+
* POST /carts/:cartId/expiration-time - set cart expiration time.
|
|
456
|
+
* @param {Object} opts
|
|
457
|
+
* @param {string} [opts.token] - API key
|
|
458
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
459
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
460
|
+
* @param {string} opts.cartId - Cart id
|
|
461
|
+
* @param {Object} opts.expirationTime - Expiration time payload
|
|
462
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
463
|
+
* @throws 400 INVALID_CART_ID
|
|
464
|
+
* @throws 400 EXPIRATION_TIME_ALREADY_SET
|
|
465
|
+
* @throws 404 ACCOUNT_NOT_FOUND
|
|
466
|
+
* @throws 404 CART_NOT_FOUND
|
|
467
|
+
* @throws 404 CART_EXPIRED
|
|
468
|
+
* @throws 500 INTERNAL_SERVER_ERROR
|
|
469
|
+
*/
|
|
470
|
+
create({
|
|
471
|
+
token,
|
|
472
|
+
jwtToken,
|
|
473
|
+
headers,
|
|
474
|
+
cartId,
|
|
475
|
+
expirationTime
|
|
476
|
+
}) {
|
|
477
|
+
return client({
|
|
478
|
+
url: `/carts/${cartId}/expiration-time`,
|
|
479
|
+
method: "post",
|
|
480
|
+
headers: authorizationHeaders({
|
|
481
|
+
token,
|
|
482
|
+
jwtToken,
|
|
483
|
+
internalAuthTokenProvider,
|
|
484
|
+
headers
|
|
485
|
+
}),
|
|
486
|
+
data: {
|
|
487
|
+
expirationTime: expirationTime
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
};
|
|
453
492
|
return {
|
|
454
493
|
get,
|
|
455
494
|
create,
|
|
@@ -462,7 +501,8 @@ function cartFactory({
|
|
|
462
501
|
partialDepositStatus,
|
|
463
502
|
payments,
|
|
464
503
|
taxExemptPaymentMethod,
|
|
465
|
-
financingCosts
|
|
504
|
+
financingCosts,
|
|
505
|
+
expirationTime
|
|
466
506
|
};
|
|
467
507
|
}
|
|
468
508
|
module.exports = cartFactory;
|
package/package.json
CHANGED
|
@@ -302,6 +302,35 @@ function cartFactory({client, internalAuthTokenProvider}) {
|
|
|
302
302
|
}
|
|
303
303
|
};
|
|
304
304
|
|
|
305
|
+
const expirationTime = {
|
|
306
|
+
/**
|
|
307
|
+
* POST /carts/:cartId/expiration-time - set cart expiration time.
|
|
308
|
+
* @param {Object} opts
|
|
309
|
+
* @param {string} [opts.token] - API key
|
|
310
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
311
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
312
|
+
* @param {string} opts.cartId - Cart id
|
|
313
|
+
* @param {Object} opts.expirationTime - Expiration time payload
|
|
314
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
315
|
+
* @throws 400 INVALID_CART_ID
|
|
316
|
+
* @throws 400 EXPIRATION_TIME_ALREADY_SET
|
|
317
|
+
* @throws 404 ACCOUNT_NOT_FOUND
|
|
318
|
+
* @throws 404 CART_NOT_FOUND
|
|
319
|
+
* @throws 404 CART_EXPIRED
|
|
320
|
+
* @throws 500 INTERNAL_SERVER_ERROR
|
|
321
|
+
*/
|
|
322
|
+
create({token, jwtToken, headers, cartId, expirationTime}) {
|
|
323
|
+
return client({
|
|
324
|
+
url: `/carts/${cartId}/expiration-time`,
|
|
325
|
+
method: "post",
|
|
326
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
327
|
+
data: {
|
|
328
|
+
expirationTime: expirationTime
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
|
|
305
334
|
return {
|
|
306
335
|
get,
|
|
307
336
|
create,
|
|
@@ -314,7 +343,8 @@ function cartFactory({client, internalAuthTokenProvider}) {
|
|
|
314
343
|
partialDepositStatus,
|
|
315
344
|
payments,
|
|
316
345
|
taxExemptPaymentMethod,
|
|
317
|
-
financingCosts
|
|
346
|
+
financingCosts,
|
|
347
|
+
expirationTime
|
|
318
348
|
};
|
|
319
349
|
}
|
|
320
350
|
|
|
@@ -105,4 +105,10 @@ describe("sales/cart", () => {
|
|
|
105
105
|
axiosMock.onDelete(`/carts/${cartId}/paid-in-items`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
106
106
|
return api.sales.cart.deletePaidInItems({jwtToken, token, cartId});
|
|
107
107
|
});
|
|
108
|
+
|
|
109
|
+
it("should set cart expiration time", () => {
|
|
110
|
+
const cartId = "someCartId";
|
|
111
|
+
axiosMock.onPost(`/carts/${cartId}/expiration-time`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
112
|
+
return api.sales.cart.expirationTime.create({jwtToken, token, cartId, expirationTime: {time: 45}});
|
|
113
|
+
});
|
|
108
114
|
});
|