CommerceClient
Describes@ebitex/commerce-sdk 0.2.xSee the changelog:@ebitex/commerce-sdk
Methods
Section titled “Methods”cart()
Section titled “cart()”cart(
id,options):Promise<Cart|null>
The cart with every price and total worked out now, or null when it is not this shopper’s or does not exist. throwIfMissing makes that an error.
Parameters
Section titled “Parameters”string
options
Section titled “options”CartCallOptions & object
Returns
Section titled “Returns”Promise<Cart | null>
categories()
Section titled “categories()”categories(
options?):Promise<CategoryList>
The categories the store’s products use.
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”Promise<CategoryList>
createCart()
Section titled “createCart()”createCart(
input,options):Promise<Cart>
Creates an empty cart for the shopper. Its currency (one the store sells in) is fixed for its life.
Parameters
Section titled “Parameters”CreateCartInput | undefined
options
Section titled “options”Returns
Section titled “Returns”Promise<Cart>
deleteCart()
Section titled “deleteCart()”deleteCart(
id,options):Promise<void>
Deletes the cart.
Parameters
Section titled “Parameters”string
options
Section titled “options”Returns
Section titled “Returns”Promise<void>
eachPage()
Section titled “eachPage()”eachPage<
A>(query?,options?):AsyncGenerator<ProductsPage<A>,void,undefined>
Every page of a query as an async iterator. The query is captured once and replayed unchanged for each page.
Type Parameters
Section titled “Type Parameters”A = Record<string, unknown>
Parameters
Section titled “Parameters”query?
Section titled “query?”Omit<ProductsQuery, "cursor">
options?
Section titled “options?”Returns
Section titled “Returns”AsyncGenerator<ProductsPage<A>, void, undefined>
eachProduct()
Section titled “eachProduct()”eachProduct<
A>(query?,options?):AsyncGenerator<Product<A>,void,undefined>
Every product a query matches, one at a time.
Type Parameters
Section titled “Type Parameters”A = Record<string, unknown>
Parameters
Section titled “Parameters”query?
Section titled “query?”Omit<ProductsQuery, "cursor">
options?
Section titled “options?”Returns
Section titled “Returns”AsyncGenerator<Product<A>, void, undefined>
product()
Section titled “product()”product<
A>(key,options?):Promise<Product<A> |null>
One product, or null when there is none available to this key. throwIfMissing makes that an error.
Type Parameters
Section titled “Type Parameters”A = Record<string, unknown>
Parameters
Section titled “Parameters”string
options?
Section titled “options?”CallOptions & object
Returns
Section titled “Returns”Promise<Product<A> | null>
productResponse()
Section titled “productResponse()”productResponse<
A>(key,options?):Promise<ProductResponse<A>>
The primitive under product: keeps the ETag, and sends If-None-Match when given, so an unchanged product is notModified.
Type Parameters
Section titled “Type Parameters”A = Record<string, unknown>
Parameters
Section titled “Parameters”string
options?
Section titled “options?”CallOptions & object
Returns
Section titled “Returns”Promise<ProductResponse<A>>
products()
Section titled “products()”products<
A>(query?,options?):Promise<ProductsPage<A>>
One page of products.
Type Parameters
Section titled “Type Parameters”A = Record<string, unknown>
Parameters
Section titled “Parameters”query?
Section titled “query?”options?
Section titled “options?”Returns
Section titled “Returns”Promise<ProductsPage<A>>
productsByKeys()
Section titled “productsByKeys()”productsByKeys<
A>(keys,options?):Promise<ProductBatch<A>>
Up to 50 products by key in one round trip, in the order asked; the keys that are not available are in missing.
Type Parameters
Section titled “Type Parameters”A = Record<string, unknown>
Parameters
Section titled “Parameters”readonly string[]
options?
Section titled “options?”Returns
Section titled “Returns”Promise<ProductBatch<A>>
setCartAddress()
Section titled “setCartAddress()”setCartAddress(
id,addresses,options):Promise<Cart>
Sets the delivery and/or billing address: present replaces (null clears), absent is left alone. Returns the whole cart.
Parameters
Section titled “Parameters”string
addresses
Section titled “addresses”options
Section titled “options”Returns
Section titled “Returns”Promise<Cart>
setCartLine()
Section titled “setCartLine()”setCartLine(
id,sku,quantity,options):Promise<Cart>
Sets one SKU’s quantity: 1 to 99 adds or changes the line, 0 removes it. Returns the whole cart.
Parameters
Section titled “Parameters”string
string
quantity
Section titled “quantity”number
options
Section titled “options”Returns
Section titled “Returns”Promise<Cart>
setCartPromotionCodes()
Section titled “setCartPromotionCodes()”setCartPromotionCodes(
id,codes,options):Promise<Cart>
Replaces the cart’s promotion codes. They are recorded and change no price in this release. Returns the whole cart.
Parameters
Section titled “Parameters”string
readonly string[]
options
Section titled “options”Returns
Section titled “Returns”Promise<Cart>
startCheckout()
Section titled “startCheckout()”startCheckout(
id,input,options):Promise<CheckoutStarted>
Starts paying for the cart: it becomes an order awaiting payment, its stock is held for the payment window (not in test mode), and the answer carries the payment provider’s page to send the shopper to. The server prices the cart afresh, so the shopper pays what the cart shows now. A cart can start a checkout only a few times a minute.
Parameters
Section titled “Parameters”string
options
Section titled “options”Returns
Section titled “Returns”Promise<CheckoutStarted>
stock()
Section titled “stock()”stock(
skus,options?):Promise<StockResult>
Live stock for up to 50 SKUs: never cached, so it is the authority a checkout confirms against (the product reads’ availability is for display, up to a few minutes old).
Counts appear only when the key may see them; see StockItem.available. Budgeted tighter than the other reads, so call it when you need it, not on every render.
Parameters
Section titled “Parameters”readonly string[]
options?
Section titled “options?”Returns
Section titled “Returns”Promise<StockResult>
store()
Section titled “store()”store(
options?):Promise<StoreInfo>
The store this key reads: its key, name, currency and whether its prices include tax.
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”Promise<StoreInfo>