@commercelayer/sdk 6.0.0-alfa.3 → 6.0.0-alfa.5

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.
@@ -10,268 +10,272 @@ class CommerceLayerClient {
10
10
  // static get openApiSchemaVersion(): string { return OPEN_API_SCHEMA_VERSION }
11
11
  openApiSchemaVersion = OPEN_API_SCHEMA_VERSION;
12
12
  #adapter;
13
- #organization;
13
+ #slug;
14
14
  // #environment: ApiMode = sdkConfig.default.environment
15
15
  // ##__CL_RESOURCES_DEF_START__##
16
- // ##__CL_RESOURCES_DEF_TEMPLATE:: ##__TAB__####__RESOURCE_TYPE__##: api.##__RESOURCE_CLASS__##
17
- addresses;
18
- adjustments;
19
- adyen_gateways;
20
- adyen_payments;
21
- application;
22
- attachments;
23
- authorizations;
24
- avalara_accounts;
25
- axerve_gateways;
26
- axerve_payments;
27
- billing_info_validation_rules;
28
- bing_geocoders;
29
- braintree_gateways;
30
- braintree_payments;
31
- bundles;
32
- buy_x_pay_y_promotions;
33
- captures;
34
- carrier_accounts;
35
- checkout_com_gateways;
36
- checkout_com_payments;
37
- cleanups;
38
- coupon_codes_promotion_rules;
39
- coupon_recipients;
40
- coupons;
41
- custom_promotion_rules;
42
- customer_addresses;
43
- customer_groups;
44
- customer_password_resets;
45
- customer_payment_sources;
46
- customer_subscriptions;
47
- customers;
48
- delivery_lead_times;
49
- event_callbacks;
50
- events;
51
- exports;
52
- external_gateways;
53
- external_payments;
54
- external_promotions;
55
- external_tax_calculators;
56
- fixed_amount_promotions;
57
- fixed_price_promotions;
58
- free_gift_promotions;
59
- free_shipping_promotions;
60
- geocoders;
61
- gift_card_recipients;
62
- gift_cards;
63
- google_geocoders;
64
- imports;
65
- in_stock_subscriptions;
66
- inventory_models;
67
- inventory_return_locations;
68
- inventory_stock_locations;
69
- klarna_gateways;
70
- klarna_payments;
71
- line_item_options;
72
- line_items;
73
- manual_gateways;
74
- manual_tax_calculators;
75
- markets;
76
- merchants;
77
- order_amount_promotion_rules;
78
- order_copies;
79
- order_factories;
80
- order_subscription_items;
81
- order_subscriptions;
82
- order_validation_rules;
83
- orders;
84
- organization;
85
- packages;
86
- parcel_line_items;
87
- parcels;
88
- payment_gateways;
89
- payment_methods;
90
- payment_options;
91
- paypal_gateways;
92
- paypal_payments;
93
- percentage_discount_promotions;
94
- price_frequency_tiers;
95
- price_lists;
96
- price_tiers;
97
- price_volume_tiers;
98
- prices;
99
- promotion_rules;
100
- promotions;
101
- recurring_order_copies;
102
- refunds;
103
- reserved_stocks;
104
- resource_errors;
105
- return_line_items;
106
- returns;
107
- satispay_gateways;
108
- satispay_payments;
109
- shipments;
110
- shipping_categories;
111
- shipping_method_tiers;
112
- shipping_methods;
113
- shipping_weight_tiers;
114
- shipping_zones;
115
- sku_list_items;
116
- sku_list_promotion_rules;
117
- sku_lists;
118
- sku_options;
119
- skus;
120
- stock_items;
121
- stock_line_items;
122
- stock_locations;
123
- stock_reservations;
124
- stock_transfers;
125
- stripe_gateways;
126
- stripe_payments;
127
- subscription_models;
128
- tags;
129
- tax_calculators;
130
- tax_categories;
131
- tax_rules;
132
- taxjar_accounts;
133
- transactions;
134
- versions;
135
- voids;
136
- webhooks;
137
- wire_transfers;
16
+ // ##__CL_RESOURCES_DEF_TEMPLATE:: ##__TAB__#####__RESOURCE_TYPE__##?: api.##__RESOURCE_CLASS__##
17
+ #addresses;
18
+ #adjustments;
19
+ #adyen_gateways;
20
+ #adyen_payments;
21
+ #application;
22
+ #attachments;
23
+ #authorizations;
24
+ #avalara_accounts;
25
+ #axerve_gateways;
26
+ #axerve_payments;
27
+ #billing_info_validation_rules;
28
+ #bing_geocoders;
29
+ #braintree_gateways;
30
+ #braintree_payments;
31
+ #bundles;
32
+ #buy_x_pay_y_promotions;
33
+ #captures;
34
+ #carrier_accounts;
35
+ #checkout_com_gateways;
36
+ #checkout_com_payments;
37
+ #cleanups;
38
+ #coupon_codes_promotion_rules;
39
+ #coupon_recipients;
40
+ #coupons;
41
+ #custom_promotion_rules;
42
+ #customer_addresses;
43
+ #customer_groups;
44
+ #customer_password_resets;
45
+ #customer_payment_sources;
46
+ #customer_subscriptions;
47
+ #customers;
48
+ #delivery_lead_times;
49
+ #event_callbacks;
50
+ #events;
51
+ #exports;
52
+ #external_gateways;
53
+ #external_payments;
54
+ #external_promotions;
55
+ #external_tax_calculators;
56
+ #fixed_amount_promotions;
57
+ #fixed_price_promotions;
58
+ #free_gift_promotions;
59
+ #free_shipping_promotions;
60
+ #geocoders;
61
+ #gift_card_recipients;
62
+ #gift_cards;
63
+ #google_geocoders;
64
+ #imports;
65
+ #in_stock_subscriptions;
66
+ #inventory_models;
67
+ #inventory_return_locations;
68
+ #inventory_stock_locations;
69
+ #klarna_gateways;
70
+ #klarna_payments;
71
+ #line_item_options;
72
+ #line_items;
73
+ #manual_gateways;
74
+ #manual_tax_calculators;
75
+ #markets;
76
+ #merchants;
77
+ #order_amount_promotion_rules;
78
+ #order_copies;
79
+ #order_factories;
80
+ #order_subscription_items;
81
+ #order_subscriptions;
82
+ #order_validation_rules;
83
+ #orders;
84
+ #organization;
85
+ #packages;
86
+ #parcel_line_items;
87
+ #parcels;
88
+ #payment_gateways;
89
+ #payment_methods;
90
+ #payment_options;
91
+ #paypal_gateways;
92
+ #paypal_payments;
93
+ #percentage_discount_promotions;
94
+ #price_frequency_tiers;
95
+ #price_lists;
96
+ #price_tiers;
97
+ #price_volume_tiers;
98
+ #prices;
99
+ #promotion_rules;
100
+ #promotions;
101
+ #recurring_order_copies;
102
+ #refunds;
103
+ #reserved_stocks;
104
+ #resource_errors;
105
+ #return_line_items;
106
+ #returns;
107
+ #satispay_gateways;
108
+ #satispay_payments;
109
+ #shipments;
110
+ #shipping_categories;
111
+ #shipping_method_tiers;
112
+ #shipping_methods;
113
+ #shipping_weight_tiers;
114
+ #shipping_zones;
115
+ #sku_list_items;
116
+ #sku_list_promotion_rules;
117
+ #sku_lists;
118
+ #sku_options;
119
+ #skus;
120
+ #stock_items;
121
+ #stock_line_items;
122
+ #stock_locations;
123
+ #stock_reservations;
124
+ #stock_transfers;
125
+ #stripe_gateways;
126
+ #stripe_payments;
127
+ #subscription_models;
128
+ #tags;
129
+ #tax_calculators;
130
+ #tax_categories;
131
+ #tax_rules;
132
+ #taxjar_accounts;
133
+ #transactions;
134
+ #versions;
135
+ #voids;
136
+ #webhooks;
137
+ #wire_transfers;
138
138
  // ##__CL_RESOURCES_DEF_STOP__##
139
139
  constructor(config) {
140
140
  debug('new commercelayer instance %O', config);
141
141
  this.#adapter = new ResourceAdapter(config);
142
- this.#organization = config.organization;
142
+ this.#slug = config.organization;
143
143
  // this.#environment = 'test'
144
144
  // ##__CL_RESOURCES_INIT_START__##
145
145
  // ##__CL_RESOURCES_INIT_TEMPLATE:: ##__TAB__####__TAB__##this.##__RESOURCE_TYPE__## = new api.##__RESOURCE_CLASS__##(this.#adapter)
146
- this.addresses = new api.Addresses(this.#adapter);
147
- this.adjustments = new api.Adjustments(this.#adapter);
148
- this.adyen_gateways = new api.AdyenGateways(this.#adapter);
149
- this.adyen_payments = new api.AdyenPayments(this.#adapter);
150
- this.application = new api.Applications(this.#adapter);
151
- this.attachments = new api.Attachments(this.#adapter);
152
- this.authorizations = new api.Authorizations(this.#adapter);
153
- this.avalara_accounts = new api.AvalaraAccounts(this.#adapter);
154
- this.axerve_gateways = new api.AxerveGateways(this.#adapter);
155
- this.axerve_payments = new api.AxervePayments(this.#adapter);
156
- this.billing_info_validation_rules = new api.BillingInfoValidationRules(this.#adapter);
157
- this.bing_geocoders = new api.BingGeocoders(this.#adapter);
158
- this.braintree_gateways = new api.BraintreeGateways(this.#adapter);
159
- this.braintree_payments = new api.BraintreePayments(this.#adapter);
160
- this.bundles = new api.Bundles(this.#adapter);
161
- this.buy_x_pay_y_promotions = new api.BuyXPayYPromotions(this.#adapter);
162
- this.captures = new api.Captures(this.#adapter);
163
- this.carrier_accounts = new api.CarrierAccounts(this.#adapter);
164
- this.checkout_com_gateways = new api.CheckoutComGateways(this.#adapter);
165
- this.checkout_com_payments = new api.CheckoutComPayments(this.#adapter);
166
- this.cleanups = new api.Cleanups(this.#adapter);
167
- this.coupon_codes_promotion_rules = new api.CouponCodesPromotionRules(this.#adapter);
168
- this.coupon_recipients = new api.CouponRecipients(this.#adapter);
169
- this.coupons = new api.Coupons(this.#adapter);
170
- this.custom_promotion_rules = new api.CustomPromotionRules(this.#adapter);
171
- this.customer_addresses = new api.CustomerAddresses(this.#adapter);
172
- this.customer_groups = new api.CustomerGroups(this.#adapter);
173
- this.customer_password_resets = new api.CustomerPasswordResets(this.#adapter);
174
- this.customer_payment_sources = new api.CustomerPaymentSources(this.#adapter);
175
- this.customer_subscriptions = new api.CustomerSubscriptions(this.#adapter);
176
- this.customers = new api.Customers(this.#adapter);
177
- this.delivery_lead_times = new api.DeliveryLeadTimes(this.#adapter);
178
- this.event_callbacks = new api.EventCallbacks(this.#adapter);
179
- this.events = new api.Events(this.#adapter);
180
- this.exports = new api.Exports(this.#adapter);
181
- this.external_gateways = new api.ExternalGateways(this.#adapter);
182
- this.external_payments = new api.ExternalPayments(this.#adapter);
183
- this.external_promotions = new api.ExternalPromotions(this.#adapter);
184
- this.external_tax_calculators = new api.ExternalTaxCalculators(this.#adapter);
185
- this.fixed_amount_promotions = new api.FixedAmountPromotions(this.#adapter);
186
- this.fixed_price_promotions = new api.FixedPricePromotions(this.#adapter);
187
- this.free_gift_promotions = new api.FreeGiftPromotions(this.#adapter);
188
- this.free_shipping_promotions = new api.FreeShippingPromotions(this.#adapter);
189
- this.geocoders = new api.Geocoders(this.#adapter);
190
- this.gift_card_recipients = new api.GiftCardRecipients(this.#adapter);
191
- this.gift_cards = new api.GiftCards(this.#adapter);
192
- this.google_geocoders = new api.GoogleGeocoders(this.#adapter);
193
- this.imports = new api.Imports(this.#adapter);
194
- this.in_stock_subscriptions = new api.InStockSubscriptions(this.#adapter);
195
- this.inventory_models = new api.InventoryModels(this.#adapter);
196
- this.inventory_return_locations = new api.InventoryReturnLocations(this.#adapter);
197
- this.inventory_stock_locations = new api.InventoryStockLocations(this.#adapter);
198
- this.klarna_gateways = new api.KlarnaGateways(this.#adapter);
199
- this.klarna_payments = new api.KlarnaPayments(this.#adapter);
200
- this.line_item_options = new api.LineItemOptions(this.#adapter);
201
- this.line_items = new api.LineItems(this.#adapter);
202
- this.manual_gateways = new api.ManualGateways(this.#adapter);
203
- this.manual_tax_calculators = new api.ManualTaxCalculators(this.#adapter);
204
- this.markets = new api.Markets(this.#adapter);
205
- this.merchants = new api.Merchants(this.#adapter);
206
- this.order_amount_promotion_rules = new api.OrderAmountPromotionRules(this.#adapter);
207
- this.order_copies = new api.OrderCopies(this.#adapter);
208
- this.order_factories = new api.OrderFactories(this.#adapter);
209
- this.order_subscription_items = new api.OrderSubscriptionItems(this.#adapter);
210
- this.order_subscriptions = new api.OrderSubscriptions(this.#adapter);
211
- this.order_validation_rules = new api.OrderValidationRules(this.#adapter);
212
- this.orders = new api.Orders(this.#adapter);
213
- this.organization = new api.Organizations(this.#adapter);
214
- this.packages = new api.Packages(this.#adapter);
215
- this.parcel_line_items = new api.ParcelLineItems(this.#adapter);
216
- this.parcels = new api.Parcels(this.#adapter);
217
- this.payment_gateways = new api.PaymentGateways(this.#adapter);
218
- this.payment_methods = new api.PaymentMethods(this.#adapter);
219
- this.payment_options = new api.PaymentOptions(this.#adapter);
220
- this.paypal_gateways = new api.PaypalGateways(this.#adapter);
221
- this.paypal_payments = new api.PaypalPayments(this.#adapter);
222
- this.percentage_discount_promotions = new api.PercentageDiscountPromotions(this.#adapter);
223
- this.price_frequency_tiers = new api.PriceFrequencyTiers(this.#adapter);
224
- this.price_lists = new api.PriceLists(this.#adapter);
225
- this.price_tiers = new api.PriceTiers(this.#adapter);
226
- this.price_volume_tiers = new api.PriceVolumeTiers(this.#adapter);
227
- this.prices = new api.Prices(this.#adapter);
228
- this.promotion_rules = new api.PromotionRules(this.#adapter);
229
- this.promotions = new api.Promotions(this.#adapter);
230
- this.recurring_order_copies = new api.RecurringOrderCopies(this.#adapter);
231
- this.refunds = new api.Refunds(this.#adapter);
232
- this.reserved_stocks = new api.ReservedStocks(this.#adapter);
233
- this.resource_errors = new api.ResourceErrors(this.#adapter);
234
- this.return_line_items = new api.ReturnLineItems(this.#adapter);
235
- this.returns = new api.Returns(this.#adapter);
236
- this.satispay_gateways = new api.SatispayGateways(this.#adapter);
237
- this.satispay_payments = new api.SatispayPayments(this.#adapter);
238
- this.shipments = new api.Shipments(this.#adapter);
239
- this.shipping_categories = new api.ShippingCategories(this.#adapter);
240
- this.shipping_method_tiers = new api.ShippingMethodTiers(this.#adapter);
241
- this.shipping_methods = new api.ShippingMethods(this.#adapter);
242
- this.shipping_weight_tiers = new api.ShippingWeightTiers(this.#adapter);
243
- this.shipping_zones = new api.ShippingZones(this.#adapter);
244
- this.sku_list_items = new api.SkuListItems(this.#adapter);
245
- this.sku_list_promotion_rules = new api.SkuListPromotionRules(this.#adapter);
246
- this.sku_lists = new api.SkuLists(this.#adapter);
247
- this.sku_options = new api.SkuOptions(this.#adapter);
248
- this.skus = new api.Skus(this.#adapter);
249
- this.stock_items = new api.StockItems(this.#adapter);
250
- this.stock_line_items = new api.StockLineItems(this.#adapter);
251
- this.stock_locations = new api.StockLocations(this.#adapter);
252
- this.stock_reservations = new api.StockReservations(this.#adapter);
253
- this.stock_transfers = new api.StockTransfers(this.#adapter);
254
- this.stripe_gateways = new api.StripeGateways(this.#adapter);
255
- this.stripe_payments = new api.StripePayments(this.#adapter);
256
- this.subscription_models = new api.SubscriptionModels(this.#adapter);
257
- this.tags = new api.Tags(this.#adapter);
258
- this.tax_calculators = new api.TaxCalculators(this.#adapter);
259
- this.tax_categories = new api.TaxCategories(this.#adapter);
260
- this.tax_rules = new api.TaxRules(this.#adapter);
261
- this.taxjar_accounts = new api.TaxjarAccounts(this.#adapter);
262
- this.transactions = new api.Transactions(this.#adapter);
263
- this.versions = new api.Versions(this.#adapter);
264
- this.voids = new api.Voids(this.#adapter);
265
- this.webhooks = new api.Webhooks(this.#adapter);
266
- this.wire_transfers = new api.WireTransfers(this.#adapter);
267
146
  // ##__CL_RESOURCES_INIT_STOP__##
268
147
  }
269
- get currentOrganization() { return this.#organization; }
148
+ // ##__CL_RESOURCES_LEAZY_LOADING_START__##
149
+ // ##__CL_RESOURCES_LEAZY_LOADING_TEMPLATE:: ##__TAB__##get ##__RESOURCE_TYPE__##(): api.##__RESOURCE_CLASS__## { return this.###__RESOURCE_TYPE__## || (this.###__RESOURCE_TYPE__## = new api.##__RESOURCE_CLASS__##(this.#adapter)) }
150
+ get addresses() { return this.#addresses || (this.#addresses = new api.Addresses(this.#adapter)); }
151
+ get adjustments() { return this.#adjustments || (this.#adjustments = new api.Adjustments(this.#adapter)); }
152
+ get adyen_gateways() { return this.#adyen_gateways || (this.#adyen_gateways = new api.AdyenGateways(this.#adapter)); }
153
+ get adyen_payments() { return this.#adyen_payments || (this.#adyen_payments = new api.AdyenPayments(this.#adapter)); }
154
+ get application() { return this.#application || (this.#application = new api.Applications(this.#adapter)); }
155
+ get attachments() { return this.#attachments || (this.#attachments = new api.Attachments(this.#adapter)); }
156
+ get authorizations() { return this.#authorizations || (this.#authorizations = new api.Authorizations(this.#adapter)); }
157
+ get avalara_accounts() { return this.#avalara_accounts || (this.#avalara_accounts = new api.AvalaraAccounts(this.#adapter)); }
158
+ get axerve_gateways() { return this.#axerve_gateways || (this.#axerve_gateways = new api.AxerveGateways(this.#adapter)); }
159
+ get axerve_payments() { return this.#axerve_payments || (this.#axerve_payments = new api.AxervePayments(this.#adapter)); }
160
+ get billing_info_validation_rules() { return this.#billing_info_validation_rules || (this.#billing_info_validation_rules = new api.BillingInfoValidationRules(this.#adapter)); }
161
+ get bing_geocoders() { return this.#bing_geocoders || (this.#bing_geocoders = new api.BingGeocoders(this.#adapter)); }
162
+ get braintree_gateways() { return this.#braintree_gateways || (this.#braintree_gateways = new api.BraintreeGateways(this.#adapter)); }
163
+ get braintree_payments() { return this.#braintree_payments || (this.#braintree_payments = new api.BraintreePayments(this.#adapter)); }
164
+ get bundles() { return this.#bundles || (this.#bundles = new api.Bundles(this.#adapter)); }
165
+ get buy_x_pay_y_promotions() { return this.#buy_x_pay_y_promotions || (this.#buy_x_pay_y_promotions = new api.BuyXPayYPromotions(this.#adapter)); }
166
+ get captures() { return this.#captures || (this.#captures = new api.Captures(this.#adapter)); }
167
+ get carrier_accounts() { return this.#carrier_accounts || (this.#carrier_accounts = new api.CarrierAccounts(this.#adapter)); }
168
+ get checkout_com_gateways() { return this.#checkout_com_gateways || (this.#checkout_com_gateways = new api.CheckoutComGateways(this.#adapter)); }
169
+ get checkout_com_payments() { return this.#checkout_com_payments || (this.#checkout_com_payments = new api.CheckoutComPayments(this.#adapter)); }
170
+ get cleanups() { return this.#cleanups || (this.#cleanups = new api.Cleanups(this.#adapter)); }
171
+ get coupon_codes_promotion_rules() { return this.#coupon_codes_promotion_rules || (this.#coupon_codes_promotion_rules = new api.CouponCodesPromotionRules(this.#adapter)); }
172
+ get coupon_recipients() { return this.#coupon_recipients || (this.#coupon_recipients = new api.CouponRecipients(this.#adapter)); }
173
+ get coupons() { return this.#coupons || (this.#coupons = new api.Coupons(this.#adapter)); }
174
+ get custom_promotion_rules() { return this.#custom_promotion_rules || (this.#custom_promotion_rules = new api.CustomPromotionRules(this.#adapter)); }
175
+ get customer_addresses() { return this.#customer_addresses || (this.#customer_addresses = new api.CustomerAddresses(this.#adapter)); }
176
+ get customer_groups() { return this.#customer_groups || (this.#customer_groups = new api.CustomerGroups(this.#adapter)); }
177
+ get customer_password_resets() { return this.#customer_password_resets || (this.#customer_password_resets = new api.CustomerPasswordResets(this.#adapter)); }
178
+ get customer_payment_sources() { return this.#customer_payment_sources || (this.#customer_payment_sources = new api.CustomerPaymentSources(this.#adapter)); }
179
+ get customer_subscriptions() { return this.#customer_subscriptions || (this.#customer_subscriptions = new api.CustomerSubscriptions(this.#adapter)); }
180
+ get customers() { return this.#customers || (this.#customers = new api.Customers(this.#adapter)); }
181
+ get delivery_lead_times() { return this.#delivery_lead_times || (this.#delivery_lead_times = new api.DeliveryLeadTimes(this.#adapter)); }
182
+ get event_callbacks() { return this.#event_callbacks || (this.#event_callbacks = new api.EventCallbacks(this.#adapter)); }
183
+ get events() { return this.#events || (this.#events = new api.Events(this.#adapter)); }
184
+ get exports() { return this.#exports || (this.#exports = new api.Exports(this.#adapter)); }
185
+ get external_gateways() { return this.#external_gateways || (this.#external_gateways = new api.ExternalGateways(this.#adapter)); }
186
+ get external_payments() { return this.#external_payments || (this.#external_payments = new api.ExternalPayments(this.#adapter)); }
187
+ get external_promotions() { return this.#external_promotions || (this.#external_promotions = new api.ExternalPromotions(this.#adapter)); }
188
+ get external_tax_calculators() { return this.#external_tax_calculators || (this.#external_tax_calculators = new api.ExternalTaxCalculators(this.#adapter)); }
189
+ get fixed_amount_promotions() { return this.#fixed_amount_promotions || (this.#fixed_amount_promotions = new api.FixedAmountPromotions(this.#adapter)); }
190
+ get fixed_price_promotions() { return this.#fixed_price_promotions || (this.#fixed_price_promotions = new api.FixedPricePromotions(this.#adapter)); }
191
+ get free_gift_promotions() { return this.#free_gift_promotions || (this.#free_gift_promotions = new api.FreeGiftPromotions(this.#adapter)); }
192
+ get free_shipping_promotions() { return this.#free_shipping_promotions || (this.#free_shipping_promotions = new api.FreeShippingPromotions(this.#adapter)); }
193
+ get geocoders() { return this.#geocoders || (this.#geocoders = new api.Geocoders(this.#adapter)); }
194
+ get gift_card_recipients() { return this.#gift_card_recipients || (this.#gift_card_recipients = new api.GiftCardRecipients(this.#adapter)); }
195
+ get gift_cards() { return this.#gift_cards || (this.#gift_cards = new api.GiftCards(this.#adapter)); }
196
+ get google_geocoders() { return this.#google_geocoders || (this.#google_geocoders = new api.GoogleGeocoders(this.#adapter)); }
197
+ get imports() { return this.#imports || (this.#imports = new api.Imports(this.#adapter)); }
198
+ get in_stock_subscriptions() { return this.#in_stock_subscriptions || (this.#in_stock_subscriptions = new api.InStockSubscriptions(this.#adapter)); }
199
+ get inventory_models() { return this.#inventory_models || (this.#inventory_models = new api.InventoryModels(this.#adapter)); }
200
+ get inventory_return_locations() { return this.#inventory_return_locations || (this.#inventory_return_locations = new api.InventoryReturnLocations(this.#adapter)); }
201
+ get inventory_stock_locations() { return this.#inventory_stock_locations || (this.#inventory_stock_locations = new api.InventoryStockLocations(this.#adapter)); }
202
+ get klarna_gateways() { return this.#klarna_gateways || (this.#klarna_gateways = new api.KlarnaGateways(this.#adapter)); }
203
+ get klarna_payments() { return this.#klarna_payments || (this.#klarna_payments = new api.KlarnaPayments(this.#adapter)); }
204
+ get line_item_options() { return this.#line_item_options || (this.#line_item_options = new api.LineItemOptions(this.#adapter)); }
205
+ get line_items() { return this.#line_items || (this.#line_items = new api.LineItems(this.#adapter)); }
206
+ get manual_gateways() { return this.#manual_gateways || (this.#manual_gateways = new api.ManualGateways(this.#adapter)); }
207
+ get manual_tax_calculators() { return this.#manual_tax_calculators || (this.#manual_tax_calculators = new api.ManualTaxCalculators(this.#adapter)); }
208
+ get markets() { return this.#markets || (this.#markets = new api.Markets(this.#adapter)); }
209
+ get merchants() { return this.#merchants || (this.#merchants = new api.Merchants(this.#adapter)); }
210
+ get order_amount_promotion_rules() { return this.#order_amount_promotion_rules || (this.#order_amount_promotion_rules = new api.OrderAmountPromotionRules(this.#adapter)); }
211
+ get order_copies() { return this.#order_copies || (this.#order_copies = new api.OrderCopies(this.#adapter)); }
212
+ get order_factories() { return this.#order_factories || (this.#order_factories = new api.OrderFactories(this.#adapter)); }
213
+ get order_subscription_items() { return this.#order_subscription_items || (this.#order_subscription_items = new api.OrderSubscriptionItems(this.#adapter)); }
214
+ get order_subscriptions() { return this.#order_subscriptions || (this.#order_subscriptions = new api.OrderSubscriptions(this.#adapter)); }
215
+ get order_validation_rules() { return this.#order_validation_rules || (this.#order_validation_rules = new api.OrderValidationRules(this.#adapter)); }
216
+ get orders() { return this.#orders || (this.#orders = new api.Orders(this.#adapter)); }
217
+ get organization() { return this.#organization || (this.#organization = new api.Organizations(this.#adapter)); }
218
+ get packages() { return this.#packages || (this.#packages = new api.Packages(this.#adapter)); }
219
+ get parcel_line_items() { return this.#parcel_line_items || (this.#parcel_line_items = new api.ParcelLineItems(this.#adapter)); }
220
+ get parcels() { return this.#parcels || (this.#parcels = new api.Parcels(this.#adapter)); }
221
+ get payment_gateways() { return this.#payment_gateways || (this.#payment_gateways = new api.PaymentGateways(this.#adapter)); }
222
+ get payment_methods() { return this.#payment_methods || (this.#payment_methods = new api.PaymentMethods(this.#adapter)); }
223
+ get payment_options() { return this.#payment_options || (this.#payment_options = new api.PaymentOptions(this.#adapter)); }
224
+ get paypal_gateways() { return this.#paypal_gateways || (this.#paypal_gateways = new api.PaypalGateways(this.#adapter)); }
225
+ get paypal_payments() { return this.#paypal_payments || (this.#paypal_payments = new api.PaypalPayments(this.#adapter)); }
226
+ get percentage_discount_promotions() { return this.#percentage_discount_promotions || (this.#percentage_discount_promotions = new api.PercentageDiscountPromotions(this.#adapter)); }
227
+ get price_frequency_tiers() { return this.#price_frequency_tiers || (this.#price_frequency_tiers = new api.PriceFrequencyTiers(this.#adapter)); }
228
+ get price_lists() { return this.#price_lists || (this.#price_lists = new api.PriceLists(this.#adapter)); }
229
+ get price_tiers() { return this.#price_tiers || (this.#price_tiers = new api.PriceTiers(this.#adapter)); }
230
+ get price_volume_tiers() { return this.#price_volume_tiers || (this.#price_volume_tiers = new api.PriceVolumeTiers(this.#adapter)); }
231
+ get prices() { return this.#prices || (this.#prices = new api.Prices(this.#adapter)); }
232
+ get promotion_rules() { return this.#promotion_rules || (this.#promotion_rules = new api.PromotionRules(this.#adapter)); }
233
+ get promotions() { return this.#promotions || (this.#promotions = new api.Promotions(this.#adapter)); }
234
+ get recurring_order_copies() { return this.#recurring_order_copies || (this.#recurring_order_copies = new api.RecurringOrderCopies(this.#adapter)); }
235
+ get refunds() { return this.#refunds || (this.#refunds = new api.Refunds(this.#adapter)); }
236
+ get reserved_stocks() { return this.#reserved_stocks || (this.#reserved_stocks = new api.ReservedStocks(this.#adapter)); }
237
+ get resource_errors() { return this.#resource_errors || (this.#resource_errors = new api.ResourceErrors(this.#adapter)); }
238
+ get return_line_items() { return this.#return_line_items || (this.#return_line_items = new api.ReturnLineItems(this.#adapter)); }
239
+ get returns() { return this.#returns || (this.#returns = new api.Returns(this.#adapter)); }
240
+ get satispay_gateways() { return this.#satispay_gateways || (this.#satispay_gateways = new api.SatispayGateways(this.#adapter)); }
241
+ get satispay_payments() { return this.#satispay_payments || (this.#satispay_payments = new api.SatispayPayments(this.#adapter)); }
242
+ get shipments() { return this.#shipments || (this.#shipments = new api.Shipments(this.#adapter)); }
243
+ get shipping_categories() { return this.#shipping_categories || (this.#shipping_categories = new api.ShippingCategories(this.#adapter)); }
244
+ get shipping_method_tiers() { return this.#shipping_method_tiers || (this.#shipping_method_tiers = new api.ShippingMethodTiers(this.#adapter)); }
245
+ get shipping_methods() { return this.#shipping_methods || (this.#shipping_methods = new api.ShippingMethods(this.#adapter)); }
246
+ get shipping_weight_tiers() { return this.#shipping_weight_tiers || (this.#shipping_weight_tiers = new api.ShippingWeightTiers(this.#adapter)); }
247
+ get shipping_zones() { return this.#shipping_zones || (this.#shipping_zones = new api.ShippingZones(this.#adapter)); }
248
+ get sku_list_items() { return this.#sku_list_items || (this.#sku_list_items = new api.SkuListItems(this.#adapter)); }
249
+ get sku_list_promotion_rules() { return this.#sku_list_promotion_rules || (this.#sku_list_promotion_rules = new api.SkuListPromotionRules(this.#adapter)); }
250
+ get sku_lists() { return this.#sku_lists || (this.#sku_lists = new api.SkuLists(this.#adapter)); }
251
+ get sku_options() { return this.#sku_options || (this.#sku_options = new api.SkuOptions(this.#adapter)); }
252
+ get skus() { return this.#skus || (this.#skus = new api.Skus(this.#adapter)); }
253
+ get stock_items() { return this.#stock_items || (this.#stock_items = new api.StockItems(this.#adapter)); }
254
+ get stock_line_items() { return this.#stock_line_items || (this.#stock_line_items = new api.StockLineItems(this.#adapter)); }
255
+ get stock_locations() { return this.#stock_locations || (this.#stock_locations = new api.StockLocations(this.#adapter)); }
256
+ get stock_reservations() { return this.#stock_reservations || (this.#stock_reservations = new api.StockReservations(this.#adapter)); }
257
+ get stock_transfers() { return this.#stock_transfers || (this.#stock_transfers = new api.StockTransfers(this.#adapter)); }
258
+ get stripe_gateways() { return this.#stripe_gateways || (this.#stripe_gateways = new api.StripeGateways(this.#adapter)); }
259
+ get stripe_payments() { return this.#stripe_payments || (this.#stripe_payments = new api.StripePayments(this.#adapter)); }
260
+ get subscription_models() { return this.#subscription_models || (this.#subscription_models = new api.SubscriptionModels(this.#adapter)); }
261
+ get tags() { return this.#tags || (this.#tags = new api.Tags(this.#adapter)); }
262
+ get tax_calculators() { return this.#tax_calculators || (this.#tax_calculators = new api.TaxCalculators(this.#adapter)); }
263
+ get tax_categories() { return this.#tax_categories || (this.#tax_categories = new api.TaxCategories(this.#adapter)); }
264
+ get tax_rules() { return this.#tax_rules || (this.#tax_rules = new api.TaxRules(this.#adapter)); }
265
+ get taxjar_accounts() { return this.#taxjar_accounts || (this.#taxjar_accounts = new api.TaxjarAccounts(this.#adapter)); }
266
+ get transactions() { return this.#transactions || (this.#transactions = new api.Transactions(this.#adapter)); }
267
+ get versions() { return this.#versions || (this.#versions = new api.Versions(this.#adapter)); }
268
+ get voids() { return this.#voids || (this.#voids = new api.Voids(this.#adapter)); }
269
+ get webhooks() { return this.#webhooks || (this.#webhooks = new api.Webhooks(this.#adapter)); }
270
+ get wire_transfers() { return this.#wire_transfers || (this.#wire_transfers = new api.WireTransfers(this.#adapter)); }
271
+ // ##__CL_RESOURCES_LEAZY_LOADING_STOP__##
272
+ get currentOrganization() { return this.#slug; }
270
273
  // get currentAccessToken(): string { return this.#adapter?.clientInstance?.currentAccessToken}
271
274
  // get environment(): ApiMode { return this.#environment }
275
+ get interceptors() { return this.#adapter.client.interceptors; }
272
276
  localConfig(config) {
273
277
  if (config.organization)
274
- this.#organization = config.organization;
278
+ this.#slug = config.organization;
275
279
  }
276
280
  config(config) {
277
281
  debug('config %o', config);
@@ -293,39 +297,45 @@ class CommerceLayerClient {
293
297
  isSingleton(resource) {
294
298
  return CommerceLayerStatic.isSingleton(resource);
295
299
  }
296
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
297
300
  isApiError(error) {
298
301
  return CommerceLayerStatic.isApiError(error);
299
302
  }
300
- addRequestInterceptor(onFulfilled, onRejected) {
301
- return this.#adapter.interceptors.request.use(onFulfilled, onRejected);
303
+ addRequestInterceptor(onSuccess, onFailure) {
304
+ this.interceptors.request = { onSuccess, onFailure };
302
305
  }
303
- addResponseInterceptor(onFulfilled, onRejected) {
304
- return this.#adapter.interceptors.response.use(onFulfilled, onRejected);
306
+ addResponseInterceptor(onSuccess, onFailure) {
307
+ this.interceptors.response = { onSuccess, onFailure };
305
308
  }
306
- removeInterceptor(type, id) {
307
- this.#adapter.interceptors[type].eject(id);
309
+ removeInterceptor(type, id = 1) {
310
+ this.interceptors[type] = undefined;
308
311
  }
309
312
  addRawResponseReader(options) {
310
313
  const reader = {
311
314
  id: undefined,
312
315
  rawResponse: undefined,
313
316
  headers: undefined,
317
+ ok: true
314
318
  };
315
- function rawResponseInterceptor(response) {
316
- reader.rawResponse = response?.data;
317
- if (options?.headers)
318
- reader.headers = response.headers;
319
+ async function rawResponseInterceptor(response) {
320
+ reader.rawResponse = await response?.clone().json().catch(() => { });
321
+ reader.ok = response.ok;
322
+ if (options?.headers) {
323
+ const ho = {};
324
+ response.headers.forEach((value, key) => { ho[key] = value; });
325
+ reader.headers = ho;
326
+ }
319
327
  return response;
320
328
  }
321
- const interceptor = this.addResponseInterceptor(rawResponseInterceptor);
322
- reader.id = interceptor;
329
+ /* const interceptor = */ this.interceptors.rawReader = { onSuccess: rawResponseInterceptor, onFailure: rawResponseInterceptor };
330
+ reader.id = 1; // interceptor
323
331
  return reader;
324
332
  }
325
- removeRawResponseReader(reader) {
326
- const id = (typeof reader === 'number') ? reader : reader?.id;
327
- if (id && (id >= 0))
328
- this.removeInterceptor('response', id);
333
+ removeRawResponseReader( /* reader: number | RawResponseReader */) {
334
+ /*
335
+ const id = (typeof reader === 'number') ? reader : reader?.id
336
+ if (id && (id >= 0)) this.removeInterceptor('response', id)
337
+ */
338
+ this.interceptors.rawReader = undefined;
329
339
  }
330
340
  }
331
341
  const CommerceLayer = (config) => {
@@ -1,10 +1,10 @@
1
1
  declare enum ErrorType {
2
- CLIENT = "client",// Error instantiating the client
2
+ CLIENT = "client",// Generic Client error
3
3
  REQUEST = "request",// Error preparing API request
4
4
  RESPONSE = "response",// Error response from API
5
5
  CANCEL = "cancel",// Forced request abort using interceptor
6
6
  PARSE = "parse",// Error parsing API resource
7
- GENERIC = "generic"
7
+ TIMEOUT = "timeout"
8
8
  }
9
9
  declare class SdkError extends Error {
10
10
  static NAME: string;
@@ -12,7 +12,6 @@ declare class SdkError extends Error {
12
12
  type: ErrorType;
13
13
  code?: string;
14
14
  source?: Error;
15
- request?: any;
16
15
  constructor(error: {
17
16
  message: string;
18
17
  type?: ErrorType;