@commercelayer/sdk 4.40.0 → 4.42.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 +3 -2
- package/lib/cjs/api.js +8 -2
- package/lib/cjs/client.d.ts +8 -9
- package/lib/cjs/client.js +42 -11
- package/lib/cjs/commercelayer.d.ts +4 -2
- package/lib/cjs/commercelayer.js +7 -1
- package/lib/cjs/error.d.ts +7 -7
- package/lib/cjs/jsonapi.d.ts +1 -0
- package/lib/cjs/jsonapi.js +1 -1
- package/lib/cjs/model.d.ts +1 -1
- package/lib/cjs/resource.d.ts +1 -1
- package/lib/cjs/resource.js +1 -2
- package/lib/cjs/resources/authorizations.d.ts +3 -3
- package/lib/cjs/resources/authorizations.js +4 -4
- package/lib/cjs/resources/avalara_accounts.d.ts +6 -6
- package/lib/cjs/resources/axerve_payments.d.ts +2 -0
- package/lib/cjs/resources/bundles.d.ts +8 -8
- package/lib/cjs/resources/buy_x_pay_y_promotions.d.ts +12 -2
- package/lib/cjs/resources/buy_x_pay_y_promotions.js +4 -0
- package/lib/cjs/resources/captures.d.ts +3 -3
- package/lib/cjs/resources/captures.js +4 -4
- package/lib/cjs/resources/customer_payment_sources.d.ts +13 -1
- package/lib/cjs/resources/customer_payment_sources.js +4 -0
- package/lib/cjs/resources/external_promotions.d.ts +12 -2
- package/lib/cjs/resources/external_promotions.js +4 -0
- package/lib/cjs/resources/fixed_amount_promotions.d.ts +12 -2
- package/lib/cjs/resources/fixed_amount_promotions.js +4 -0
- package/lib/cjs/resources/fixed_price_promotions.d.ts +12 -2
- package/lib/cjs/resources/fixed_price_promotions.js +4 -0
- package/lib/cjs/resources/free_gift_promotions.d.ts +12 -2
- package/lib/cjs/resources/free_gift_promotions.js +4 -0
- package/lib/cjs/resources/free_shipping_promotions.d.ts +12 -2
- package/lib/cjs/resources/free_shipping_promotions.js +4 -0
- package/lib/cjs/resources/imports.d.ts +0 -2
- package/lib/cjs/resources/inventory_models.d.ts +3 -0
- package/lib/cjs/resources/line_items.d.ts +9 -0
- package/lib/cjs/resources/line_items.js +4 -0
- package/lib/cjs/resources/markets.d.ts +5 -0
- package/lib/cjs/resources/orders.d.ts +5 -1
- package/lib/cjs/resources/orders.js +4 -0
- package/lib/cjs/resources/organization.d.ts +4 -4
- package/lib/cjs/resources/payment_methods.d.ts +2 -0
- package/lib/cjs/resources/percentage_discount_promotions.d.ts +12 -2
- package/lib/cjs/resources/percentage_discount_promotions.js +4 -0
- package/lib/cjs/resources/price_lists.d.ts +3 -0
- package/lib/cjs/resources/prices.d.ts +6 -6
- package/lib/cjs/resources/promotions.d.ts +4 -1
- package/lib/cjs/resources/promotions.js +4 -0
- package/lib/cjs/resources/refunds.d.ts +3 -3
- package/lib/cjs/resources/refunds.js +4 -4
- package/lib/cjs/resources/shipments.d.ts +11 -1
- package/lib/cjs/resources/shipments.js +7 -0
- package/lib/cjs/resources/shipping_categories.d.ts +3 -0
- package/lib/cjs/resources/shipping_methods.d.ts +2 -0
- package/lib/cjs/resources/stock_line_items.d.ts +7 -0
- package/lib/cjs/resources/stock_line_items.js +9 -0
- package/lib/cjs/resources/stock_locations.d.ts +3 -0
- package/lib/cjs/resources/stock_reservations.d.ts +0 -1
- package/lib/cjs/resources/stock_transfers.d.ts +1 -0
- package/lib/cjs/resources/stripe_payments.d.ts +2 -0
- package/lib/cjs/resources/transactions.d.ts +3 -0
- package/lib/cjs/resources/transactions.js +4 -0
- package/lib/cjs/resources/voids.d.ts +3 -3
- package/lib/cjs/resources/voids.js +4 -4
- package/lib/cjs/resources/webhooks.d.ts +7 -0
- package/lib/cjs/resources/webhooks.js +6 -0
- package/lib/cjs/static.d.ts +4 -1
- package/lib/cjs/static.js +8 -2
- package/lib/cjs/util.d.ts +6 -1
- package/lib/cjs/util.js +1 -0
- package/lib/esm/api.d.ts +3 -2
- package/lib/esm/api.js +7 -1
- package/lib/esm/client.d.ts +8 -9
- package/lib/esm/client.js +42 -11
- package/lib/esm/commercelayer.d.ts +4 -2
- package/lib/esm/commercelayer.js +7 -1
- package/lib/esm/error.d.ts +7 -7
- package/lib/esm/jsonapi.d.ts +1 -0
- package/lib/esm/jsonapi.js +1 -1
- package/lib/esm/model.d.ts +1 -1
- package/lib/esm/resource.d.ts +1 -1
- package/lib/esm/resource.js +1 -2
- package/lib/esm/resources/authorizations.d.ts +3 -3
- package/lib/esm/resources/authorizations.js +4 -4
- package/lib/esm/resources/avalara_accounts.d.ts +6 -6
- package/lib/esm/resources/axerve_payments.d.ts +2 -0
- package/lib/esm/resources/bundles.d.ts +8 -8
- package/lib/esm/resources/buy_x_pay_y_promotions.d.ts +12 -2
- package/lib/esm/resources/buy_x_pay_y_promotions.js +4 -0
- package/lib/esm/resources/captures.d.ts +3 -3
- package/lib/esm/resources/captures.js +4 -4
- package/lib/esm/resources/customer_payment_sources.d.ts +13 -1
- package/lib/esm/resources/customer_payment_sources.js +4 -0
- package/lib/esm/resources/external_promotions.d.ts +12 -2
- package/lib/esm/resources/external_promotions.js +4 -0
- package/lib/esm/resources/fixed_amount_promotions.d.ts +12 -2
- package/lib/esm/resources/fixed_amount_promotions.js +4 -0
- package/lib/esm/resources/fixed_price_promotions.d.ts +12 -2
- package/lib/esm/resources/fixed_price_promotions.js +4 -0
- package/lib/esm/resources/free_gift_promotions.d.ts +12 -2
- package/lib/esm/resources/free_gift_promotions.js +4 -0
- package/lib/esm/resources/free_shipping_promotions.d.ts +12 -2
- package/lib/esm/resources/free_shipping_promotions.js +4 -0
- package/lib/esm/resources/imports.d.ts +0 -2
- package/lib/esm/resources/inventory_models.d.ts +3 -0
- package/lib/esm/resources/line_items.d.ts +9 -0
- package/lib/esm/resources/line_items.js +4 -0
- package/lib/esm/resources/markets.d.ts +5 -0
- package/lib/esm/resources/orders.d.ts +5 -1
- package/lib/esm/resources/orders.js +4 -0
- package/lib/esm/resources/organization.d.ts +4 -4
- package/lib/esm/resources/payment_methods.d.ts +2 -0
- package/lib/esm/resources/percentage_discount_promotions.d.ts +12 -2
- package/lib/esm/resources/percentage_discount_promotions.js +4 -0
- package/lib/esm/resources/price_lists.d.ts +3 -0
- package/lib/esm/resources/prices.d.ts +6 -6
- package/lib/esm/resources/promotions.d.ts +4 -1
- package/lib/esm/resources/promotions.js +4 -0
- package/lib/esm/resources/refunds.d.ts +3 -3
- package/lib/esm/resources/refunds.js +4 -4
- package/lib/esm/resources/shipments.d.ts +11 -1
- package/lib/esm/resources/shipments.js +7 -0
- package/lib/esm/resources/shipping_categories.d.ts +3 -0
- package/lib/esm/resources/shipping_methods.d.ts +2 -0
- package/lib/esm/resources/stock_line_items.d.ts +7 -0
- package/lib/esm/resources/stock_line_items.js +9 -0
- package/lib/esm/resources/stock_locations.d.ts +3 -0
- package/lib/esm/resources/stock_reservations.d.ts +0 -1
- package/lib/esm/resources/stock_transfers.d.ts +1 -0
- package/lib/esm/resources/stripe_payments.d.ts +2 -0
- package/lib/esm/resources/transactions.d.ts +3 -0
- package/lib/esm/resources/transactions.js +4 -0
- package/lib/esm/resources/voids.d.ts +3 -3
- package/lib/esm/resources/voids.js +4 -4
- package/lib/esm/resources/webhooks.d.ts +7 -0
- package/lib/esm/resources/webhooks.js +6 -0
- package/lib/esm/static.d.ts +4 -1
- package/lib/esm/static.js +8 -2
- package/lib/esm/util.d.ts +6 -1
- package/lib/esm/util.js +27 -1
- package/lib/tsconfig.esm.tsbuildinfo +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
package/lib/cjs/static.js
CHANGED
@@ -29,8 +29,14 @@ const error_1 = require("./error");
|
|
29
29
|
const commercelayer_1 = __importStar(require("./commercelayer"));
|
30
30
|
/* Static functions */
|
31
31
|
exports.CommerceLayerStatic = {
|
32
|
-
resources: () => {
|
33
|
-
return api.resourceList;
|
32
|
+
resources: (sort) => {
|
33
|
+
return sort ? [...api.resourceList].sort() : api.resourceList;
|
34
|
+
},
|
35
|
+
singletons: (sort) => {
|
36
|
+
return sort ? [...api.singletonList].sort() : api.singletonList;
|
37
|
+
},
|
38
|
+
isSingleton: (resource) => {
|
39
|
+
return api.singletonList.includes(resource);
|
34
40
|
},
|
35
41
|
isSdkError: (error) => {
|
36
42
|
return error_1.SdkError.isSdkError(error);
|
package/lib/cjs/util.d.ts
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
/// <reference types="node" />
|
3
|
+
/// <reference types="node" />
|
4
|
+
/// <reference types="node" />
|
5
|
+
/// <reference types="node" />
|
1
6
|
import type { ObjectType } from "../src/common";
|
2
7
|
declare const sleep: (ms: number) => Promise<NodeJS.Timeout>;
|
3
8
|
declare const sortObjectFields: (obj: ObjectType) => ObjectType;
|
4
|
-
export { sleep, sortObjectFields };
|
9
|
+
export { sleep, sortObjectFields, };
|
package/lib/cjs/util.js
CHANGED
package/lib/esm/api.d.ts
CHANGED
@@ -2,7 +2,7 @@ import type { Resource, ResourceRel } from './resource';
|
|
2
2
|
import type { TagType } from './resources/tags';
|
3
3
|
import type { VersionType } from './resources/versions';
|
4
4
|
/**
|
5
|
-
* ©
|
5
|
+
* ©2024 Commerce Layer Inc.
|
6
6
|
**/
|
7
7
|
export { default as Addresses } from './resources/addresses';
|
8
8
|
export { default as Adjustments } from './resources/adjustments';
|
@@ -126,6 +126,7 @@ export { default as Webhooks } from './resources/webhooks';
|
|
126
126
|
export { default as WireTransfers } from './resources/wire_transfers';
|
127
127
|
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' | 'buy_x_pay_y_promotions' | 'captures' | 'carrier_accounts' | 'checkout_com_gateways' | 'checkout_com_payments' | 'cleanups' | 'coupon_codes_promotion_rules' | 'coupon_recipients' | 'coupons' | 'custom_promotion_rules' | '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' | 'payment_options' | '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' | 'versions' | 'voids' | 'webhooks' | 'wire_transfers';
|
128
128
|
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", "buy_x_pay_y_promotions", "captures", "carrier_accounts", "checkout_com_gateways", "checkout_com_payments", "cleanups", "coupon_codes_promotion_rules", "coupon_recipients", "coupons", "custom_promotion_rules", "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", "payment_options", "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", "versions", "voids", "webhooks", "wire_transfers"];
|
129
|
+
export declare const singletonList: readonly ["application", "organization"];
|
129
130
|
export type RetrievableResourceType = ResourceTypeLock;
|
130
131
|
export type RetrievableResource = Resource & {
|
131
132
|
type: RetrievableResourceType;
|
@@ -146,7 +147,7 @@ export type DeletableResourceType = 'addresses' | 'adjustments' | 'adyen_gateway
|
|
146
147
|
export type DeletableResource = Resource & {
|
147
148
|
type: DeletableResourceType;
|
148
149
|
};
|
149
|
-
export type TaggableResourceType = 'addresses' | 'bundles' | 'buy_x_pay_y_promotions' | 'coupons' | 'customers' | 'external_promotions' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'gift_cards' | 'line_item_options' | 'line_items' | 'orders' | 'percentage_discount_promotions' | 'promotions' | 'returns' | 'sku_options' | 'skus';
|
150
|
+
export type TaggableResourceType = 'addresses' | 'bundles' | 'buy_x_pay_y_promotions' | 'coupons' | 'customers' | 'external_promotions' | 'fixed_amount_promotions' | 'fixed_price_promotions' | 'free_gift_promotions' | 'free_shipping_promotions' | 'gift_cards' | 'line_item_options' | 'line_items' | 'orders' | 'percentage_discount_promotions' | 'promotions' | 'returns' | 'shipments' | 'sku_options' | 'skus';
|
150
151
|
export type TaggableResource = Resource & {
|
151
152
|
type: TaggableResourceType;
|
152
153
|
tags?: Array<ResourceRel & {
|
package/lib/esm/api.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
// ##__API_RESOURCES_START__##
|
2
2
|
// ##__API_RESOURCES_TEMPLATE:: export { default as ##__RESOURCE_CLASS__## } from './resources/##__RESOURCE_TYPE__##'
|
3
3
|
/**
|
4
|
-
* ©
|
4
|
+
* ©2024 Commerce Layer Inc.
|
5
5
|
**/
|
6
6
|
export { default as Addresses } from './resources/addresses';
|
7
7
|
export { default as Adjustments } from './resources/adjustments';
|
@@ -248,3 +248,9 @@ export const resourceList = [
|
|
248
248
|
'wire_transfers'
|
249
249
|
// ##__API_RESOURCE_LIST_STOP__##
|
250
250
|
];
|
251
|
+
export const singletonList = [
|
252
|
+
// ##__API_RESOURCE_SINGLETON_START__##
|
253
|
+
'application',
|
254
|
+
'organization'
|
255
|
+
// ##__API_RESOURCE_SINGLETON_STOP__##
|
256
|
+
];
|
package/lib/esm/client.d.ts
CHANGED
@@ -1,9 +1,5 @@
|
|
1
|
-
/// <reference types="node" />
|
2
|
-
/// <reference types="node" />
|
3
1
|
import type { AxiosAdapter, AxiosProxyConfig, Method } from 'axios';
|
4
2
|
import type { InterceptorManager } from './interceptor';
|
5
|
-
import type { Agent as HttpAgent } from 'http';
|
6
|
-
import type { Agent as HttpsAgent } from 'https';
|
7
3
|
type ProxyConfig = AxiosProxyConfig | false;
|
8
4
|
type Adapter = AxiosAdapter;
|
9
5
|
type RequestParams = Record<string, string | number | boolean>;
|
@@ -11,19 +7,21 @@ type RequestHeaders = Record<string, string>;
|
|
11
7
|
type RequestConfig = {
|
12
8
|
timeout?: number;
|
13
9
|
params?: RequestParams;
|
14
|
-
httpAgent?:
|
15
|
-
httpsAgent?:
|
10
|
+
httpAgent?: any;
|
11
|
+
httpsAgent?: any;
|
16
12
|
proxy?: ProxyConfig;
|
17
13
|
headers?: RequestHeaders;
|
18
14
|
};
|
15
|
+
type RequestConfigExtra = {
|
16
|
+
adapter?: Adapter;
|
17
|
+
userAgent?: string;
|
18
|
+
};
|
19
19
|
type ApiConfig = {
|
20
20
|
organization: string;
|
21
21
|
domain?: string;
|
22
22
|
accessToken: string;
|
23
23
|
};
|
24
|
-
type ApiClientInitConfig = ApiConfig & RequestConfig &
|
25
|
-
adapter?: Adapter;
|
26
|
-
};
|
24
|
+
type ApiClientInitConfig = ApiConfig & RequestConfig & RequestConfigExtra;
|
27
25
|
type ApiClientConfig = Partial<ApiClientInitConfig>;
|
28
26
|
declare class ApiClient {
|
29
27
|
#private;
|
@@ -32,6 +30,7 @@ declare class ApiClient {
|
|
32
30
|
interceptors: InterceptorManager;
|
33
31
|
private constructor();
|
34
32
|
config(config: ApiClientConfig): ApiClient;
|
33
|
+
userAgent(userAgent: string): ApiClient;
|
35
34
|
adapter(adapter: Adapter): ApiClient;
|
36
35
|
request(method: Method, path: string, body?: any, options?: ApiClientConfig): Promise<any>;
|
37
36
|
private customHeaders;
|
package/lib/esm/client.js
CHANGED
@@ -13,6 +13,9 @@ var _ApiClient_accessToken, _ApiClient_client;
|
|
13
13
|
import axios from 'axios';
|
14
14
|
import { SdkError, handleError } from './error';
|
15
15
|
import config from './config';
|
16
|
+
// import type { Agent as HttpAgent } from 'http'
|
17
|
+
// import type { Agent as HttpsAgent } from 'https'
|
18
|
+
// import { packageInfo } from './util'
|
16
19
|
import Debug from './debug';
|
17
20
|
const debug = Debug('client');
|
18
21
|
const baseURL = (organization, domain) => {
|
@@ -35,19 +38,28 @@ class ApiClient {
|
|
35
38
|
timeout: options.timeout || config.client.timeout,
|
36
39
|
proxy: options.proxy,
|
37
40
|
httpAgent: options.httpAgent,
|
38
|
-
httpsAgent: options.httpsAgent
|
41
|
+
httpsAgent: options.httpsAgent
|
39
42
|
};
|
40
43
|
// Set custom headers
|
41
44
|
const customHeaders = this.customHeaders(options.headers);
|
45
|
+
// Set headers
|
46
|
+
const headers = {
|
47
|
+
...customHeaders,
|
48
|
+
'Accept': 'application/vnd.api+json',
|
49
|
+
'Content-Type': 'application/vnd.api+json',
|
50
|
+
'Authorization': 'Bearer ' + __classPrivateFieldGet(this, _ApiClient_accessToken, "f")
|
51
|
+
};
|
52
|
+
// Set User-Agent
|
53
|
+
let userAgent = options.userAgent; // || `SDK-core axios/${axios.VERSION}`
|
54
|
+
if (userAgent) {
|
55
|
+
if (!userAgent.includes('axios/'))
|
56
|
+
userAgent += ` axios/${axios.VERSION}`;
|
57
|
+
headers['User-Agent'] = userAgent;
|
58
|
+
}
|
42
59
|
const axiosOptions = {
|
43
60
|
baseURL: this.baseUrl,
|
44
61
|
timeout: config.client.timeout,
|
45
|
-
headers
|
46
|
-
...customHeaders,
|
47
|
-
'Accept': 'application/vnd.api+json',
|
48
|
-
'Content-Type': 'application/vnd.api+json',
|
49
|
-
'Authorization': 'Bearer ' + __classPrivateFieldGet(this, _ApiClient_accessToken, "f")
|
50
|
-
},
|
62
|
+
headers,
|
51
63
|
...axiosConfig
|
52
64
|
};
|
53
65
|
if (options.adapter)
|
@@ -68,6 +80,10 @@ class ApiClient {
|
|
68
80
|
def.httpAgent = config.httpAgent;
|
69
81
|
if (config.httpsAgent)
|
70
82
|
def.httpsAgent = config.httpsAgent;
|
83
|
+
if (config.adapter)
|
84
|
+
this.adapter(config.adapter);
|
85
|
+
if (config.userAgent)
|
86
|
+
this.userAgent(config.userAgent);
|
71
87
|
// API Client config
|
72
88
|
if (config.organization)
|
73
89
|
this.baseUrl = baseURL(config.organization, config.domain);
|
@@ -77,8 +93,18 @@ class ApiClient {
|
|
77
93
|
}
|
78
94
|
if (config.headers)
|
79
95
|
def.headers.common = this.customHeaders(config.headers);
|
80
|
-
|
81
|
-
|
96
|
+
return this;
|
97
|
+
}
|
98
|
+
userAgent(userAgent) {
|
99
|
+
if (userAgent) {
|
100
|
+
let ua = userAgent;
|
101
|
+
if (!ua.includes('axios/')) {
|
102
|
+
// const axiosVer = packageInfo(['dependencies.axios'], { nestedName: true })
|
103
|
+
if (axios.VERSION)
|
104
|
+
ua += ` axios/${axios.VERSION}`;
|
105
|
+
}
|
106
|
+
__classPrivateFieldGet(this, _ApiClient_client, "f").defaults.headers['User-Agent'] = ua;
|
107
|
+
}
|
82
108
|
return this;
|
83
109
|
}
|
84
110
|
adapter(adapter) {
|
@@ -88,6 +114,11 @@ class ApiClient {
|
|
88
114
|
}
|
89
115
|
async request(method, path, body, options) {
|
90
116
|
debug('request %s %s, %O, %O', method, path, body || {}, options || {});
|
117
|
+
// Ignored params alerts (in debug mode)
|
118
|
+
if (options === null || options === void 0 ? void 0 : options.adapter)
|
119
|
+
debug('Adapter ignored in request config');
|
120
|
+
if (options === null || options === void 0 ? void 0 : options.userAgent)
|
121
|
+
debug('User-Agent header ignored in request config');
|
91
122
|
const data = body ? { data: body } : undefined;
|
92
123
|
const url = path;
|
93
124
|
// Runtime request parameters
|
@@ -101,14 +132,14 @@ class ApiClient {
|
|
101
132
|
// const start = Date.now()
|
102
133
|
return __classPrivateFieldGet(this, _ApiClient_client, "f").request(requestParams)
|
103
134
|
.then(response => response.data)
|
104
|
-
.catch(error => handleError(error));
|
135
|
+
.catch((error) => handleError(error));
|
105
136
|
// .finally(() => console.log(`<<-- ${method} ${path} ${Date.now() - start}`))
|
106
137
|
}
|
107
138
|
customHeaders(headers) {
|
108
139
|
const customHeaders = {};
|
109
140
|
if (headers) {
|
110
141
|
for (const [name, value] of Object.entries(headers))
|
111
|
-
if (!['accept', 'content-type', 'authorization'].includes(name.toLowerCase()))
|
142
|
+
if (!['accept', 'content-type', 'authorization', 'user-agent'].includes(name.toLowerCase()))
|
112
143
|
customHeaders[name] = value;
|
113
144
|
}
|
114
145
|
return customHeaders;
|
@@ -2,14 +2,14 @@ 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.24.0";
|
6
6
|
export { OPEN_API_SCHEMA_VERSION };
|
7
7
|
type SdkConfig = {};
|
8
8
|
type CommerceLayerInitConfig = SdkConfig & ResourcesInitConfig;
|
9
9
|
type CommerceLayerConfig = Partial<CommerceLayerInitConfig>;
|
10
10
|
declare class CommerceLayerClient {
|
11
11
|
#private;
|
12
|
-
readonly openApiSchemaVersion = "4.
|
12
|
+
readonly openApiSchemaVersion = "4.24.0";
|
13
13
|
addresses: api.Addresses;
|
14
14
|
adjustments: api.Adjustments;
|
15
15
|
adyen_gateways: api.AdyenGateways;
|
@@ -135,6 +135,8 @@ declare class CommerceLayerClient {
|
|
135
135
|
private localConfig;
|
136
136
|
config(config: CommerceLayerConfig): CommerceLayerClient;
|
137
137
|
resources(): readonly string[];
|
138
|
+
singletons(): readonly string[];
|
139
|
+
isSingleton(resource: api.ResourceTypeLock): boolean;
|
138
140
|
isApiError(error: any): error is ApiError;
|
139
141
|
addRequestInterceptor(onFulfilled?: RequestInterceptor, onRejected?: ErrorInterceptor): number;
|
140
142
|
addResponseInterceptor(onFulfilled?: ResponseInterceptor, onRejected?: ErrorInterceptor): number;
|
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.24.0';
|
20
20
|
export { OPEN_API_SCHEMA_VERSION };
|
21
21
|
class CommerceLayerClient {
|
22
22
|
// ##__CL_RESOURCES_DEF_STOP__##
|
@@ -174,6 +174,12 @@ class CommerceLayerClient {
|
|
174
174
|
resources() {
|
175
175
|
return CommerceLayerStatic.resources();
|
176
176
|
}
|
177
|
+
singletons() {
|
178
|
+
return CommerceLayerStatic.singletons();
|
179
|
+
}
|
180
|
+
isSingleton(resource) {
|
181
|
+
return CommerceLayerStatic.isSingleton(resource);
|
182
|
+
}
|
177
183
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
|
178
184
|
isApiError(error) {
|
179
185
|
return CommerceLayerStatic.isApiError(error);
|
package/lib/esm/error.d.ts
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
declare enum ErrorType {
|
2
|
-
CLIENT = "client"
|
3
|
-
REQUEST = "request"
|
4
|
-
RESPONSE = "response"
|
5
|
-
CANCEL = "cancel"
|
6
|
-
PARSE = "parse"
|
2
|
+
CLIENT = "client",// Error instantiating the client
|
3
|
+
REQUEST = "request",// Error preparing API request
|
4
|
+
RESPONSE = "response",// Error response from API
|
5
|
+
CANCEL = "cancel",// Forced request abort using interceptor
|
6
|
+
PARSE = "parse",// Error parsing API resource
|
7
7
|
GENERIC = "generic"
|
8
8
|
}
|
9
9
|
declare class SdkError extends Error {
|
10
10
|
static NAME: string;
|
11
|
-
static isSdkError(error: any): error is
|
12
|
-
type:
|
11
|
+
static isSdkError(error: any): error is SdkError;
|
12
|
+
type: ErrorType;
|
13
13
|
code?: string;
|
14
14
|
source?: Error;
|
15
15
|
request?: any;
|
package/lib/esm/jsonapi.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { DocWithData, ResourceObject as JSONAPIObject } from 'jsonapi-typescript';
|
2
2
|
import type { ResourceCreate, ResourceUpdate, ResourceId, ResourceType, Resource } from './resource';
|
3
|
+
export type { DocWithData };
|
3
4
|
declare const denormalize: <R extends Resource>(response: DocWithData) => R | R[];
|
4
5
|
declare const normalize: (resource: (ResourceCreate & ResourceType) | (ResourceUpdate & ResourceId)) => JSONAPIObject;
|
5
6
|
export { denormalize, normalize };
|
package/lib/esm/jsonapi.js
CHANGED
@@ -38,7 +38,7 @@ const denormalizeResource = (res, included) => {
|
|
38
38
|
const rel = res.relationships[key].data;
|
39
39
|
if (rel) {
|
40
40
|
if (Array.isArray(rel))
|
41
|
-
resource[key] = rel.map(r => denormalizeResource(findIncluded(r, included), included));
|
41
|
+
resource[key] = rel.map((r) => denormalizeResource(findIncluded(r, included), included));
|
42
42
|
else
|
43
43
|
resource[key] = denormalizeResource(findIncluded(rel, included), included);
|
44
44
|
}
|
package/lib/esm/model.d.ts
CHANGED
package/lib/esm/resource.d.ts
CHANGED
@@ -70,7 +70,7 @@ declare abstract class ApiResourceBase<R extends Resource> {
|
|
70
70
|
constructor(adapter: ResourceAdapter);
|
71
71
|
abstract relationship(id: string | ResourceId | null): ResourceRel;
|
72
72
|
abstract type(): ResourceTypeLock;
|
73
|
-
parse(resource:
|
73
|
+
parse(resource: string): R | R[];
|
74
74
|
update(resource: ResourceUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<R>;
|
75
75
|
}
|
76
76
|
declare abstract class ApiResource<R extends Resource> extends ApiResourceBase<R> {
|
package/lib/esm/resource.js
CHANGED
@@ -14,8 +14,8 @@ import ApiClient from './client';
|
|
14
14
|
import { denormalize, normalize } from './jsonapi';
|
15
15
|
import { generateQueryStringParams, isParamsList } from './query';
|
16
16
|
import config from './config';
|
17
|
-
import Debug from './debug';
|
18
17
|
import { ErrorType, SdkError } from './error';
|
18
|
+
import Debug from './debug';
|
19
19
|
const debug = Debug('resource');
|
20
20
|
class ListResponse extends Array {
|
21
21
|
constructor(meta, data) {
|
@@ -40,7 +40,6 @@ class ResourceAdapter {
|
|
40
40
|
this.localConfig(config);
|
41
41
|
}
|
42
42
|
get interceptors() { return __classPrivateFieldGet(this, _ResourceAdapter_client, "f").interceptors; }
|
43
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
44
43
|
localConfig(config) {
|
45
44
|
// if (typeof config.xyz !== 'undefined') this.#config.xyz = config.xyz
|
46
45
|
}
|
@@ -3,10 +3,10 @@ import type { Resource, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel
|
|
3
3
|
import type { QueryParamsRetrieve, QueryParamsList } from '../query';
|
4
4
|
import type { Order } from './orders';
|
5
5
|
import type { Attachment } from './attachments';
|
6
|
+
import type { Event } from './events';
|
6
7
|
import type { Version } from './versions';
|
7
8
|
import type { Capture } from './captures';
|
8
9
|
import type { Void } from './voids';
|
9
|
-
import type { Event } from './events';
|
10
10
|
type AuthorizationType = 'authorizations';
|
11
11
|
type AuthorizationRel = ResourceRel & {
|
12
12
|
type: AuthorizationType;
|
@@ -40,10 +40,10 @@ interface Authorization extends Resource {
|
|
40
40
|
formatted_void_balance?: string | null;
|
41
41
|
order?: Order | null;
|
42
42
|
attachments?: Attachment[] | null;
|
43
|
+
events?: Event[] | null;
|
43
44
|
versions?: Version[] | null;
|
44
45
|
captures?: Capture[] | null;
|
45
46
|
voids?: Void[] | null;
|
46
|
-
events?: Event[] | null;
|
47
47
|
}
|
48
48
|
interface AuthorizationUpdate extends ResourceUpdate {
|
49
49
|
_capture?: boolean | null;
|
@@ -55,10 +55,10 @@ declare class Authorizations extends ApiResource<Authorization> {
|
|
55
55
|
update(resource: AuthorizationUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Authorization>;
|
56
56
|
order(authorizationId: string | Authorization, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Order>;
|
57
57
|
attachments(authorizationId: string | Authorization, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
|
58
|
+
events(authorizationId: string | Authorization, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
|
58
59
|
versions(authorizationId: string | Authorization, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Version>>;
|
59
60
|
captures(authorizationId: string | Authorization, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Capture>>;
|
60
61
|
voids(authorizationId: string | Authorization, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Void>>;
|
61
|
-
events(authorizationId: string | Authorization, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
|
62
62
|
_capture(id: string | Authorization, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Authorization>;
|
63
63
|
_capture_amount_cents(id: string | Authorization, triggerValue: number, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Authorization>;
|
64
64
|
_void(id: string | Authorization, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Authorization>;
|
@@ -11,6 +11,10 @@ class Authorizations extends ApiResource {
|
|
11
11
|
const _authorizationId = authorizationId.id || authorizationId;
|
12
12
|
return this.resources.fetch({ type: 'attachments' }, `authorizations/${_authorizationId}/attachments`, params, options);
|
13
13
|
}
|
14
|
+
async events(authorizationId, params, options) {
|
15
|
+
const _authorizationId = authorizationId.id || authorizationId;
|
16
|
+
return this.resources.fetch({ type: 'events' }, `authorizations/${_authorizationId}/events`, params, options);
|
17
|
+
}
|
14
18
|
async versions(authorizationId, params, options) {
|
15
19
|
const _authorizationId = authorizationId.id || authorizationId;
|
16
20
|
return this.resources.fetch({ type: 'versions' }, `authorizations/${_authorizationId}/versions`, params, options);
|
@@ -23,10 +27,6 @@ class Authorizations extends ApiResource {
|
|
23
27
|
const _authorizationId = authorizationId.id || authorizationId;
|
24
28
|
return this.resources.fetch({ type: 'voids' }, `authorizations/${_authorizationId}/voids`, params, options);
|
25
29
|
}
|
26
|
-
async events(authorizationId, params, options) {
|
27
|
-
const _authorizationId = authorizationId.id || authorizationId;
|
28
|
-
return this.resources.fetch({ type: 'events' }, `authorizations/${_authorizationId}/events`, params, options);
|
29
|
-
}
|
30
30
|
async _capture(id, params, options) {
|
31
31
|
return this.resources.update({ id: (typeof id === 'string') ? id : id.id, type: Authorizations.TYPE, _capture: true }, params, options);
|
32
32
|
}
|
@@ -17,8 +17,8 @@ interface AvalaraAccount extends Resource {
|
|
17
17
|
name: string;
|
18
18
|
username: string;
|
19
19
|
company_code: string;
|
20
|
-
commit_invoice?:
|
21
|
-
ddp?:
|
20
|
+
commit_invoice?: boolean | null;
|
21
|
+
ddp?: boolean | null;
|
22
22
|
markets?: Market[] | null;
|
23
23
|
attachments?: Attachment[] | null;
|
24
24
|
versions?: Version[] | null;
|
@@ -29,8 +29,8 @@ interface AvalaraAccountCreate extends ResourceCreate {
|
|
29
29
|
username: string;
|
30
30
|
password: string;
|
31
31
|
company_code: string;
|
32
|
-
commit_invoice?:
|
33
|
-
ddp?:
|
32
|
+
commit_invoice?: boolean | null;
|
33
|
+
ddp?: boolean | null;
|
34
34
|
tax_categories?: TaxCategoryRel[] | null;
|
35
35
|
}
|
36
36
|
interface AvalaraAccountUpdate extends ResourceUpdate {
|
@@ -38,8 +38,8 @@ interface AvalaraAccountUpdate extends ResourceUpdate {
|
|
38
38
|
username?: string | null;
|
39
39
|
password?: string | null;
|
40
40
|
company_code?: string | null;
|
41
|
-
commit_invoice?:
|
42
|
-
ddp?:
|
41
|
+
commit_invoice?: boolean | null;
|
42
|
+
ddp?: boolean | null;
|
43
43
|
tax_categories?: TaxCategoryRel[] | null;
|
44
44
|
}
|
45
45
|
declare class AvalaraAccounts extends ApiResource<AvalaraAccount> {
|
@@ -18,6 +18,7 @@ interface AxervePayment extends Resource {
|
|
18
18
|
payment_request_data?: Record<string, any> | null;
|
19
19
|
client_ip?: string | null;
|
20
20
|
buyer_details?: Record<string, any> | null;
|
21
|
+
request_token?: boolean | null;
|
21
22
|
mismatched_amounts?: boolean | null;
|
22
23
|
intent_amount_cents: number;
|
23
24
|
intent_amount_float?: number | null;
|
@@ -31,6 +32,7 @@ interface AxervePaymentCreate extends ResourceCreate {
|
|
31
32
|
return_url: string;
|
32
33
|
client_ip?: string | null;
|
33
34
|
buyer_details?: Record<string, any> | null;
|
35
|
+
request_token?: boolean | null;
|
34
36
|
order: OrderRel;
|
35
37
|
}
|
36
38
|
interface AxervePaymentUpdate extends ResourceUpdate {
|
@@ -30,12 +30,12 @@ interface Bundle extends Resource {
|
|
30
30
|
image_url?: string | null;
|
31
31
|
do_not_ship?: boolean | null;
|
32
32
|
do_not_track?: boolean | null;
|
33
|
-
price_amount_cents
|
34
|
-
price_amount_float
|
35
|
-
formatted_price_amount
|
36
|
-
compare_at_amount_cents
|
37
|
-
compare_at_amount_float
|
38
|
-
formatted_compare_at_amount
|
33
|
+
price_amount_cents?: number | null;
|
34
|
+
price_amount_float?: number | null;
|
35
|
+
formatted_price_amount?: string | null;
|
36
|
+
compare_at_amount_cents?: number | null;
|
37
|
+
compare_at_amount_float?: number | null;
|
38
|
+
formatted_compare_at_amount?: string | null;
|
39
39
|
skus_count?: number | null;
|
40
40
|
market?: Market | null;
|
41
41
|
sku_list?: SkuList | null;
|
@@ -51,8 +51,8 @@ interface BundleCreate extends ResourceCreate {
|
|
51
51
|
currency_code?: string | null;
|
52
52
|
description?: string | null;
|
53
53
|
image_url?: string | null;
|
54
|
-
price_amount_cents
|
55
|
-
compare_at_amount_cents
|
54
|
+
price_amount_cents?: number | null;
|
55
|
+
compare_at_amount_cents?: number | null;
|
56
56
|
_compute_price_amount?: boolean | null;
|
57
57
|
_compute_compare_at_amount?: boolean | null;
|
58
58
|
market?: MarketRel | null;
|
@@ -6,6 +6,7 @@ import type { PromotionRule, PromotionRuleType } from './promotion_rules';
|
|
6
6
|
import type { OrderAmountPromotionRule, OrderAmountPromotionRuleType } from './order_amount_promotion_rules';
|
7
7
|
import type { SkuListPromotionRule, SkuListPromotionRuleType } from './sku_list_promotion_rules';
|
8
8
|
import type { CouponCodesPromotionRule, CouponCodesPromotionRuleType } from './coupon_codes_promotion_rules';
|
9
|
+
import type { CustomPromotionRule, CustomPromotionRuleType } from './custom_promotion_rules';
|
9
10
|
import type { Coupon, CouponType } from './coupons';
|
10
11
|
import type { SkuList, SkuListType } from './sku_lists';
|
11
12
|
import type { Attachment } from './attachments';
|
@@ -32,6 +33,9 @@ type SkuListPromotionRuleRel = ResourceRel & {
|
|
32
33
|
type CouponCodesPromotionRuleRel = ResourceRel & {
|
33
34
|
type: CouponCodesPromotionRuleType;
|
34
35
|
};
|
36
|
+
type CustomPromotionRuleRel = ResourceRel & {
|
37
|
+
type: CustomPromotionRuleType;
|
38
|
+
};
|
35
39
|
type CouponRel = ResourceRel & {
|
36
40
|
type: CouponType;
|
37
41
|
};
|
@@ -49,7 +53,7 @@ interface BuyXPayYPromotion extends Resource {
|
|
49
53
|
priority?: number | null;
|
50
54
|
starts_at: string;
|
51
55
|
expires_at: string;
|
52
|
-
total_usage_limit
|
56
|
+
total_usage_limit?: number | null;
|
53
57
|
total_usage_count?: number | null;
|
54
58
|
active?: boolean | null;
|
55
59
|
disabled_at?: string | null;
|
@@ -61,6 +65,7 @@ interface BuyXPayYPromotion extends Resource {
|
|
61
65
|
order_amount_promotion_rule?: OrderAmountPromotionRule | null;
|
62
66
|
sku_list_promotion_rule?: SkuListPromotionRule | null;
|
63
67
|
coupon_codes_promotion_rule?: CouponCodesPromotionRule | null;
|
68
|
+
custom_promotion_rule?: CustomPromotionRule | null;
|
64
69
|
coupons?: Coupon[] | null;
|
65
70
|
sku_list?: SkuList | null;
|
66
71
|
attachments?: Attachment[] | null;
|
@@ -76,7 +81,9 @@ interface BuyXPayYPromotionCreate extends ResourceCreate {
|
|
76
81
|
priority?: number | null;
|
77
82
|
starts_at: string;
|
78
83
|
expires_at: string;
|
79
|
-
total_usage_limit
|
84
|
+
total_usage_limit?: number | null;
|
85
|
+
_disable?: boolean | null;
|
86
|
+
_enable?: boolean | null;
|
80
87
|
x: number;
|
81
88
|
y: number;
|
82
89
|
cheapest_free?: boolean | null;
|
@@ -85,6 +92,7 @@ interface BuyXPayYPromotionCreate extends ResourceCreate {
|
|
85
92
|
order_amount_promotion_rule?: OrderAmountPromotionRuleRel | null;
|
86
93
|
sku_list_promotion_rule?: SkuListPromotionRuleRel | null;
|
87
94
|
coupon_codes_promotion_rule?: CouponCodesPromotionRuleRel | null;
|
95
|
+
custom_promotion_rule?: CustomPromotionRuleRel | null;
|
88
96
|
coupons?: CouponRel[] | null;
|
89
97
|
sku_list: SkuListRel;
|
90
98
|
tags?: TagRel[] | null;
|
@@ -107,6 +115,7 @@ interface BuyXPayYPromotionUpdate extends ResourceUpdate {
|
|
107
115
|
order_amount_promotion_rule?: OrderAmountPromotionRuleRel | null;
|
108
116
|
sku_list_promotion_rule?: SkuListPromotionRuleRel | null;
|
109
117
|
coupon_codes_promotion_rule?: CouponCodesPromotionRuleRel | null;
|
118
|
+
custom_promotion_rule?: CustomPromotionRuleRel | null;
|
110
119
|
coupons?: CouponRel[] | null;
|
111
120
|
sku_list?: SkuListRel | null;
|
112
121
|
tags?: TagRel[] | null;
|
@@ -120,6 +129,7 @@ declare class BuyXPayYPromotions extends ApiResource<BuyXPayYPromotion> {
|
|
120
129
|
order_amount_promotion_rule(buyXPayYPromotionId: string | BuyXPayYPromotion, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<OrderAmountPromotionRule>;
|
121
130
|
sku_list_promotion_rule(buyXPayYPromotionId: string | BuyXPayYPromotion, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<SkuListPromotionRule>;
|
122
131
|
coupon_codes_promotion_rule(buyXPayYPromotionId: string | BuyXPayYPromotion, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<CouponCodesPromotionRule>;
|
132
|
+
custom_promotion_rule(buyXPayYPromotionId: string | BuyXPayYPromotion, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<CustomPromotionRule>;
|
123
133
|
coupons(buyXPayYPromotionId: string | BuyXPayYPromotion, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Coupon>>;
|
124
134
|
sku_list(buyXPayYPromotionId: string | BuyXPayYPromotion, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<SkuList>;
|
125
135
|
attachments(buyXPayYPromotionId: string | BuyXPayYPromotion, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
|
@@ -25,6 +25,10 @@ class BuyXPayYPromotions extends ApiResource {
|
|
25
25
|
const _buyXPayYPromotionId = buyXPayYPromotionId.id || buyXPayYPromotionId;
|
26
26
|
return this.resources.fetch({ type: 'coupon_codes_promotion_rules' }, `buy_x_pay_y_promotions/${_buyXPayYPromotionId}/coupon_codes_promotion_rule`, params, options);
|
27
27
|
}
|
28
|
+
async custom_promotion_rule(buyXPayYPromotionId, params, options) {
|
29
|
+
const _buyXPayYPromotionId = buyXPayYPromotionId.id || buyXPayYPromotionId;
|
30
|
+
return this.resources.fetch({ type: 'custom_promotion_rules' }, `buy_x_pay_y_promotions/${_buyXPayYPromotionId}/custom_promotion_rule`, params, options);
|
31
|
+
}
|
28
32
|
async coupons(buyXPayYPromotionId, params, options) {
|
29
33
|
const _buyXPayYPromotionId = buyXPayYPromotionId.id || buyXPayYPromotionId;
|
30
34
|
return this.resources.fetch({ type: 'coupons' }, `buy_x_pay_y_promotions/${_buyXPayYPromotionId}/coupons`, params, options);
|
@@ -3,10 +3,10 @@ import type { Resource, ResourceUpdate, ResourceId, ResourcesConfig, ResourceRel
|
|
3
3
|
import type { QueryParamsRetrieve, QueryParamsList } from '../query';
|
4
4
|
import type { Order } from './orders';
|
5
5
|
import type { Attachment } from './attachments';
|
6
|
+
import type { Event } from './events';
|
6
7
|
import type { Version } from './versions';
|
7
8
|
import type { Authorization } from './authorizations';
|
8
9
|
import type { Refund } from './refunds';
|
9
|
-
import type { Event } from './events';
|
10
10
|
type CaptureType = 'captures';
|
11
11
|
type CaptureRel = ResourceRel & {
|
12
12
|
type: CaptureType;
|
@@ -32,10 +32,10 @@ interface Capture extends Resource {
|
|
32
32
|
formatted_refund_balance?: string | null;
|
33
33
|
order?: Order | null;
|
34
34
|
attachments?: Attachment[] | null;
|
35
|
+
events?: Event[] | null;
|
35
36
|
versions?: Version[] | null;
|
36
37
|
reference_authorization?: Authorization | null;
|
37
38
|
refunds?: Refund[] | null;
|
38
|
-
events?: Event[] | null;
|
39
39
|
}
|
40
40
|
interface CaptureUpdate extends ResourceUpdate {
|
41
41
|
_refund?: boolean | null;
|
@@ -46,10 +46,10 @@ declare class Captures extends ApiResource<Capture> {
|
|
46
46
|
update(resource: CaptureUpdate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Capture>;
|
47
47
|
order(captureId: string | Capture, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Order>;
|
48
48
|
attachments(captureId: string | Capture, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Attachment>>;
|
49
|
+
events(captureId: string | Capture, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
|
49
50
|
versions(captureId: string | Capture, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Version>>;
|
50
51
|
reference_authorization(captureId: string | Capture, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Authorization>;
|
51
52
|
refunds(captureId: string | Capture, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Refund>>;
|
52
|
-
events(captureId: string | Capture, params?: QueryParamsList, options?: ResourcesConfig): Promise<ListResponse<Event>>;
|
53
53
|
_refund(id: string | Capture, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Capture>;
|
54
54
|
_refund_amount_cents(id: string | Capture, triggerValue: number, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<Capture>;
|
55
55
|
isCapture(resource: any): resource is Capture;
|