@commercelayer/sdk 4.30.0 → 4.32.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/lib/cjs/api.d.ts +4 -2
- package/lib/cjs/api.js +8 -2
- package/lib/cjs/client.d.ts +5 -1
- package/lib/cjs/client.js +22 -3
- package/lib/cjs/commercelayer.d.ts +4 -2
- package/lib/cjs/commercelayer.js +3 -1
- package/lib/cjs/error.d.ts +1 -0
- package/lib/cjs/error.js +1 -2
- package/lib/cjs/interceptor.d.ts +1 -1
- package/lib/cjs/jsonapi.js +4 -1
- package/lib/cjs/model.d.ts +2 -0
- package/lib/cjs/resources/authorizations.d.ts +3 -0
- package/lib/cjs/resources/authorizations.js +4 -0
- package/lib/cjs/resources/captures.d.ts +3 -0
- package/lib/cjs/resources/captures.js +4 -0
- package/lib/cjs/resources/coupons.d.ts +8 -0
- package/lib/cjs/resources/coupons.js +4 -0
- package/lib/cjs/resources/customer_addresses.d.ts +2 -0
- package/lib/cjs/resources/customers.d.ts +1 -0
- package/lib/cjs/resources/external_promotions.d.ts +3 -0
- package/lib/cjs/resources/external_promotions.js +4 -0
- package/lib/cjs/resources/fixed_amount_promotions.d.ts +3 -0
- package/lib/cjs/resources/fixed_amount_promotions.js +4 -0
- package/lib/cjs/resources/fixed_price_promotions.d.ts +8 -8
- package/lib/cjs/resources/fixed_price_promotions.js +4 -4
- package/lib/cjs/resources/free_gift_promotions.d.ts +8 -8
- package/lib/cjs/resources/free_gift_promotions.js +4 -4
- package/lib/cjs/resources/free_shipping_promotions.d.ts +3 -0
- package/lib/cjs/resources/free_shipping_promotions.js +4 -0
- package/lib/cjs/resources/imports.d.ts +0 -3
- package/lib/cjs/resources/inventory_models.d.ts +3 -0
- package/lib/cjs/resources/line_items.d.ts +5 -0
- package/lib/cjs/resources/line_items.js +4 -0
- package/lib/cjs/resources/order_amount_promotion_rules.d.ts +3 -0
- package/lib/cjs/resources/orders.d.ts +4 -4
- package/lib/cjs/resources/parcel_line_items.d.ts +1 -1
- package/lib/cjs/resources/parcels.d.ts +3 -3
- package/lib/cjs/resources/percentage_discount_promotions.d.ts +8 -8
- package/lib/cjs/resources/percentage_discount_promotions.js +4 -4
- package/lib/cjs/resources/promotions.d.ts +3 -0
- package/lib/cjs/resources/promotions.js +4 -0
- package/lib/cjs/resources/refunds.d.ts +3 -0
- package/lib/cjs/resources/refunds.js +4 -0
- package/lib/cjs/resources/reserved_stocks.d.ts +28 -0
- package/lib/cjs/resources/reserved_stocks.js +28 -0
- package/lib/cjs/resources/return_line_items.d.ts +2 -1
- package/lib/cjs/resources/satispay_payments.d.ts +7 -0
- package/lib/cjs/resources/shipping_methods.d.ts +6 -0
- package/lib/cjs/resources/skus.d.ts +3 -0
- package/lib/cjs/resources/skus.js +4 -0
- package/lib/cjs/resources/stock_items.d.ts +6 -0
- package/lib/cjs/resources/stock_items.js +8 -0
- package/lib/cjs/resources/stock_line_items.d.ts +3 -0
- package/lib/cjs/resources/stock_line_items.js +4 -0
- package/lib/cjs/resources/stock_reservations.d.ts +36 -0
- package/lib/cjs/resources/stock_reservations.js +36 -0
- package/lib/cjs/resources/stripe_payments.d.ts +1 -0
- package/lib/cjs/resources/transactions.d.ts +5 -2
- package/lib/cjs/resources/transactions.js +4 -0
- package/lib/cjs/resources/voids.d.ts +3 -0
- package/lib/cjs/resources/voids.js +4 -0
- package/lib/cjs/util.d.ts +0 -4
- package/lib/esm/api.d.ts +4 -2
- package/lib/esm/api.js +4 -0
- package/lib/esm/client.d.ts +5 -1
- package/lib/esm/client.js +22 -3
- package/lib/esm/commercelayer.d.ts +4 -2
- package/lib/esm/commercelayer.js +3 -1
- package/lib/esm/error.d.ts +1 -0
- package/lib/esm/interceptor.d.ts +1 -1
- package/lib/esm/jsonapi.js +4 -1
- package/lib/esm/model.d.ts +2 -0
- package/lib/esm/resources/authorizations.d.ts +3 -0
- package/lib/esm/resources/authorizations.js +4 -0
- package/lib/esm/resources/captures.d.ts +3 -0
- package/lib/esm/resources/captures.js +4 -0
- package/lib/esm/resources/coupons.d.ts +8 -0
- package/lib/esm/resources/coupons.js +4 -0
- package/lib/esm/resources/customer_addresses.d.ts +2 -0
- package/lib/esm/resources/customers.d.ts +1 -0
- package/lib/esm/resources/external_promotions.d.ts +3 -0
- package/lib/esm/resources/external_promotions.js +4 -0
- package/lib/esm/resources/fixed_amount_promotions.d.ts +3 -0
- package/lib/esm/resources/fixed_amount_promotions.js +4 -0
- package/lib/esm/resources/fixed_price_promotions.d.ts +8 -8
- package/lib/esm/resources/fixed_price_promotions.js +4 -4
- package/lib/esm/resources/free_gift_promotions.d.ts +8 -8
- package/lib/esm/resources/free_gift_promotions.js +4 -4
- package/lib/esm/resources/free_shipping_promotions.d.ts +3 -0
- package/lib/esm/resources/free_shipping_promotions.js +4 -0
- package/lib/esm/resources/imports.d.ts +0 -3
- package/lib/esm/resources/inventory_models.d.ts +3 -0
- package/lib/esm/resources/line_items.d.ts +5 -0
- package/lib/esm/resources/line_items.js +4 -0
- package/lib/esm/resources/order_amount_promotion_rules.d.ts +3 -0
- package/lib/esm/resources/orders.d.ts +4 -4
- package/lib/esm/resources/parcel_line_items.d.ts +1 -1
- package/lib/esm/resources/parcels.d.ts +3 -3
- package/lib/esm/resources/percentage_discount_promotions.d.ts +8 -8
- package/lib/esm/resources/percentage_discount_promotions.js +4 -4
- package/lib/esm/resources/promotions.d.ts +3 -0
- package/lib/esm/resources/promotions.js +4 -0
- package/lib/esm/resources/refunds.d.ts +3 -0
- package/lib/esm/resources/refunds.js +4 -0
- package/lib/esm/resources/reserved_stocks.d.ts +28 -0
- package/lib/esm/resources/reserved_stocks.js +26 -0
- package/lib/esm/resources/return_line_items.d.ts +2 -1
- package/lib/esm/resources/satispay_payments.d.ts +7 -0
- package/lib/esm/resources/shipping_methods.d.ts +6 -0
- package/lib/esm/resources/skus.d.ts +3 -0
- package/lib/esm/resources/skus.js +4 -0
- package/lib/esm/resources/stock_items.d.ts +6 -0
- package/lib/esm/resources/stock_items.js +8 -0
- package/lib/esm/resources/stock_line_items.d.ts +3 -0
- package/lib/esm/resources/stock_line_items.js +4 -0
- package/lib/esm/resources/stock_reservations.d.ts +36 -0
- package/lib/esm/resources/stock_reservations.js +34 -0
- package/lib/esm/resources/stripe_payments.d.ts +1 -0
- package/lib/esm/resources/transactions.d.ts +5 -2
- package/lib/esm/resources/transactions.js +4 -0
- package/lib/esm/resources/voids.d.ts +3 -0
- package/lib/esm/resources/voids.js +4 -0
- package/lib/esm/util.d.ts +0 -4
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +8 -8
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const resource_1 = require("../resource");
|
4
|
+
class ReservedStocks extends resource_1.ApiResource {
|
5
|
+
async stock_item(reservedStockId, params, options) {
|
6
|
+
const _reservedStockId = reservedStockId.id || reservedStockId;
|
7
|
+
return this.resources.fetch({ type: 'stock_items' }, `reserved_stocks/${_reservedStockId}/stock_item`, params, options);
|
8
|
+
}
|
9
|
+
async sku(reservedStockId, params, options) {
|
10
|
+
const _reservedStockId = reservedStockId.id || reservedStockId;
|
11
|
+
return this.resources.fetch({ type: 'skus' }, `reserved_stocks/${_reservedStockId}/sku`, params, options);
|
12
|
+
}
|
13
|
+
async stock_reservations(reservedStockId, params, options) {
|
14
|
+
const _reservedStockId = reservedStockId.id || reservedStockId;
|
15
|
+
return this.resources.fetch({ type: 'stock_reservations' }, `reserved_stocks/${_reservedStockId}/stock_reservations`, params, options);
|
16
|
+
}
|
17
|
+
isReservedStock(resource) {
|
18
|
+
return resource.type && (resource.type === ReservedStocks.TYPE);
|
19
|
+
}
|
20
|
+
relationship(id) {
|
21
|
+
return ((id === null) || (typeof id === 'string')) ? { id, type: ReservedStocks.TYPE } : { id: id.id, type: ReservedStocks.TYPE };
|
22
|
+
}
|
23
|
+
type() {
|
24
|
+
return ReservedStocks.TYPE;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
ReservedStocks.TYPE = 'reserved_stocks';
|
28
|
+
exports.default = ReservedStocks;
|
@@ -17,8 +17,9 @@ interface ReturnLineItem extends Resource {
|
|
17
17
|
readonly type: ReturnLineItemType;
|
18
18
|
sku_code?: string | null;
|
19
19
|
bundle_code?: string | null;
|
20
|
-
name?: string | null;
|
21
20
|
quantity: number;
|
21
|
+
name?: string | null;
|
22
|
+
image_url?: string | null;
|
22
23
|
return_reason?: Record<string, any> | null;
|
23
24
|
restocked_at?: string | null;
|
24
25
|
return?: Return | null;
|
@@ -13,11 +13,18 @@ type OrderRel = ResourceRel & {
|
|
13
13
|
interface SatispayPayment extends Resource {
|
14
14
|
readonly type: SatispayPaymentType;
|
15
15
|
payment_id?: string | null;
|
16
|
+
flow?: string | null;
|
16
17
|
redirect_url?: string | null;
|
18
|
+
payment_url?: string | null;
|
19
|
+
intent_amount_cents: number;
|
20
|
+
intent_amount_float?: number | null;
|
21
|
+
formatted_intent_amount?: string | null;
|
22
|
+
payment_response?: Record<string, any> | null;
|
17
23
|
order?: Order | null;
|
18
24
|
payment_gateway?: PaymentGateway | null;
|
19
25
|
}
|
20
26
|
interface SatispayPaymentCreate extends ResourceCreate {
|
27
|
+
flow?: string | null;
|
21
28
|
redirect_url?: string | null;
|
22
29
|
order: OrderRel;
|
23
30
|
}
|
@@ -33,6 +33,7 @@ interface ShippingMethod extends Resource {
|
|
33
33
|
name: string;
|
34
34
|
scheme?: string | null;
|
35
35
|
currency_code?: string | null;
|
36
|
+
external_prices_url?: string | null;
|
36
37
|
disabled_at?: string | null;
|
37
38
|
price_amount_cents: number;
|
38
39
|
price_amount_float?: number | null;
|
@@ -40,6 +41,7 @@ interface ShippingMethod extends Resource {
|
|
40
41
|
free_over_amount_cents?: number | null;
|
41
42
|
free_over_amount_float?: number | null;
|
42
43
|
formatted_free_over_amount?: string | null;
|
44
|
+
use_subtotal?: boolean | null;
|
43
45
|
price_amount_for_shipment_cents?: number | null;
|
44
46
|
price_amount_for_shipment_float?: number | null;
|
45
47
|
formatted_price_amount_for_shipment?: string | null;
|
@@ -59,8 +61,10 @@ interface ShippingMethodCreate extends ResourceCreate {
|
|
59
61
|
name: string;
|
60
62
|
scheme?: string | null;
|
61
63
|
currency_code?: string | null;
|
64
|
+
external_prices_url?: string | null;
|
62
65
|
price_amount_cents: number;
|
63
66
|
free_over_amount_cents?: number | null;
|
67
|
+
use_subtotal?: boolean | null;
|
64
68
|
min_weight?: number | null;
|
65
69
|
max_weight?: number | null;
|
66
70
|
unit_of_weight?: string | null;
|
@@ -74,10 +78,12 @@ interface ShippingMethodUpdate extends ResourceUpdate {
|
|
74
78
|
name?: string | null;
|
75
79
|
scheme?: string | null;
|
76
80
|
currency_code?: string | null;
|
81
|
+
external_prices_url?: string | null;
|
77
82
|
_disable?: boolean | null;
|
78
83
|
_enable?: boolean | null;
|
79
84
|
price_amount_cents?: number | null;
|
80
85
|
free_over_amount_cents?: number | null;
|
86
|
+
use_subtotal?: boolean | null;
|
81
87
|
min_weight?: number | null;
|
82
88
|
max_weight?: number | null;
|
83
89
|
unit_of_weight?: string | null;
|
@@ -4,6 +4,7 @@ import type { QueryParamsRetrieve, QueryParamsList } from '../query';
|
|
4
4
|
import type { ShippingCategory, ShippingCategoryType } from './shipping_categories';
|
5
5
|
import type { Price } from './prices';
|
6
6
|
import type { StockItem } from './stock_items';
|
7
|
+
import type { StockReservation } from './stock_reservations';
|
7
8
|
import type { DeliveryLeadTime } from './delivery_lead_times';
|
8
9
|
import type { SkuOption } from './sku_options';
|
9
10
|
import type { Attachment } from './attachments';
|
@@ -35,6 +36,7 @@ interface Sku extends Resource {
|
|
35
36
|
shipping_category?: ShippingCategory | null;
|
36
37
|
prices?: Price[] | null;
|
37
38
|
stock_items?: StockItem[] | null;
|
39
|
+
stock_reservations?: StockReservation[] | null;
|
38
40
|
delivery_lead_times?: DeliveryLeadTime[] | null;
|
39
41
|
sku_options?: SkuOption[] | null;
|
40
42
|
attachments?: Attachment[] | null;
|
@@ -77,6 +79,7 @@ declare class Skus extends ApiResource<Sku> {
|
|
77
79
|
shipping_category(skuId: string | Sku, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<ShippingCategory>;
|
78
80
|
prices(skuId: string | Sku, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Price>>;
|
79
81
|
stock_items(skuId: string | Sku, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<StockItem>>;
|
82
|
+
stock_reservations(skuId: string | Sku, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<StockReservation>>;
|
80
83
|
delivery_lead_times(skuId: string | Sku, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<DeliveryLeadTime>>;
|
81
84
|
sku_options(skuId: string | Sku, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<SkuOption>>;
|
82
85
|
attachments(skuId: string | Sku, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
|
@@ -23,6 +23,10 @@ class Skus extends resource_1.ApiResource {
|
|
23
23
|
const _skuId = skuId.id || skuId;
|
24
24
|
return this.resources.fetch({ type: 'stock_items' }, `skus/${_skuId}/stock_items`, params, options);
|
25
25
|
}
|
26
|
+
async stock_reservations(skuId, params, options) {
|
27
|
+
const _skuId = skuId.id || skuId;
|
28
|
+
return this.resources.fetch({ type: 'stock_reservations' }, `skus/${_skuId}/stock_reservations`, params, options);
|
29
|
+
}
|
26
30
|
async delivery_lead_times(skuId, params, options) {
|
27
31
|
const _skuId = skuId.id || skuId;
|
28
32
|
return this.resources.fetch({ type: 'delivery_lead_times' }, `skus/${_skuId}/delivery_lead_times`, params, options);
|
@@ -3,6 +3,8 @@ import type { Resource, ResourceCreate, ResourceUpdate, ResourceId, ResourcesCon
|
|
3
3
|
import type { QueryParamsRetrieve, QueryParamsList } from '../query';
|
4
4
|
import type { StockLocation, StockLocationType } from './stock_locations';
|
5
5
|
import type { Sku, SkuType } from './skus';
|
6
|
+
import type { ReservedStock } from './reserved_stocks';
|
7
|
+
import type { StockReservation } from './stock_reservations';
|
6
8
|
import type { Attachment } from './attachments';
|
7
9
|
type StockItemType = 'stock_items';
|
8
10
|
type StockItemRel = ResourceRel & {
|
@@ -20,6 +22,8 @@ interface StockItem extends Resource {
|
|
20
22
|
quantity: number;
|
21
23
|
stock_location?: StockLocation | null;
|
22
24
|
sku?: Sku | null;
|
25
|
+
reserved_stock?: ReservedStock | null;
|
26
|
+
stock_reservations?: StockReservation[] | null;
|
23
27
|
attachments?: Attachment[] | null;
|
24
28
|
}
|
25
29
|
interface StockItemCreate extends ResourceCreate {
|
@@ -41,6 +45,8 @@ declare class StockItems extends ApiResource<StockItem> {
|
|
41
45
|
delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>;
|
42
46
|
stock_location(stockItemId: string | StockItem, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<StockLocation>;
|
43
47
|
sku(stockItemId: string | StockItem, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Sku>;
|
48
|
+
reserved_stock(stockItemId: string | StockItem, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<ReservedStock>;
|
49
|
+
stock_reservations(stockItemId: string | StockItem, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<StockReservation>>;
|
44
50
|
attachments(stockItemId: string | StockItem, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
|
45
51
|
isStockItem(resource: any): resource is StockItem;
|
46
52
|
relationship(id: string | ResourceId | null): StockItemRel;
|
@@ -19,6 +19,14 @@ class StockItems extends resource_1.ApiResource {
|
|
19
19
|
const _stockItemId = stockItemId.id || stockItemId;
|
20
20
|
return this.resources.fetch({ type: 'skus' }, `stock_items/${_stockItemId}/sku`, params, options);
|
21
21
|
}
|
22
|
+
async reserved_stock(stockItemId, params, options) {
|
23
|
+
const _stockItemId = stockItemId.id || stockItemId;
|
24
|
+
return this.resources.fetch({ type: 'reserved_stocks' }, `stock_items/${_stockItemId}/reserved_stock`, params, options);
|
25
|
+
}
|
26
|
+
async stock_reservations(stockItemId, params, options) {
|
27
|
+
const _stockItemId = stockItemId.id || stockItemId;
|
28
|
+
return this.resources.fetch({ type: 'stock_reservations' }, `stock_items/${_stockItemId}/stock_reservations`, params, options);
|
29
|
+
}
|
22
30
|
async attachments(stockItemId, params, options) {
|
23
31
|
const _stockItemId = stockItemId.id || stockItemId;
|
24
32
|
return this.resources.fetch({ type: 'attachments' }, `stock_items/${_stockItemId}/attachments`, params, options);
|
@@ -4,6 +4,7 @@ import type { QueryParamsRetrieve } from '../query';
|
|
4
4
|
import type { Shipment } from './shipments';
|
5
5
|
import type { LineItem } from './line_items';
|
6
6
|
import type { StockItem } from './stock_items';
|
7
|
+
import type { Sku } from './skus';
|
7
8
|
type StockLineItemType = 'stock_line_items';
|
8
9
|
type StockLineItemRel = ResourceRel & {
|
9
10
|
type: StockLineItemType;
|
@@ -16,12 +17,14 @@ interface StockLineItem extends Resource {
|
|
16
17
|
shipment?: Shipment | null;
|
17
18
|
line_item?: LineItem | null;
|
18
19
|
stock_item?: StockItem | null;
|
20
|
+
sku?: Sku | null;
|
19
21
|
}
|
20
22
|
declare class StockLineItems extends ApiResource<StockLineItem> {
|
21
23
|
static readonly TYPE: StockLineItemType;
|
22
24
|
shipment(stockLineItemId: string | StockLineItem, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Shipment>;
|
23
25
|
line_item(stockLineItemId: string | StockLineItem, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<LineItem>;
|
24
26
|
stock_item(stockLineItemId: string | StockLineItem, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<StockItem>;
|
27
|
+
sku(stockLineItemId: string | StockLineItem, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Sku>;
|
25
28
|
isStockLineItem(resource: any): resource is StockLineItem;
|
26
29
|
relationship(id: string | ResourceId | null): StockLineItemRel;
|
27
30
|
type(): StockLineItemType;
|
@@ -14,6 +14,10 @@ class StockLineItems extends resource_1.ApiResource {
|
|
14
14
|
const _stockLineItemId = stockLineItemId.id || stockLineItemId;
|
15
15
|
return this.resources.fetch({ type: 'stock_items' }, `stock_line_items/${_stockLineItemId}/stock_item`, params, options);
|
16
16
|
}
|
17
|
+
async sku(stockLineItemId, params, options) {
|
18
|
+
const _stockLineItemId = stockLineItemId.id || stockLineItemId;
|
19
|
+
return this.resources.fetch({ type: 'skus' }, `stock_line_items/${_stockLineItemId}/sku`, params, options);
|
20
|
+
}
|
17
21
|
isStockLineItem(resource) {
|
18
22
|
return resource.type && (resource.type === StockLineItems.TYPE);
|
19
23
|
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { ApiResource } from '../resource';
|
2
|
+
import type { Resource, ResourceId, ResourcesConfig, ResourceRel } from '../resource';
|
3
|
+
import type { QueryParamsRetrieve } from '../query';
|
4
|
+
import type { LineItem } from './line_items';
|
5
|
+
import type { Order } from './orders';
|
6
|
+
import type { StockItem } from './stock_items';
|
7
|
+
import type { ReservedStock } from './reserved_stocks';
|
8
|
+
import type { Sku } from './skus';
|
9
|
+
type StockReservationType = 'stock_reservations';
|
10
|
+
type StockReservationRel = ResourceRel & {
|
11
|
+
type: StockReservationType;
|
12
|
+
};
|
13
|
+
interface StockReservation extends Resource {
|
14
|
+
readonly type: StockReservationType;
|
15
|
+
status: 'draft' | 'pending';
|
16
|
+
quantity: number;
|
17
|
+
expires_at: string;
|
18
|
+
line_item?: LineItem | null;
|
19
|
+
order?: Order | null;
|
20
|
+
stock_item?: StockItem | null;
|
21
|
+
reserved_stock?: ReservedStock | null;
|
22
|
+
sku?: Sku | null;
|
23
|
+
}
|
24
|
+
declare class StockReservations extends ApiResource<StockReservation> {
|
25
|
+
static readonly TYPE: StockReservationType;
|
26
|
+
line_item(stockReservationId: string | StockReservation, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<LineItem>;
|
27
|
+
order(stockReservationId: string | StockReservation, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Order>;
|
28
|
+
stock_item(stockReservationId: string | StockReservation, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<StockItem>;
|
29
|
+
reserved_stock(stockReservationId: string | StockReservation, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<ReservedStock>;
|
30
|
+
sku(stockReservationId: string | StockReservation, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Sku>;
|
31
|
+
isStockReservation(resource: any): resource is StockReservation;
|
32
|
+
relationship(id: string | ResourceId | null): StockReservationRel;
|
33
|
+
type(): StockReservationType;
|
34
|
+
}
|
35
|
+
export default StockReservations;
|
36
|
+
export type { StockReservation, StockReservationType };
|
@@ -0,0 +1,36 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const resource_1 = require("../resource");
|
4
|
+
class StockReservations extends resource_1.ApiResource {
|
5
|
+
async line_item(stockReservationId, params, options) {
|
6
|
+
const _stockReservationId = stockReservationId.id || stockReservationId;
|
7
|
+
return this.resources.fetch({ type: 'line_items' }, `stock_reservations/${_stockReservationId}/line_item`, params, options);
|
8
|
+
}
|
9
|
+
async order(stockReservationId, params, options) {
|
10
|
+
const _stockReservationId = stockReservationId.id || stockReservationId;
|
11
|
+
return this.resources.fetch({ type: 'orders' }, `stock_reservations/${_stockReservationId}/order`, params, options);
|
12
|
+
}
|
13
|
+
async stock_item(stockReservationId, params, options) {
|
14
|
+
const _stockReservationId = stockReservationId.id || stockReservationId;
|
15
|
+
return this.resources.fetch({ type: 'stock_items' }, `stock_reservations/${_stockReservationId}/stock_item`, params, options);
|
16
|
+
}
|
17
|
+
async reserved_stock(stockReservationId, params, options) {
|
18
|
+
const _stockReservationId = stockReservationId.id || stockReservationId;
|
19
|
+
return this.resources.fetch({ type: 'reserved_stocks' }, `stock_reservations/${_stockReservationId}/reserved_stock`, params, options);
|
20
|
+
}
|
21
|
+
async sku(stockReservationId, params, options) {
|
22
|
+
const _stockReservationId = stockReservationId.id || stockReservationId;
|
23
|
+
return this.resources.fetch({ type: 'skus' }, `stock_reservations/${_stockReservationId}/sku`, params, options);
|
24
|
+
}
|
25
|
+
isStockReservation(resource) {
|
26
|
+
return resource.type && (resource.type === StockReservations.TYPE);
|
27
|
+
}
|
28
|
+
relationship(id) {
|
29
|
+
return ((id === null) || (typeof id === 'string')) ? { id, type: StockReservations.TYPE } : { id: id.id, type: StockReservations.TYPE };
|
30
|
+
}
|
31
|
+
type() {
|
32
|
+
return StockReservations.TYPE;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
StockReservations.TYPE = 'stock_reservations';
|
36
|
+
exports.default = StockReservations;
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { ApiResource } from '../resource';
|
2
|
-
import type { Resource, ResourceId, ResourcesConfig, ResourceRel } from '../resource';
|
3
|
-
import type { QueryParamsRetrieve } from '../query';
|
2
|
+
import type { Resource, ResourceId, ResourcesConfig, ResourceRel, ListResponse } from '../resource';
|
3
|
+
import type { QueryParamsRetrieve, QueryParamsList } from '../query';
|
4
4
|
import type { Order } from './orders';
|
5
|
+
import type { Attachment } from './attachments';
|
5
6
|
type TransactionType = 'transactions';
|
6
7
|
type TransactionRel = ResourceRel & {
|
7
8
|
type: TransactionType;
|
@@ -20,10 +21,12 @@ interface Transaction extends Resource {
|
|
20
21
|
token?: string | null;
|
21
22
|
gateway_transaction_id?: string | null;
|
22
23
|
order?: Order | null;
|
24
|
+
attachments?: Attachment[] | null;
|
23
25
|
}
|
24
26
|
declare class Transactions extends ApiResource<Transaction> {
|
25
27
|
static readonly TYPE: TransactionType;
|
26
28
|
order(transactionId: string | Transaction, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Order>;
|
29
|
+
attachments(transactionId: string | Transaction, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
|
27
30
|
isTransaction(resource: any): resource is Transaction;
|
28
31
|
relationship(id: string | ResourceId | null): TransactionRel;
|
29
32
|
type(): TransactionType;
|
@@ -6,6 +6,10 @@ class Transactions extends resource_1.ApiResource {
|
|
6
6
|
const _transactionId = transactionId.id || transactionId;
|
7
7
|
return this.resources.fetch({ type: 'orders' }, `transactions/${_transactionId}/order`, params, options);
|
8
8
|
}
|
9
|
+
async attachments(transactionId, params, options) {
|
10
|
+
const _transactionId = transactionId.id || transactionId;
|
11
|
+
return this.resources.fetch({ type: 'attachments' }, `transactions/${_transactionId}/attachments`, params, options);
|
12
|
+
}
|
9
13
|
isTransaction(resource) {
|
10
14
|
return resource.type && (resource.type === Transactions.TYPE);
|
11
15
|
}
|
@@ -2,6 +2,7 @@ import { ApiResource } from '../resource';
|
|
2
2
|
import type { Resource, ResourceId, ResourcesConfig, ResourceRel, ListResponse } from '../resource';
|
3
3
|
import type { QueryParamsRetrieve, QueryParamsList } from '../query';
|
4
4
|
import type { Order } from './orders';
|
5
|
+
import type { Attachment } from './attachments';
|
5
6
|
import type { Authorization } from './authorizations';
|
6
7
|
import type { Event } from './events';
|
7
8
|
type VoidType = 'voids';
|
@@ -22,12 +23,14 @@ interface Void extends Resource {
|
|
22
23
|
token?: string | null;
|
23
24
|
gateway_transaction_id?: string | null;
|
24
25
|
order?: Order | null;
|
26
|
+
attachments?: Attachment[] | null;
|
25
27
|
reference_authorization?: Authorization | null;
|
26
28
|
events?: Event[] | null;
|
27
29
|
}
|
28
30
|
declare class Voids extends ApiResource<Void> {
|
29
31
|
static readonly TYPE: VoidType;
|
30
32
|
order(voidId: string | Void, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Order>;
|
33
|
+
attachments(voidId: string | Void, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
|
31
34
|
reference_authorization(voidId: string | Void, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Authorization>;
|
32
35
|
events(voidId: string | Void, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
|
33
36
|
isVoid(resource: any): resource is Void;
|
@@ -6,6 +6,10 @@ class Voids extends resource_1.ApiResource {
|
|
6
6
|
const _voidId = voidId.id || voidId;
|
7
7
|
return this.resources.fetch({ type: 'orders' }, `voids/${_voidId}/order`, params, options);
|
8
8
|
}
|
9
|
+
async attachments(voidId, params, options) {
|
10
|
+
const _voidId = voidId.id || voidId;
|
11
|
+
return this.resources.fetch({ type: 'attachments' }, `voids/${_voidId}/attachments`, params, options);
|
12
|
+
}
|
9
13
|
async reference_authorization(voidId, params, options) {
|
10
14
|
const _voidId = voidId.id || voidId;
|
11
15
|
return this.resources.fetch({ type: 'authorizations' }, `voids/${_voidId}/reference_authorization`, params, options);
|
package/lib/cjs/util.d.ts
CHANGED
@@ -1,7 +1,3 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
/// <reference types="node" />
|
3
|
-
/// <reference types="node" />
|
4
|
-
/// <reference types="node" />
|
5
1
|
import type { ObjectType } from "./common";
|
6
2
|
declare const sleep: (ms: number) => Promise<NodeJS.Timeout>;
|
7
3
|
declare const sortObjectFields: (obj: ObjectType) => ObjectType;
|
package/lib/esm/api.d.ts
CHANGED
@@ -84,6 +84,7 @@ export { default as PromotionRules } from './resources/promotion_rules';
|
|
84
84
|
export { default as Promotions } from './resources/promotions';
|
85
85
|
export { default as RecurringOrderCopies } from './resources/recurring_order_copies';
|
86
86
|
export { default as Refunds } from './resources/refunds';
|
87
|
+
export { default as ReservedStocks } from './resources/reserved_stocks';
|
87
88
|
export { default as ReturnLineItems } from './resources/return_line_items';
|
88
89
|
export { default as Returns } from './resources/returns';
|
89
90
|
export { default as SatispayGateways } from './resources/satispay_gateways';
|
@@ -102,6 +103,7 @@ export { default as Skus } from './resources/skus';
|
|
102
103
|
export { default as StockItems } from './resources/stock_items';
|
103
104
|
export { default as StockLineItems } from './resources/stock_line_items';
|
104
105
|
export { default as StockLocations } from './resources/stock_locations';
|
106
|
+
export { default as StockReservations } from './resources/stock_reservations';
|
105
107
|
export { default as StockTransfers } from './resources/stock_transfers';
|
106
108
|
export { default as StripeGateways } from './resources/stripe_gateways';
|
107
109
|
export { default as StripePayments } from './resources/stripe_payments';
|
@@ -115,8 +117,8 @@ export { default as Transactions } from './resources/transactions';
|
|
115
117
|
export { default as Voids } from './resources/voids';
|
116
118
|
export { default as Webhooks } from './resources/webhooks';
|
117
119
|
export { default as WireTransfers } from './resources/wire_transfers';
|
118
|
-
export type ResourceTypeLock = 'addresses' | 'adjustments' | 'adyen_gateways' | 'adyen_payments' | 'application' | 'attachments' | 'authorizations' | 'avalara_accounts' | 'axerve_gateways' | 'axerve_payments' | 'billing_info_validation_rules' | 'bing_geocoders' | 'braintree_gateways' | 'braintree_payments' | 'bundles' | 'captures' | 'carrier_accounts' | 'checkout_com_gateways' | 'checkout_com_payments' | 'cleanups' | 'coupon_codes_promotion_rules' | 'coupon_recipients' | 'coupons' | 'customer_addresses' | 'customer_groups' | 'customer_password_resets' | 'customer_payment_sources' | 'customer_subscriptions' | 'customers' | 'delivery_lead_times' | 'event_callbacks' | 'events' | 'exports' | 'external_gateways' | 'external_payments' | 'external_promotions' | 'external_tax_calculators' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'geocoders' | 'gift_card_recipients' | 'gift_cards' | 'google_geocoders' | 'imports' | 'in_stock_subscriptions' | 'inventory_models' | 'inventory_return_locations' | 'inventory_stock_locations' | 'klarna_gateways' | 'klarna_payments' | 'line_item_options' | 'line_items' | 'manual_gateways' | 'manual_tax_calculators' | 'markets' | 'merchants' | 'order_amount_promotion_rules' | 'order_copies' | 'order_factories' | 'order_subscription_items' | 'order_subscriptions' | 'order_validation_rules' | 'orders' | 'organization' | 'packages' | 'parcel_line_items' | 'parcels' | 'payment_gateways' | 'payment_methods' | 'paypal_gateways' | 'paypal_payments' | 'percentage_discount_promotions' | 'price_frequency_tiers' | 'price_lists' | 'price_tiers' | 'price_volume_tiers' | 'prices' | 'promotion_rules' | 'promotions' | 'recurring_order_copies' | 'refunds' | 'return_line_items' | 'returns' | 'satispay_gateways' | 'satispay_payments' | 'shipments' | 'shipping_categories' | 'shipping_method_tiers' | 'shipping_methods' | 'shipping_weight_tiers' | 'shipping_zones' | 'sku_list_items' | 'sku_list_promotion_rules' | 'sku_lists' | 'sku_options' | 'skus' | 'stock_items' | 'stock_line_items' | 'stock_locations' | 'stock_transfers' | 'stripe_gateways' | 'stripe_payments' | 'subscription_models' | 'tags' | 'tax_calculators' | 'tax_categories' | 'tax_rules' | 'taxjar_accounts' | 'transactions' | 'voids' | 'webhooks' | 'wire_transfers';
|
119
|
-
export declare const resourceList: readonly ["addresses", "adjustments", "adyen_gateways", "adyen_payments", "application", "attachments", "authorizations", "avalara_accounts", "axerve_gateways", "axerve_payments", "billing_info_validation_rules", "bing_geocoders", "braintree_gateways", "braintree_payments", "bundles", "captures", "carrier_accounts", "checkout_com_gateways", "checkout_com_payments", "cleanups", "coupon_codes_promotion_rules", "coupon_recipients", "coupons", "customer_addresses", "customer_groups", "customer_password_resets", "customer_payment_sources", "customer_subscriptions", "customers", "delivery_lead_times", "event_callbacks", "events", "exports", "external_gateways", "external_payments", "external_promotions", "external_tax_calculators", "fixed_amount_promotions", "fixed_price_promotions", "free_gift_promotions", "free_shipping_promotions", "geocoders", "gift_card_recipients", "gift_cards", "google_geocoders", "imports", "in_stock_subscriptions", "inventory_models", "inventory_return_locations", "inventory_stock_locations", "klarna_gateways", "klarna_payments", "line_item_options", "line_items", "manual_gateways", "manual_tax_calculators", "markets", "merchants", "order_amount_promotion_rules", "order_copies", "order_factories", "order_subscription_items", "order_subscriptions", "order_validation_rules", "orders", "organization", "packages", "parcel_line_items", "parcels", "payment_gateways", "payment_methods", "paypal_gateways", "paypal_payments", "percentage_discount_promotions", "price_frequency_tiers", "price_lists", "price_tiers", "price_volume_tiers", "prices", "promotion_rules", "promotions", "recurring_order_copies", "refunds", "return_line_items", "returns", "satispay_gateways", "satispay_payments", "shipments", "shipping_categories", "shipping_method_tiers", "shipping_methods", "shipping_weight_tiers", "shipping_zones", "sku_list_items", "sku_list_promotion_rules", "sku_lists", "sku_options", "skus", "stock_items", "stock_line_items", "stock_locations", "stock_transfers", "stripe_gateways", "stripe_payments", "subscription_models", "tags", "tax_calculators", "tax_categories", "tax_rules", "taxjar_accounts", "transactions", "voids", "webhooks", "wire_transfers"];
|
120
|
+
export type ResourceTypeLock = 'addresses' | 'adjustments' | 'adyen_gateways' | 'adyen_payments' | 'application' | 'attachments' | 'authorizations' | 'avalara_accounts' | 'axerve_gateways' | 'axerve_payments' | 'billing_info_validation_rules' | 'bing_geocoders' | 'braintree_gateways' | 'braintree_payments' | 'bundles' | 'captures' | 'carrier_accounts' | 'checkout_com_gateways' | 'checkout_com_payments' | 'cleanups' | 'coupon_codes_promotion_rules' | 'coupon_recipients' | 'coupons' | 'customer_addresses' | 'customer_groups' | 'customer_password_resets' | 'customer_payment_sources' | 'customer_subscriptions' | 'customers' | 'delivery_lead_times' | 'event_callbacks' | 'events' | 'exports' | 'external_gateways' | 'external_payments' | 'external_promotions' | 'external_tax_calculators' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'geocoders' | 'gift_card_recipients' | 'gift_cards' | 'google_geocoders' | 'imports' | 'in_stock_subscriptions' | 'inventory_models' | 'inventory_return_locations' | 'inventory_stock_locations' | 'klarna_gateways' | 'klarna_payments' | 'line_item_options' | 'line_items' | 'manual_gateways' | 'manual_tax_calculators' | 'markets' | 'merchants' | 'order_amount_promotion_rules' | 'order_copies' | 'order_factories' | 'order_subscription_items' | 'order_subscriptions' | 'order_validation_rules' | 'orders' | 'organization' | 'packages' | 'parcel_line_items' | 'parcels' | 'payment_gateways' | 'payment_methods' | 'paypal_gateways' | 'paypal_payments' | 'percentage_discount_promotions' | 'price_frequency_tiers' | 'price_lists' | 'price_tiers' | 'price_volume_tiers' | 'prices' | 'promotion_rules' | 'promotions' | 'recurring_order_copies' | 'refunds' | 'reserved_stocks' | 'return_line_items' | 'returns' | 'satispay_gateways' | 'satispay_payments' | 'shipments' | 'shipping_categories' | 'shipping_method_tiers' | 'shipping_methods' | 'shipping_weight_tiers' | 'shipping_zones' | 'sku_list_items' | 'sku_list_promotion_rules' | 'sku_lists' | 'sku_options' | 'skus' | 'stock_items' | 'stock_line_items' | 'stock_locations' | 'stock_reservations' | 'stock_transfers' | 'stripe_gateways' | 'stripe_payments' | 'subscription_models' | 'tags' | 'tax_calculators' | 'tax_categories' | 'tax_rules' | 'taxjar_accounts' | 'transactions' | 'voids' | 'webhooks' | 'wire_transfers';
|
121
|
+
export declare const resourceList: readonly ["addresses", "adjustments", "adyen_gateways", "adyen_payments", "application", "attachments", "authorizations", "avalara_accounts", "axerve_gateways", "axerve_payments", "billing_info_validation_rules", "bing_geocoders", "braintree_gateways", "braintree_payments", "bundles", "captures", "carrier_accounts", "checkout_com_gateways", "checkout_com_payments", "cleanups", "coupon_codes_promotion_rules", "coupon_recipients", "coupons", "customer_addresses", "customer_groups", "customer_password_resets", "customer_payment_sources", "customer_subscriptions", "customers", "delivery_lead_times", "event_callbacks", "events", "exports", "external_gateways", "external_payments", "external_promotions", "external_tax_calculators", "fixed_amount_promotions", "fixed_price_promotions", "free_gift_promotions", "free_shipping_promotions", "geocoders", "gift_card_recipients", "gift_cards", "google_geocoders", "imports", "in_stock_subscriptions", "inventory_models", "inventory_return_locations", "inventory_stock_locations", "klarna_gateways", "klarna_payments", "line_item_options", "line_items", "manual_gateways", "manual_tax_calculators", "markets", "merchants", "order_amount_promotion_rules", "order_copies", "order_factories", "order_subscription_items", "order_subscriptions", "order_validation_rules", "orders", "organization", "packages", "parcel_line_items", "parcels", "payment_gateways", "payment_methods", "paypal_gateways", "paypal_payments", "percentage_discount_promotions", "price_frequency_tiers", "price_lists", "price_tiers", "price_volume_tiers", "prices", "promotion_rules", "promotions", "recurring_order_copies", "refunds", "reserved_stocks", "return_line_items", "returns", "satispay_gateways", "satispay_payments", "shipments", "shipping_categories", "shipping_method_tiers", "shipping_methods", "shipping_weight_tiers", "shipping_zones", "sku_list_items", "sku_list_promotion_rules", "sku_lists", "sku_options", "skus", "stock_items", "stock_line_items", "stock_locations", "stock_reservations", "stock_transfers", "stripe_gateways", "stripe_payments", "subscription_models", "tags", "tax_calculators", "tax_categories", "tax_rules", "taxjar_accounts", "transactions", "voids", "webhooks", "wire_transfers"];
|
120
122
|
export type RetrievableResourceType = ResourceTypeLock;
|
121
123
|
export type RetrievableResource = {
|
122
124
|
type: RetrievableResourceType;
|
package/lib/esm/api.js
CHANGED
@@ -86,6 +86,7 @@ export { default as PromotionRules } from './resources/promotion_rules';
|
|
86
86
|
export { default as Promotions } from './resources/promotions';
|
87
87
|
export { default as RecurringOrderCopies } from './resources/recurring_order_copies';
|
88
88
|
export { default as Refunds } from './resources/refunds';
|
89
|
+
export { default as ReservedStocks } from './resources/reserved_stocks';
|
89
90
|
export { default as ReturnLineItems } from './resources/return_line_items';
|
90
91
|
export { default as Returns } from './resources/returns';
|
91
92
|
export { default as SatispayGateways } from './resources/satispay_gateways';
|
@@ -104,6 +105,7 @@ export { default as Skus } from './resources/skus';
|
|
104
105
|
export { default as StockItems } from './resources/stock_items';
|
105
106
|
export { default as StockLineItems } from './resources/stock_line_items';
|
106
107
|
export { default as StockLocations } from './resources/stock_locations';
|
108
|
+
export { default as StockReservations } from './resources/stock_reservations';
|
107
109
|
export { default as StockTransfers } from './resources/stock_transfers';
|
108
110
|
export { default as StripeGateways } from './resources/stripe_gateways';
|
109
111
|
export { default as StripePayments } from './resources/stripe_payments';
|
@@ -203,6 +205,7 @@ export const resourceList = [
|
|
203
205
|
'promotions',
|
204
206
|
'recurring_order_copies',
|
205
207
|
'refunds',
|
208
|
+
'reserved_stocks',
|
206
209
|
'return_line_items',
|
207
210
|
'returns',
|
208
211
|
'satispay_gateways',
|
@@ -221,6 +224,7 @@ export const resourceList = [
|
|
221
224
|
'stock_items',
|
222
225
|
'stock_line_items',
|
223
226
|
'stock_locations',
|
227
|
+
'stock_reservations',
|
224
228
|
'stock_transfers',
|
225
229
|
'stripe_gateways',
|
226
230
|
'stripe_payments',
|
package/lib/esm/client.d.ts
CHANGED
@@ -5,12 +5,15 @@ import type { InterceptorManager } from './interceptor';
|
|
5
5
|
import type { Agent as HttpAgent } from 'http';
|
6
6
|
import type { Agent as HttpsAgent } from 'https';
|
7
7
|
type ProxyConfig = AxiosProxyConfig | false;
|
8
|
+
type RequestParams = Record<string, string | number | boolean>;
|
9
|
+
type RequestHeaders = Record<string, string>;
|
8
10
|
type RequestConfig = {
|
9
11
|
timeout?: number;
|
10
|
-
params?:
|
12
|
+
params?: RequestParams;
|
11
13
|
httpAgent?: HttpAgent;
|
12
14
|
httpsAgent?: HttpsAgent;
|
13
15
|
proxy?: ProxyConfig;
|
16
|
+
headers?: RequestHeaders;
|
14
17
|
};
|
15
18
|
type ApiClientInitConfig = {
|
16
19
|
organization: string;
|
@@ -26,6 +29,7 @@ declare class ApiClient {
|
|
26
29
|
private constructor();
|
27
30
|
config(config: ApiClientConfig): void;
|
28
31
|
request(method: Method, path: string, body?: any, options?: ApiClientConfig): Promise<any>;
|
32
|
+
private customHeaders;
|
29
33
|
}
|
30
34
|
export default ApiClient;
|
31
35
|
export type { ApiClientInitConfig, ApiClientConfig, RequestConfig };
|
package/lib/esm/client.js
CHANGED
@@ -26,8 +26,11 @@ const handleError = (error) => {
|
|
26
26
|
const apiError = new ApiError(sdkError);
|
27
27
|
apiError.type = ErrorType.RESPONSE;
|
28
28
|
apiError.status = error.response.status;
|
29
|
+
apiError.statusText = error.response.statusText;
|
29
30
|
apiError.code = String(apiError.status);
|
30
31
|
apiError.errors = error.response.data.errors;
|
32
|
+
if (!apiError.message && apiError.statusText)
|
33
|
+
apiError.message = apiError.statusText;
|
31
34
|
sdkError = apiError;
|
32
35
|
}
|
33
36
|
else if (error.request) {
|
@@ -66,13 +69,16 @@ class ApiClient {
|
|
66
69
|
httpAgent: options.httpAgent,
|
67
70
|
httpsAgent: options.httpsAgent,
|
68
71
|
};
|
72
|
+
// Set custom headers
|
73
|
+
const customHeaders = this.customHeaders(options.headers);
|
69
74
|
const axiosOptions = {
|
70
75
|
baseURL: this.baseUrl,
|
71
76
|
timeout: config.client.timeout,
|
72
77
|
headers: {
|
78
|
+
...customHeaders,
|
73
79
|
'Accept': 'application/vnd.api+json',
|
74
80
|
'Content-Type': 'application/vnd.api+json',
|
75
|
-
'Authorization': 'Bearer ' + __classPrivateFieldGet(this, _ApiClient_accessToken, "f")
|
81
|
+
'Authorization': 'Bearer ' + __classPrivateFieldGet(this, _ApiClient_accessToken, "f")
|
76
82
|
},
|
77
83
|
...axiosConfig
|
78
84
|
};
|
@@ -99,6 +105,8 @@ class ApiClient {
|
|
99
105
|
__classPrivateFieldSet(this, _ApiClient_accessToken, config.accessToken, "f");
|
100
106
|
def.headers.common.Authorization = 'Bearer ' + __classPrivateFieldGet(this, _ApiClient_accessToken, "f");
|
101
107
|
}
|
108
|
+
if (config.headers)
|
109
|
+
def.headers.common = this.customHeaders(config.headers);
|
102
110
|
}
|
103
111
|
async request(method, path, body, options) {
|
104
112
|
debug('request %s %s, %O, %O', method, path, body || {}, options || {});
|
@@ -107,8 +115,10 @@ class ApiClient {
|
|
107
115
|
// Runtime request parameters
|
108
116
|
const baseUrl = (options === null || options === void 0 ? void 0 : options.organization) ? baseURL(options.organization, options.domain) : undefined;
|
109
117
|
const accessToken = (options === null || options === void 0 ? void 0 : options.accessToken) || __classPrivateFieldGet(this, _ApiClient_accessToken, "f");
|
110
|
-
const headers =
|
111
|
-
|
118
|
+
const headers = this.customHeaders(options === null || options === void 0 ? void 0 : options.headers);
|
119
|
+
if (accessToken)
|
120
|
+
headers.Authorization = 'Bearer ' + accessToken;
|
121
|
+
const requestParams = { method, baseURL: baseUrl, url, data, ...options, headers };
|
112
122
|
debug('request params: %O', requestParams);
|
113
123
|
// const start = Date.now()
|
114
124
|
return __classPrivateFieldGet(this, _ApiClient_client, "f").request(requestParams)
|
@@ -116,6 +126,15 @@ class ApiClient {
|
|
116
126
|
.catch(error => handleError(error));
|
117
127
|
// .finally(() => console.log(`<<-- ${method} ${path} ${Date.now() - start}`))
|
118
128
|
}
|
129
|
+
customHeaders(headers) {
|
130
|
+
const customHeaders = {};
|
131
|
+
if (headers) {
|
132
|
+
for (const [name, value] of Object.entries(headers))
|
133
|
+
if (!['accept', 'content-type', 'authorization'].includes(name.toLowerCase()))
|
134
|
+
customHeaders[name] = value;
|
135
|
+
}
|
136
|
+
return customHeaders;
|
137
|
+
}
|
119
138
|
}
|
120
139
|
_ApiClient_accessToken = new WeakMap(), _ApiClient_client = new WeakMap();
|
121
140
|
export default ApiClient;
|
@@ -2,7 +2,7 @@ import * as api from './api';
|
|
2
2
|
import type { ApiError } from './error';
|
3
3
|
import type { ErrorInterceptor, InterceptorType, RawResponseReader, RequestInterceptor, ResponseInterceptor } from './interceptor';
|
4
4
|
import { type ResourcesInitConfig } from './resource';
|
5
|
-
declare const OPEN_API_SCHEMA_VERSION = "4.
|
5
|
+
declare const OPEN_API_SCHEMA_VERSION = "4.10.0";
|
6
6
|
export { OPEN_API_SCHEMA_VERSION };
|
7
7
|
type SdkConfig = Record<string, unknown>;
|
8
8
|
type CommerceLayerInitConfig = SdkConfig & ResourcesInitConfig;
|
@@ -10,7 +10,7 @@ type CommerceLayerConfig = Partial<CommerceLayerInitConfig>;
|
|
10
10
|
declare class CommerceLayerClient {
|
11
11
|
#private;
|
12
12
|
static get openApiSchemaVersion(): string;
|
13
|
-
readonly openApiSchemaVersion = "4.
|
13
|
+
readonly openApiSchemaVersion = "4.10.0";
|
14
14
|
addresses: api.Addresses;
|
15
15
|
adjustments: api.Adjustments;
|
16
16
|
adyen_gateways: api.AdyenGateways;
|
@@ -94,6 +94,7 @@ declare class CommerceLayerClient {
|
|
94
94
|
promotions: api.Promotions;
|
95
95
|
recurring_order_copies: api.RecurringOrderCopies;
|
96
96
|
refunds: api.Refunds;
|
97
|
+
reserved_stocks: api.ReservedStocks;
|
97
98
|
return_line_items: api.ReturnLineItems;
|
98
99
|
returns: api.Returns;
|
99
100
|
satispay_gateways: api.SatispayGateways;
|
@@ -112,6 +113,7 @@ declare class CommerceLayerClient {
|
|
112
113
|
stock_items: api.StockItems;
|
113
114
|
stock_line_items: api.StockLineItems;
|
114
115
|
stock_locations: api.StockLocations;
|
116
|
+
stock_reservations: api.StockReservations;
|
115
117
|
stock_transfers: api.StockTransfers;
|
116
118
|
stripe_gateways: api.StripeGateways;
|
117
119
|
stripe_payments: api.StripePayments;
|
package/lib/esm/commercelayer.js
CHANGED
@@ -16,7 +16,7 @@ import ResourceAdapter from './resource';
|
|
16
16
|
import Debug from './debug';
|
17
17
|
const debug = Debug('commercelayer');
|
18
18
|
// Autogenerated schema version number, do not remove this line
|
19
|
-
const OPEN_API_SCHEMA_VERSION = '4.
|
19
|
+
const OPEN_API_SCHEMA_VERSION = '4.10.0';
|
20
20
|
export { OPEN_API_SCHEMA_VERSION };
|
21
21
|
class CommerceLayerClient {
|
22
22
|
static get openApiSchemaVersion() { return OPEN_API_SCHEMA_VERSION; }
|
@@ -113,6 +113,7 @@ class CommerceLayerClient {
|
|
113
113
|
this.promotions = new api.Promotions(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
|
114
114
|
this.recurring_order_copies = new api.RecurringOrderCopies(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
|
115
115
|
this.refunds = new api.Refunds(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
|
116
|
+
this.reserved_stocks = new api.ReservedStocks(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
|
116
117
|
this.return_line_items = new api.ReturnLineItems(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
|
117
118
|
this.returns = new api.Returns(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
|
118
119
|
this.satispay_gateways = new api.SatispayGateways(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
|
@@ -131,6 +132,7 @@ class CommerceLayerClient {
|
|
131
132
|
this.stock_items = new api.StockItems(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
|
132
133
|
this.stock_line_items = new api.StockLineItems(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
|
133
134
|
this.stock_locations = new api.StockLocations(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
|
135
|
+
this.stock_reservations = new api.StockReservations(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
|
134
136
|
this.stock_transfers = new api.StockTransfers(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
|
135
137
|
this.stripe_gateways = new api.StripeGateways(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
|
136
138
|
this.stripe_payments = new api.StripePayments(__classPrivateFieldGet(this, _CommerceLayerClient_adapter, "f"));
|