UNPKG

@commercelayer/sdk

Version:
1,109 lines (1,093 loc) 821 kB
import ApiClient, { ApiClientInitConfig } from './client.cjs'; import { ObjectType, StringKey, PositiveNumberRange } from './types.cjs'; type ResourceNull = { id: null; } & ResourceType; type ResourceRel = ResourceId | ResourceNull; type Metadata = ObjectType; interface ResourceType { readonly type: ResourceTypeLock; } interface ResourceId extends ResourceType { readonly id: string; } interface ResourceBase { reference?: string | null; reference_origin?: string | null; metadata?: Metadata; } interface Resource extends ResourceBase, ResourceId { readonly created_at: string; readonly updated_at: string; } interface ResourceCreate extends ResourceBase { } interface ResourceUpdate extends ResourceBase { readonly id: string; } type ListMeta = { readonly pageCount: number; readonly recordCount: number; readonly currentPage: number; readonly recordsPerPage: number; }; declare class ListResponse<R extends Resource = Resource> extends Array<R> { readonly meta: ListMeta; constructor(meta: ListMeta, data: R[]); first(): R | undefined; last(): R | undefined; get(index: number): R | undefined; hasNextPage(): boolean; hasPrevPage(): boolean; getRecordCount(): number; getPageCount(): number; get recordCount(): number; get pageCount(): number; } type ResourceSort = Pick<Resource, 'id' | 'reference' | 'reference_origin' | 'created_at' | 'updated_at'>; type ResourceFilter = Pick<Resource, 'id' | 'reference' | 'reference_origin' | 'metadata' | 'created_at' | 'updated_at'>; type ResourceAdapterConfig = {}; type ResourcesInitConfig = ResourceAdapterConfig & ApiClientInitConfig; type ResourcesConfig = Partial<ResourcesInitConfig>; declare class ApiResourceAdapter { private static adapter; private constructor(); static init(config: ResourcesInitConfig): ResourceAdapter; static get(config?: ResourcesInitConfig): ResourceAdapter; static config(config: ResourcesConfig): void; } declare class ResourceAdapter { #private; constructor(config: ResourcesInitConfig); private localConfig; config(config: ResourcesConfig): this; get client(): Readonly<ApiClient>; singleton<R extends Resource>(resource: ResourceType, params?: QueryParamsRetrieve<R>, options?: ResourcesConfig, path?: string): Promise<R>; retrieve<R extends Resource>(resource: ResourceId, params?: QueryParamsRetrieve<R>, options?: ResourcesConfig): Promise<R>; list<R extends Resource>(resource: ResourceType, params?: QueryParamsList<R>, options?: ResourcesConfig): Promise<ListResponse<R>>; create<C extends ResourceCreate, R extends Resource>(resource: C & ResourceType, params?: QueryParamsRetrieve<R>, options?: ResourcesConfig): Promise<R>; update<U extends ResourceUpdate, R extends Resource>(resource: U & ResourceId, params?: QueryParamsRetrieve<R>, options?: ResourcesConfig): Promise<R>; delete(resource: ResourceId, options?: ResourcesConfig): Promise<void>; fetch<R extends Resource>(resource: string | ResourceType, path: string, params?: QueryParams<R>, options?: ResourcesConfig): Promise<R | ListResponse<R>>; } declare abstract class ApiResourceBase<R extends Resource> { #private; static readonly TYPE: ResourceTypeLock; constructor(adapter?: ResourceAdapter); protected get resources(): ResourceAdapter; abstract relationship(id: string | ResourceId | null): ResourceRel; protected relationshipOneToOne<RR extends ResourceRel>(id: string | ResourceId | null): RR; protected relationshipOneToMany<RR extends ResourceRel>(...ids: string[]): RR[]; abstract type(): ResourceTypeLock; protected path(): string; update(resource: ResourceUpdate, params?: QueryParamsRetrieve<R>, options?: ResourcesConfig): Promise<R>; } declare abstract class ApiResource<R extends Resource> extends ApiResourceBase<R> { retrieve(id: string | ResourceId, params?: QueryParamsRetrieve<R>, options?: ResourcesConfig): Promise<R>; list(params?: QueryParamsList<R>, options?: ResourcesConfig): Promise<ListResponse<R>>; count(filter?: QueryFilter | QueryParamsList<R>, options?: ResourcesConfig): Promise<number>; } declare abstract class ApiSingleton<R extends Resource> extends ApiResourceBase<R> { retrieve(params?: QueryParamsRetrieve<R>, options?: ResourcesConfig): Promise<R>; } declare const isResourceId: (resource: any) => resource is ResourceId; declare const isResourceType: (resource: any) => resource is ResourceType; type EventStoreType = 'event_stores'; type EventStoreRel = ResourceRel & { type: EventStoreType; }; type EventStoreSort = Pick<EventStore, 'id'> & ResourceSort; interface EventStore extends Resource { readonly type: EventStoreType; /** * The type of the affected resource. One of 'applications', 'event_stores', 'organizations', 'addresses', 'geocoders', 'events', 'tags', 'adjustments', 'price_lists', 'payment_gateways', 'payment_methods', 'markets', 'customer_groups', 'line_items', 'discount_engine_items', 'promotions', 'adyen_payments', 'orders', 'transactions', 'order_factories', 'attachments', 'tax_calculators', 'tax_categories', 'skus', 'shipping_categories', 'axerve_payments', 'order_validation_rules', 'braintree_payments', 'bundles', 'sku_lists', 'sku_list_items', 'stock_items', 'stock_locations', 'promotion_rules', 'coupons', 'returns', 'carrier_accounts', 'checkout_com_payments', 'customers', 'customer_addresses', 'customer_payment_sources', 'customer_subscriptions', 'order_subscriptions', 'customer_password_resets', 'delivery_lead_times', 'shipping_methods', 'shipments', 'discount_engines', 'pickups', 'parcels', 'webhooks', 'event_callbacks', 'external_payments', 'gift_cards', 'in_stock_subscriptions', 'inventory_models', 'inventory_stock_locations', 'inventory_return_locations', 'klarna_payments', 'line_item_options', 'return_line_items', 'stock_line_items', 'stock_reservations', 'stock_transfers', 'notifications', 'sku_options', 'links', 'tax_rules', 'merchants', 'subscription_models', 'stores', 'price_list_schedulers', 'order_subscription_items', 'payment_options', 'resource_errors', 'paypal_payments', 'packages', 'parcel_line_items', 'prices', 'price_tiers', 'reserved_stocks', 'satispay_payments', 'shipping_method_tiers', 'shipping_zones', 'stripe_payments', or 'wire_transfers'. * @example ```"orders"``` */ resource_type?: 'applications' | 'event_stores' | 'organizations' | 'addresses' | 'geocoders' | 'events' | 'tags' | 'adjustments' | 'price_lists' | 'payment_gateways' | 'payment_methods' | 'markets' | 'customer_groups' | 'line_items' | 'discount_engine_items' | 'promotions' | 'adyen_payments' | 'orders' | 'transactions' | 'order_factories' | 'attachments' | 'tax_calculators' | 'tax_categories' | 'skus' | 'shipping_categories' | 'axerve_payments' | 'order_validation_rules' | 'braintree_payments' | 'bundles' | 'sku_lists' | 'sku_list_items' | 'stock_items' | 'stock_locations' | 'promotion_rules' | 'coupons' | 'returns' | 'carrier_accounts' | 'checkout_com_payments' | 'customers' | 'customer_addresses' | 'customer_payment_sources' | 'customer_subscriptions' | 'order_subscriptions' | 'customer_password_resets' | 'delivery_lead_times' | 'shipping_methods' | 'shipments' | 'discount_engines' | 'pickups' | 'parcels' | 'webhooks' | 'event_callbacks' | 'external_payments' | 'gift_cards' | 'in_stock_subscriptions' | 'inventory_models' | 'inventory_stock_locations' | 'inventory_return_locations' | 'klarna_payments' | 'line_item_options' | 'return_line_items' | 'stock_line_items' | 'stock_reservations' | 'stock_transfers' | 'notifications' | 'sku_options' | 'links' | 'tax_rules' | 'merchants' | 'subscription_models' | 'stores' | 'price_list_schedulers' | 'order_subscription_items' | 'payment_options' | 'resource_errors' | 'paypal_payments' | 'packages' | 'parcel_line_items' | 'prices' | 'price_tiers' | 'reserved_stocks' | 'satispay_payments' | 'shipping_method_tiers' | 'shipping_zones' | 'stripe_payments' | 'wire_transfers' | null; /** * The ID of the affected resource. * @example ```"PzdJhdLdYV"``` */ resource_id?: string | null; /** * The type of change (one of create or update). * @example ```"update"``` */ event?: string | null; /** * The object changes payload. * @example ```{"status":["draft","placed"]}``` */ payload?: Record<string, any> | null; /** * Information about who triggered the change. * @example ```{"application":{"id":"DNOPYiZYpn","kind":"sales_channel","public":true},"owner":{"id":"yQQrBhLBmQ","type":"Customer"}}``` */ who?: Record<string, any> | null; } declare class EventStores extends ApiResource<EventStore> { static readonly TYPE: EventStoreType; isEventStore(resource: any): resource is EventStore; relationship(id: string | ResourceId | null): EventStoreRel; relationshipToMany(...ids: string[]): EventStoreRel[]; type(): EventStoreType; } declare const instance$22: EventStores; type AdjustmentType = 'adjustments'; type AdjustmentRel$2 = ResourceRel & { type: AdjustmentType; }; type AdjustmentSort = Pick<Adjustment, 'id' | 'name' | 'currency_code' | 'amount_cents'> & ResourceSort; interface Adjustment extends Resource { readonly type: AdjustmentType; /** * The adjustment name. * @example ```"Additional service"``` */ name: string; /** * The international 3-letter currency code as defined by the ISO 4217 standard. * @example ```"EUR"``` */ currency_code: string; /** * The adjustment amount, in cents. * @example ```1500``` */ amount_cents: number; /** * The adjustment amount, float. * @example ```15``` */ amount_float: number; /** * The adjustment amount, formatted. * @example ```"€15,00"``` */ formatted_amount: string; /** * Indicates if negative adjustment amount is distributed for tax calculation. * @example ```true``` */ distribute_discount?: boolean | null; event_stores?: EventStore[] | null; } interface AdjustmentCreate extends ResourceCreate { /** * The adjustment name. * @example ```"Additional service"``` */ name: string; /** * The international 3-letter currency code as defined by the ISO 4217 standard. * @example ```"EUR"``` */ currency_code: string; /** * The adjustment amount, in cents. * @example ```1500``` */ amount_cents: number; /** * Indicates if negative adjustment amount is distributed for tax calculation. * @example ```true``` */ distribute_discount?: boolean | null; } interface AdjustmentUpdate extends ResourceUpdate { /** * The adjustment name. * @example ```"Additional service"``` */ name?: string | null; /** * The international 3-letter currency code as defined by the ISO 4217 standard. * @example ```"EUR"``` */ currency_code?: string | null; /** * The adjustment amount, in cents. * @example ```1500``` */ amount_cents?: number | null; /** * Indicates if negative adjustment amount is distributed for tax calculation. * @example ```true``` */ distribute_discount?: boolean | null; } declare class Adjustments extends ApiResource<Adjustment> { static readonly TYPE: AdjustmentType; create(resource: AdjustmentCreate, params?: QueryParamsRetrieve<Adjustment>, options?: ResourcesConfig): Promise<Adjustment>; update(resource: AdjustmentUpdate, params?: QueryParamsRetrieve<Adjustment>, options?: ResourcesConfig): Promise<Adjustment>; delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>; event_stores(adjustmentId: string | Adjustment, params?: QueryParamsList<EventStore>, options?: ResourcesConfig): Promise<ListResponse<EventStore>>; isAdjustment(resource: any): resource is Adjustment; relationship(id: string | ResourceId | null): AdjustmentRel$2; relationshipToMany(...ids: string[]): AdjustmentRel$2[]; type(): AdjustmentType; } declare const instance$21: Adjustments; type WebhookType = 'webhooks'; type WebhookRel = ResourceRel & { type: WebhookType; }; type WebhookSort = Pick<Webhook, 'id' | 'disabled_at' | 'circuit_state' | 'circuit_failure_count'> & ResourceSort; interface Webhook extends Resource { readonly type: WebhookType; /** * Unique name for the webhook. * @example ```"myorg-orders.place"``` */ name?: string | null; /** * The identifier of the resource/event that will trigger the webhook. * @example ```"orders.place"``` */ topic: string; /** * URI where the webhook subscription should send the POST request when the event occurs. * @example ```"https://yourapp.com/webhooks"``` */ callback_url: string; /** * List of related resources that should be included in the webhook body. * @example ```["customer","shipping_address","billing_address"]``` */ include_resources?: string[] | null; /** * Time at which this resource was disabled. * @example ```"2018-01-01T12:00:00.000Z"``` */ disabled_at?: string | null; /** * The circuit breaker state, by default it is 'closed'. It can become 'open' once the number of consecutive failures overlaps the specified threshold, in such case no further calls to the failing callback are made. * @example ```"closed"``` */ circuit_state?: string | null; /** * The number of consecutive failures recorded by the circuit breaker associated to this resource, will be reset on first successful call to callback. * @example ```5``` */ circuit_failure_count?: number | null; /** * The shared secret used to sign the external request payload. * @example ```"1c0994cc4e996e8c6ee56a2198f66f3c"``` */ shared_secret: string; last_event_callbacks?: EventCallback[] | null; event_stores?: EventStore[] | null; } interface WebhookCreate extends ResourceCreate { /** * Unique name for the webhook. * @example ```"myorg-orders.place"``` */ name?: string | null; /** * The identifier of the resource/event that will trigger the webhook. * @example ```"orders.place"``` */ topic: string; /** * URI where the webhook subscription should send the POST request when the event occurs. * @example ```"https://yourapp.com/webhooks"``` */ callback_url: string; /** * List of related resources that should be included in the webhook body. * @example ```["customer","shipping_address","billing_address"]``` */ include_resources?: string[] | null; /** * Send this attribute if you want to mark this resource as disabled. * @example ```true``` */ _disable?: boolean | null; /** * Send this attribute if you want to mark this resource as enabled. * @example ```true``` */ _enable?: boolean | null; } interface WebhookUpdate extends ResourceUpdate { /** * Unique name for the webhook. * @example ```"myorg-orders.place"``` */ name?: string | null; /** * The identifier of the resource/event that will trigger the webhook. * @example ```"orders.place"``` */ topic?: string | null; /** * URI where the webhook subscription should send the POST request when the event occurs. * @example ```"https://yourapp.com/webhooks"``` */ callback_url?: string | null; /** * List of related resources that should be included in the webhook body. * @example ```["customer","shipping_address","billing_address"]``` */ include_resources?: string[] | null; /** * Send this attribute if you want to mark this resource as disabled. * @example ```true``` */ _disable?: boolean | null; /** * Send this attribute if you want to mark this resource as enabled. * @example ```true``` */ _enable?: boolean | null; /** * Send this attribute if you want to reset the circuit breaker associated to this resource to 'closed' state and zero failures count. Cannot be passed by sales channels. * @example ```true``` */ _reset_circuit?: boolean | null; } declare class Webhooks extends ApiResource<Webhook> { static readonly TYPE: WebhookType; create(resource: WebhookCreate, params?: QueryParamsRetrieve<Webhook>, options?: ResourcesConfig): Promise<Webhook>; update(resource: WebhookUpdate, params?: QueryParamsRetrieve<Webhook>, options?: ResourcesConfig): Promise<Webhook>; delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>; last_event_callbacks(webhookId: string | Webhook, params?: QueryParamsList<EventCallback>, options?: ResourcesConfig): Promise<ListResponse<EventCallback>>; event_stores(webhookId: string | Webhook, params?: QueryParamsList<EventStore>, options?: ResourcesConfig): Promise<ListResponse<EventStore>>; _disable(id: string | Webhook, params?: QueryParamsRetrieve<Webhook>, options?: ResourcesConfig): Promise<Webhook>; _enable(id: string | Webhook, params?: QueryParamsRetrieve<Webhook>, options?: ResourcesConfig): Promise<Webhook>; _reset_circuit(id: string | Webhook, params?: QueryParamsRetrieve<Webhook>, options?: ResourcesConfig): Promise<Webhook>; isWebhook(resource: any): resource is Webhook; relationship(id: string | ResourceId | null): WebhookRel; relationshipToMany(...ids: string[]): WebhookRel[]; type(): WebhookType; } declare const instance$20: Webhooks; type EventCallbackType = 'event_callbacks'; type EventCallbackRel = ResourceRel & { type: EventCallbackType; }; type EventCallbackSort = Pick<EventCallback, 'id' | 'response_code' | 'response_message'> & ResourceSort; interface EventCallback extends Resource { readonly type: EventCallbackType; /** * The URI of the callback, inherited by the associated webhook. * @example ```"https://yourapp.com/webhooks"``` */ callback_url: string; /** * The payload sent to the callback endpoint, including the event affected resource and the specified includes. * @example ```{"data":{"attributes":{"id":"PYWehaoXJj","type":"orders"}}}``` */ payload?: Record<string, any> | null; /** * The HTTP response code of the callback endpoint. * @example ```"200"``` */ response_code?: string | null; /** * The HTTP response message of the callback endpoint. * @example ```"OK"``` */ response_message?: string | null; webhook?: Webhook | null; event_stores?: EventStore[] | null; } declare class EventCallbacks extends ApiResource<EventCallback> { static readonly TYPE: EventCallbackType; webhook(eventCallbackId: string | EventCallback, params?: QueryParamsRetrieve<Webhook>, options?: ResourcesConfig): Promise<Webhook>; event_stores(eventCallbackId: string | EventCallback, params?: QueryParamsList<EventStore>, options?: ResourcesConfig): Promise<ListResponse<EventStore>>; isEventCallback(resource: any): resource is EventCallback; relationship(id: string | ResourceId | null): EventCallbackRel; relationshipToMany(...ids: string[]): EventCallbackRel[]; type(): EventCallbackType; } declare const instance$1$: EventCallbacks; type EventType = 'events'; type EventRel = ResourceRel & { type: EventType; }; type EventSort = Pick<Event, 'id' | 'name'> & ResourceSort; interface Event extends Resource { readonly type: EventType; /** * The event's internal name. * @example ```"orders.create"``` */ name: string; webhooks?: Webhook[] | null; last_event_callbacks?: EventCallback[] | null; event_stores?: EventStore[] | null; } interface EventUpdate extends ResourceUpdate { /** * Send this attribute if you want to force webhooks execution for this event. Cannot be passed by sales channels. * @example ```true``` */ _trigger?: boolean | null; } declare class Events extends ApiResource<Event> { static readonly TYPE: EventType; update(resource: EventUpdate, params?: QueryParamsRetrieve<Event>, options?: ResourcesConfig): Promise<Event>; webhooks(eventId: string | Event, params?: QueryParamsList<Webhook>, options?: ResourcesConfig): Promise<ListResponse<Webhook>>; last_event_callbacks(eventId: string | Event, params?: QueryParamsList<EventCallback>, options?: ResourcesConfig): Promise<ListResponse<EventCallback>>; event_stores(eventId: string | Event, params?: QueryParamsList<EventStore>, options?: ResourcesConfig): Promise<ListResponse<EventStore>>; _trigger(id: string | Event, params?: QueryParamsRetrieve<Event>, options?: ResourcesConfig): Promise<Event>; isEvent(resource: any): resource is Event; relationship(id: string | ResourceId | null): EventRel; relationshipToMany(...ids: string[]): EventRel[]; type(): EventType; } declare const instance$1_: Events; type ExternalTaxCalculatorType = 'external_tax_calculators'; type ExternalTaxCalculatorRel$2 = ResourceRel & { type: ExternalTaxCalculatorType; }; type ExternalTaxCalculatorSort = Pick<ExternalTaxCalculator, 'id' | 'name' | 'circuit_state' | 'circuit_failure_count'> & ResourceSort; interface ExternalTaxCalculator extends Resource { readonly type: ExternalTaxCalculatorType; /** * The tax calculator's internal name. * @example ```"Personal tax calculator"``` */ name: string; /** * The circuit breaker state, by default it is 'closed'. It can become 'open' once the number of consecutive failures overlaps the specified threshold, in such case no further calls to the failing callback are made. * @example ```"closed"``` */ circuit_state?: string | null; /** * The number of consecutive failures recorded by the circuit breaker associated to this resource, will be reset on first successful call to callback. * @example ```5``` */ circuit_failure_count?: number | null; /** * The shared secret used to sign the external request payload. * @example ```"1c0994cc4e996e8c6ee56a2198f66f3c"``` */ shared_secret: string; /** * List of related resources that will be included in the request to the external callback. Please do consult the documentation to check on which resource the includes are related (i.e. the order) and the defaults in case no list is provided. * @example ```["order.line_item_options"]``` */ external_includes?: string[] | null; /** * The URL to the service that will compute the taxes. * @example ```"https://external_calculator.yourbrand.com"``` */ tax_calculator_url: string; markets?: Market[] | null; attachments?: Attachment[] | null; events?: Event[] | null; event_stores?: EventStore[] | null; } interface ExternalTaxCalculatorCreate extends ResourceCreate { /** * The tax calculator's internal name. * @example ```"Personal tax calculator"``` */ name: string; /** * List of related resources that will be included in the request to the external callback. Please do consult the documentation to check on which resource the includes are related (i.e. the order) and the defaults in case no list is provided. * @example ```["order.line_item_options"]``` */ external_includes?: string[] | null; /** * The URL to the service that will compute the taxes. * @example ```"https://external_calculator.yourbrand.com"``` */ tax_calculator_url: string; } interface ExternalTaxCalculatorUpdate extends ResourceUpdate { /** * The tax calculator's internal name. * @example ```"Personal tax calculator"``` */ name?: string | null; /** * Send this attribute if you want to reset the circuit breaker associated to this resource to 'closed' state and zero failures count. Cannot be passed by sales channels. * @example ```true``` */ _reset_circuit?: boolean | null; /** * List of related resources that will be included in the request to the external callback. Please do consult the documentation to check on which resource the includes are related (i.e. the order) and the defaults in case no list is provided. * @example ```["order.line_item_options"]``` */ external_includes?: string[] | null; /** * The URL to the service that will compute the taxes. * @example ```"https://external_calculator.yourbrand.com"``` */ tax_calculator_url?: string | null; } declare class ExternalTaxCalculators extends ApiResource<ExternalTaxCalculator> { static readonly TYPE: ExternalTaxCalculatorType; create(resource: ExternalTaxCalculatorCreate, params?: QueryParamsRetrieve<ExternalTaxCalculator>, options?: ResourcesConfig): Promise<ExternalTaxCalculator>; update(resource: ExternalTaxCalculatorUpdate, params?: QueryParamsRetrieve<ExternalTaxCalculator>, options?: ResourcesConfig): Promise<ExternalTaxCalculator>; delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>; markets(externalTaxCalculatorId: string | ExternalTaxCalculator, params?: QueryParamsList<Market>, options?: ResourcesConfig): Promise<ListResponse<Market>>; attachments(externalTaxCalculatorId: string | ExternalTaxCalculator, params?: QueryParamsList<Attachment>, options?: ResourcesConfig): Promise<ListResponse<Attachment>>; events(externalTaxCalculatorId: string | ExternalTaxCalculator, params?: QueryParamsList<Event>, options?: ResourcesConfig): Promise<ListResponse<Event>>; event_stores(externalTaxCalculatorId: string | ExternalTaxCalculator, params?: QueryParamsList<EventStore>, options?: ResourcesConfig): Promise<ListResponse<EventStore>>; _reset_circuit(id: string | ExternalTaxCalculator, params?: QueryParamsRetrieve<ExternalTaxCalculator>, options?: ResourcesConfig): Promise<ExternalTaxCalculator>; isExternalTaxCalculator(resource: any): resource is ExternalTaxCalculator; relationship(id: string | ResourceId | null): ExternalTaxCalculatorRel$2; relationshipToMany(...ids: string[]): ExternalTaxCalculatorRel$2[]; type(): ExternalTaxCalculatorType; } declare const instance$1Z: ExternalTaxCalculators; type TaxRuleType = 'tax_rules'; type TaxRuleRel$1 = ResourceRel & { type: TaxRuleType; }; type ManualTaxCalculatorRel$3 = ResourceRel & { type: ManualTaxCalculatorType; }; type TaxRuleSort = Pick<TaxRule, 'id' | 'name' | 'tax_rate'> & ResourceSort; interface TaxRule extends Resource { readonly type: TaxRuleType; /** * The tax rule internal name. * @example ```"Fixed 22%"``` */ name: string; /** * The tax rate for this rule. * @example ```0.22``` */ tax_rate?: number | null; /** * Indicates if the freight is taxable. */ freight_taxable?: boolean | null; /** * Indicates if the payment method is taxable. */ payment_method_taxable?: boolean | null; /** * Indicates if gift cards are taxable. */ gift_card_taxable?: boolean | null; /** * Indicates if adjustemnts are taxable. */ adjustment_taxable?: boolean | null; /** * The breakdown for this tax rule (if calculated). * @example ```{"41":{"tax_rate":0.22}}``` */ breakdown?: Record<string, any> | null; /** * The regex that will be evaluated to match the shipping address country code, max size is 5000. * @example ```"AT|BE|BG|CZ|DK|EE|DE|HU|LV|LT"``` */ country_code_regex?: string | null; /** * The regex that will be evaluated as negative match for the shipping address country code, max size is 5000. * @example ```"AT|BE|BG|CZ|DK|EE|DE"``` */ not_country_code_regex?: string | null; /** * The regex that will be evaluated to match the shipping address state code, max size is 5000. * @example ```"A[KLRZ]|C[AOT]|D[CE]|FL"``` */ state_code_regex?: string | null; /** * The regex that will be evaluated as negative match for the shipping address state code, max size is 5000. * @example ```"A[KLRZ]|C[AOT]"``` */ not_state_code_regex?: string | null; /** * The regex that will be evaluated to match the shipping address zip code, max size is 5000. * @example ```"(?i)(JE1|JE2|JE3|JE4|JE5)"``` */ zip_code_regex?: string | null; /** * The regex that will be evaluated as negative match for the shipping zip country code, max size is 5000. * @example ```"(?i)(JE1|JE2|JE3)"``` */ not_zip_code_regex?: string | null; manual_tax_calculator?: ManualTaxCalculator | null; event_stores?: EventStore[] | null; } interface TaxRuleCreate extends ResourceCreate { /** * The tax rule internal name. * @example ```"Fixed 22%"``` */ name: string; /** * The tax rate for this rule. * @example ```0.22``` */ tax_rate?: number | null; /** * Indicates if the freight is taxable. */ freight_taxable?: boolean | null; /** * Indicates if the payment method is taxable. */ payment_method_taxable?: boolean | null; /** * Indicates if gift cards are taxable. */ gift_card_taxable?: boolean | null; /** * Indicates if adjustemnts are taxable. */ adjustment_taxable?: boolean | null; /** * The regex that will be evaluated to match the shipping address country code, max size is 5000. * @example ```"AT|BE|BG|CZ|DK|EE|DE|HU|LV|LT"``` */ country_code_regex?: string | null; /** * The regex that will be evaluated as negative match for the shipping address country code, max size is 5000. * @example ```"AT|BE|BG|CZ|DK|EE|DE"``` */ not_country_code_regex?: string | null; /** * The regex that will be evaluated to match the shipping address state code, max size is 5000. * @example ```"A[KLRZ]|C[AOT]|D[CE]|FL"``` */ state_code_regex?: string | null; /** * The regex that will be evaluated as negative match for the shipping address state code, max size is 5000. * @example ```"A[KLRZ]|C[AOT]"``` */ not_state_code_regex?: string | null; /** * The regex that will be evaluated to match the shipping address zip code, max size is 5000. * @example ```"(?i)(JE1|JE2|JE3|JE4|JE5)"``` */ zip_code_regex?: string | null; /** * The regex that will be evaluated as negative match for the shipping zip country code, max size is 5000. * @example ```"(?i)(JE1|JE2|JE3)"``` */ not_zip_code_regex?: string | null; manual_tax_calculator: ManualTaxCalculatorRel$3; } interface TaxRuleUpdate extends ResourceUpdate { /** * The tax rule internal name. * @example ```"Fixed 22%"``` */ name?: string | null; /** * The tax rate for this rule. * @example ```0.22``` */ tax_rate?: number | null; /** * Indicates if the freight is taxable. */ freight_taxable?: boolean | null; /** * Indicates if the payment method is taxable. */ payment_method_taxable?: boolean | null; /** * Indicates if gift cards are taxable. */ gift_card_taxable?: boolean | null; /** * Indicates if adjustemnts are taxable. */ adjustment_taxable?: boolean | null; /** * The regex that will be evaluated to match the shipping address country code, max size is 5000. * @example ```"AT|BE|BG|CZ|DK|EE|DE|HU|LV|LT"``` */ country_code_regex?: string | null; /** * The regex that will be evaluated as negative match for the shipping address country code, max size is 5000. * @example ```"AT|BE|BG|CZ|DK|EE|DE"``` */ not_country_code_regex?: string | null; /** * The regex that will be evaluated to match the shipping address state code, max size is 5000. * @example ```"A[KLRZ]|C[AOT]|D[CE]|FL"``` */ state_code_regex?: string | null; /** * The regex that will be evaluated as negative match for the shipping address state code, max size is 5000. * @example ```"A[KLRZ]|C[AOT]"``` */ not_state_code_regex?: string | null; /** * The regex that will be evaluated to match the shipping address zip code, max size is 5000. * @example ```"(?i)(JE1|JE2|JE3|JE4|JE5)"``` */ zip_code_regex?: string | null; /** * The regex that will be evaluated as negative match for the shipping zip country code, max size is 5000. * @example ```"(?i)(JE1|JE2|JE3)"``` */ not_zip_code_regex?: string | null; manual_tax_calculator?: ManualTaxCalculatorRel$3 | null; } declare class TaxRules extends ApiResource<TaxRule> { static readonly TYPE: TaxRuleType; create(resource: TaxRuleCreate, params?: QueryParamsRetrieve<TaxRule>, options?: ResourcesConfig): Promise<TaxRule>; update(resource: TaxRuleUpdate, params?: QueryParamsRetrieve<TaxRule>, options?: ResourcesConfig): Promise<TaxRule>; delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>; manual_tax_calculator(taxRuleId: string | TaxRule, params?: QueryParamsRetrieve<ManualTaxCalculator>, options?: ResourcesConfig): Promise<ManualTaxCalculator>; event_stores(taxRuleId: string | TaxRule, params?: QueryParamsList<EventStore>, options?: ResourcesConfig): Promise<ListResponse<EventStore>>; isTaxRule(resource: any): resource is TaxRule; relationship(id: string | ResourceId | null): TaxRuleRel$1; relationshipToMany(...ids: string[]): TaxRuleRel$1[]; type(): TaxRuleType; } declare const instance$1Y: TaxRules; type ManualTaxCalculatorType = 'manual_tax_calculators'; type ManualTaxCalculatorRel$2 = ResourceRel & { type: ManualTaxCalculatorType; }; type TaxRuleRel = ResourceRel & { type: TaxRuleType; }; type ManualTaxCalculatorSort = Pick<ManualTaxCalculator, 'id' | 'name'> & ResourceSort; interface ManualTaxCalculator extends Resource { readonly type: ManualTaxCalculatorType; /** * The tax calculator's internal name. * @example ```"Personal tax calculator"``` */ name: string; markets?: Market[] | null; attachments?: Attachment[] | null; events?: Event[] | null; event_stores?: EventStore[] | null; tax_rules?: TaxRule[] | null; } interface ManualTaxCalculatorCreate extends ResourceCreate { /** * The tax calculator's internal name. * @example ```"Personal tax calculator"``` */ name: string; tax_rules?: TaxRuleRel[] | null; } interface ManualTaxCalculatorUpdate extends ResourceUpdate { /** * The tax calculator's internal name. * @example ```"Personal tax calculator"``` */ name?: string | null; tax_rules?: TaxRuleRel[] | null; } declare class ManualTaxCalculators extends ApiResource<ManualTaxCalculator> { static readonly TYPE: ManualTaxCalculatorType; create(resource: ManualTaxCalculatorCreate, params?: QueryParamsRetrieve<ManualTaxCalculator>, options?: ResourcesConfig): Promise<ManualTaxCalculator>; update(resource: ManualTaxCalculatorUpdate, params?: QueryParamsRetrieve<ManualTaxCalculator>, options?: ResourcesConfig): Promise<ManualTaxCalculator>; delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>; markets(manualTaxCalculatorId: string | ManualTaxCalculator, params?: QueryParamsList<Market>, options?: ResourcesConfig): Promise<ListResponse<Market>>; attachments(manualTaxCalculatorId: string | ManualTaxCalculator, params?: QueryParamsList<Attachment>, options?: ResourcesConfig): Promise<ListResponse<Attachment>>; events(manualTaxCalculatorId: string | ManualTaxCalculator, params?: QueryParamsList<Event>, options?: ResourcesConfig): Promise<ListResponse<Event>>; event_stores(manualTaxCalculatorId: string | ManualTaxCalculator, params?: QueryParamsList<EventStore>, options?: ResourcesConfig): Promise<ListResponse<EventStore>>; tax_rules(manualTaxCalculatorId: string | ManualTaxCalculator, params?: QueryParamsList<TaxRule>, options?: ResourcesConfig): Promise<ListResponse<TaxRule>>; isManualTaxCalculator(resource: any): resource is ManualTaxCalculator; relationship(id: string | ResourceId | null): ManualTaxCalculatorRel$2; relationshipToMany(...ids: string[]): ManualTaxCalculatorRel$2[]; type(): ManualTaxCalculatorType; } declare const instance$1X: ManualTaxCalculators; type CustomerAddressType = 'customer_addresses'; type CustomerAddressRel = ResourceRel & { type: CustomerAddressType; }; type CustomerRel$8 = ResourceRel & { type: CustomerType; }; type AddressRel$5 = ResourceRel & { type: AddressType; }; type CustomerAddressSort = Pick<CustomerAddress, 'id'> & ResourceSort; interface CustomerAddress extends Resource { readonly type: CustomerAddressType; /** * Returns the associated address' name. * @example ```"John Smith, 2883 Geraldine Lane Apt.23, 10013 New York NY (US) (212) 646-338-1228"``` */ name?: string | null; /** * The email of the customer associated to the address. * @example ```"john@example.com"``` */ customer_email: string; customer?: Customer | null; address?: Address | null; events?: Event[] | null; event_stores?: EventStore[] | null; } interface CustomerAddressCreate extends ResourceCreate { /** * The email of the customer associated to the address. * @example ```"john@example.com"``` */ customer_email: string; customer: CustomerRel$8; address: AddressRel$5; } interface CustomerAddressUpdate extends ResourceUpdate { customer?: CustomerRel$8 | null; address?: AddressRel$5 | null; } declare class CustomerAddresses extends ApiResource<CustomerAddress> { static readonly TYPE: CustomerAddressType; create(resource: CustomerAddressCreate, params?: QueryParamsRetrieve<CustomerAddress>, options?: ResourcesConfig): Promise<CustomerAddress>; update(resource: CustomerAddressUpdate, params?: QueryParamsRetrieve<CustomerAddress>, options?: ResourcesConfig): Promise<CustomerAddress>; delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>; customer(customerAddressId: string | CustomerAddress, params?: QueryParamsRetrieve<Customer>, options?: ResourcesConfig): Promise<Customer>; address(customerAddressId: string | CustomerAddress, params?: QueryParamsRetrieve<Address>, options?: ResourcesConfig): Promise<Address>; events(customerAddressId: string | CustomerAddress, params?: QueryParamsList<Event>, options?: ResourcesConfig): Promise<ListResponse<Event>>; event_stores(customerAddressId: string | CustomerAddress, params?: QueryParamsList<EventStore>, options?: ResourcesConfig): Promise<ListResponse<EventStore>>; isCustomerAddress(resource: any): resource is CustomerAddress; relationship(id: string | ResourceId | null): CustomerAddressRel; relationshipToMany(...ids: string[]): CustomerAddressRel[]; type(): CustomerAddressType; } declare const instance$1W: CustomerAddresses; type CustomerGroupType = 'customer_groups'; type CustomerGroupRel$3 = ResourceRel & { type: CustomerGroupType; }; type CustomerGroupSort = Pick<CustomerGroup, 'id' | 'name' | 'code'> & ResourceSort; interface CustomerGroup extends Resource { readonly type: CustomerGroupType; /** * The customer group's internal name. * @example ```"VIP"``` */ name: string; /** * A string that you can use to identify the customer group (must be unique within the environment). * @example ```"vip1"``` */ code?: string | null; customers?: Customer[] | null; markets?: Market[] | null; attachments?: Attachment[] | null; event_stores?: EventStore[] | null; } interface CustomerGroupCreate extends ResourceCreate { /** * The customer group's internal name. * @example ```"VIP"``` */ name: string; /** * A string that you can use to identify the customer group (must be unique within the environment). * @example ```"vip1"``` */ code?: string | null; } interface CustomerGroupUpdate extends ResourceUpdate { /** * The customer group's internal name. * @example ```"VIP"``` */ name?: string | null; /** * A string that you can use to identify the customer group (must be unique within the environment). * @example ```"vip1"``` */ code?: string | null; } declare class CustomerGroups extends ApiResource<CustomerGroup> { static readonly TYPE: CustomerGroupType; create(resource: CustomerGroupCreate, params?: QueryParamsRetrieve<CustomerGroup>, options?: ResourcesConfig): Promise<CustomerGroup>; update(resource: CustomerGroupUpdate, params?: QueryParamsRetrieve<CustomerGroup>, options?: ResourcesConfig): Promise<CustomerGroup>; delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>; customers(customerGroupId: string | CustomerGroup, params?: QueryParamsList<Customer>, options?: ResourcesConfig): Promise<ListResponse<Customer>>; markets(customerGroupId: string | CustomerGroup, params?: QueryParamsList<Market>, options?: ResourcesConfig): Promise<ListResponse<Market>>; attachments(customerGroupId: string | CustomerGroup, params?: QueryParamsList<Attachment>, options?: ResourcesConfig): Promise<ListResponse<Attachment>>; event_stores(customerGroupId: string | CustomerGroup, params?: QueryParamsList<EventStore>, options?: ResourcesConfig): Promise<ListResponse<EventStore>>; isCustomerGroup(resource: any): resource is CustomerGroup; relationship(id: string | ResourceId | null): CustomerGroupRel$3; relationshipToMany(...ids: string[]): CustomerGroupRel$3[]; type(): CustomerGroupType; } declare const instance$1V: CustomerGroups; type MerchantType = 'merchants'; type MerchantRel$3 = ResourceRel & { type: MerchantType; }; type AddressRel$4 = ResourceRel & { type: AddressType; }; type MerchantSort = Pick<Merchant, 'id' | 'name'> & ResourceSort; interface Merchant extends Resource { readonly type: MerchantType; /** * The merchant's internal name. * @example ```"The Brand Inc."``` */ name: string; address?: Address | null; attachments?: Attachment[] | null; event_stores?: EventStore[] | null; } interface MerchantCreate extends ResourceCreate { /** * The merchant's internal name. * @example ```"The Brand Inc."``` */ name: string; address: AddressRel$4; } interface MerchantUpdate extends ResourceUpdate { /** * The merchant's internal name. * @example ```"The Brand Inc."``` */ name?: string | null; address?: AddressRel$4 | null; } declare class Merchants extends ApiResource<Merchant> { static readonly TYPE: MerchantType; create(resource: MerchantCreate, params?: QueryParamsRetrieve<Merchant>, options?: ResourcesConfig): Promise<Merchant>; update(resource: MerchantUpdate, params?: QueryParamsRetrieve<Merchant>, options?: ResourcesConfig): Promise<Merchant>; delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>; address(merchantId: string | Merchant, params?: QueryParamsRetrieve<Address>, options?: ResourcesConfig): Promise<Address>; attachments(merchantId: string | Merchant, params?: QueryParamsList<Attachment>, options?: ResourcesConfig): Promise<ListResponse<Attachment>>; event_stores(merchantId: string | Merchant, params?: QueryParamsList<EventStore>, options?: ResourcesConfig): Promise<ListResponse<EventStore>>; isMerchant(resource: any): resource is Merchant; relationship(id: string | ResourceId | null): MerchantRel$3; relationshipToMany(...ids: string[]): MerchantRel$3[]; type(): MerchantType; } declare const instance$1U: Merchants; type InventoryStockLocationType = 'inventory_stock_locations'; type InventoryStockLocationRel$1 = ResourceRel & { type: InventoryStockLocationType; }; type StockLocationRel$a = ResourceRel & { type: StockLocationType; }; type InventoryModelRel$4 = ResourceRel & { type: InventoryModelType; }; type InventoryStockLocationSort = Pick<InventoryStockLocation, 'id' | 'priority' | 'on_hold'> & ResourceSort; interface InventoryStockLocation extends Resource { readonly type: InventoryStockLocationType; /** * The stock location priority within the associated invetory model. * @example ```1``` */ priority: number; /** * Indicates if the shipment should be put on hold if fulfilled from the associated stock location. This is useful to manage use cases like back-orders, pre-orders or personalized orders that need to be customized before being fulfilled. */ on_hold?: boolean | null; stock_location?: StockLocation | null; inventory_model?: InventoryModel | null; event_stores?: EventStore[] | null; } interface InventoryStockLocationCreate extends ResourceCreate { /** * The stock location priority within the associated invetory model. * @example ```1``` */ priority: number; /** * Indicates if the shipment should be put on hold if fulfilled from the associated stock location. This is useful to manage use cases like back-orders, pre-orders or personalized orders that need to be customized before being fulfilled. */ on_hold?: boolean | null; stock_location: StockLocationRel$a; inventory_model: InventoryModelRel$4; } interface InventoryStockLocationUpdate extends ResourceUpdate { /** * The stock location priority within the associated invetory model. * @example ```1``` */ priority?: number | null; /** * Indicates if the shipment should be put on hold if fulfilled from the associated stock location. This is useful to manage use cases like back-orders, pre-orders or personalized orders that need to be customized before being fulfilled. */ on_hold?: boolean | null; stock_location?: StockLocationRel$a | null; inventory_model?: InventoryModelRel$4 | null; } declare class InventoryStockLocations extends ApiResource<InventoryStockLocation> { static readonly TYPE: InventoryStockLocationType; create(resource: InventoryStockLocationCreate, params?: QueryParamsRetrieve<InventoryStockLocation>, options?: ResourcesConfig): Promise<InventoryStockLocation>; update(resource: InventoryStockLocationUpdate, params?: QueryParamsRetrieve<InventoryStockLocation>, options?: ResourcesConfig): Promise<InventoryStockLocation>; delete(id: string | ResourceId, options?: ResourcesConfig): Promise<void>; stock_location(inventoryStockLocationId: string | InventoryStockLocation, params?: QueryParamsRetrieve<StockLocation>, options?: ResourcesConfig): Promise<StockLocation>; inventory_model(inventoryStockLocationId: string | InventoryStockLocation, params?: QueryParamsRetrieve<InventoryModel>, options?: ResourcesConfig): Promise<InventoryModel>; event_stores(inventoryStockLocationId: string | InventoryStockLocation, params?: QueryParamsList<EventStore>, options?: ResourcesConfig): Promise<ListResponse<EventStore>>; isInventoryStockLocation(resource: any): resource is InventoryStockLocation; relationship(id: string | ResourceId | null): InventoryStockLocationRel$1; relationshipToMany(...ids: string[]): InventoryStockLocationRel$1[]; type(): InventoryStockLocationType; } declare const instance$1T: InventoryStockLocations; type InventoryModelType = 'inventory_models'; type InventoryModelRel$3 = ResourceRel & { type: InventoryModelType; }; type InventoryModelSort = Pick<InventoryModel, 'id' | 'name' | 'strategy' | 'stock_locations_cutoff' | 'stock_reservation_cutoff'> & ResourceSort; interface InventoryModel extends Resource { readonly type: InventoryModelType; /** * The inventory model's internal name. * @example ```"EU Inventory Model"``` */ name: string; /** * The inventory model's shipping strategy: one between 'no_split' (default), 'split_shipments', 'ship_from_primary' and 'ship_from_first_available_or_primary'. * @example ```"no_split"``` */ strategy?: string | null; /** * The maximum number of stock locations used for inventory computation. * @example ```3``` */ stock_locations_cutoff?: number | null; /** * The duration in seconds of the generated stock reservations. * @example ```3600``` */ stock_reservation_cutoff?: number | null; /** * Indicates if the the stock transfers must be put on hold automatically with the associated shipment. * @example ```true``` */ put_stock_transfers_on_hold?: boolean | null; /** * Indicates if the the stock will be decremented manually after the order approval. * @example ```true``` */ manual_stock_decrement?: boolean | null; inventory_stock_locations?: InventoryStockLocation[] | null; inventory_return_locations?: InventoryReturnLocation[] | null; attachments?: Attachment[] | null; event_stores?: EventStore[] | null; } interface InventoryModelCreate extends ResourceCreate { /** * The inventory model's internal name. * @example ```"EU Inventory Model"``` */ name: string; /** * The inventory model's shipping strategy: one between 'no_split' (default), 'split_shipments', 'ship_from_primary' and 'ship_from_first_available_or_primary'. * @example ```"no_split"``` */ strategy?: string | null; /** * The maximum number of stock locations used for inventory computation. * @example ```3``` */ stock_locations_cutoff?: number | null; /** * The duration in seconds of the generated stock reservations. * @example ```3600``` */ stock_reservation_cutoff?: number | null; /** * Indicates if the th