UNPKG

bananas-commerce

Version:

A client for bananas-commerce with support for TypeScript

125 lines (124 loc) 5.41 kB
import { components, operations, paths } from "../types/openapi.js"; import { CamelCasedObjectKeys } from "../util/casedObjectKeys.js"; import { SiteArgs } from "../types/types.js"; import { VariableResult } from "../util/formatVariableResult.js"; import { Extension } from "../extension.js"; /** * A client for `Pos` only using public API:s. */ export declare class Pos extends Extension<"pos", paths, { siteCode: string; }> { readonly name = "pos"; /** Lists the items of the group with the specified `groupReference`. */ items(args: Items.Args): Promise<Items.Result>; checkout(args: Checkout.Args): Promise<Checkout.Result>; receipt(args: Receipt.Args): Promise<Receipt.Result>; /** Get the availability of the group with the specified `groupReference`s. */ availability(args: Availability.Args): Promise<Availability.Result>; /** * Returns additional information for the specified `items` of the cart, such as `name`, * `variant`, `total`, `error`, and `warning`. The errors or warnings can for instance be defined * if the item in question is out of stock. */ cart(args: Cart.Args): Promise<Cart.Result>; } /** @see {@link BananasCommerce.items} */ export declare namespace Items { /** @see {@link BananasCommerce.items} */ type Args = CamelCasedObjectKeys<operations["bcom_pos_rest_views_items"]["parameters"]["query"]> & SiteArgs; /** @see {@link BananasCommerce.items} */ type Result = VariableResult<{ success: Items; "invalid-args": InvalidArgs; "internal-error": InternalError; }>; /** `200` */ type Items = CamelCasedObjectKeys<components["schemas"]["ItemsResponse"]>; /** `400` */ type InvalidArgs = CamelCasedObjectKeys<components["schemas"]["ErrorDetail_str_"]>; /** `503` */ type InternalError = CamelCasedObjectKeys<components["schemas"]["ErrorDetail_str_"]>; /** * An item of the {@link Items} result of {@link BananasCommerce.items}. */ type Item = Items["items"][number]; } /** @see {@link BananasCommerce.checkout} */ export declare namespace Checkout { /** @see {@link BananasCommerce.checkout} */ type Args = CamelCasedObjectKeys<components["schemas"]["POSCheckoutRequest"]> & SiteArgs; /** @see {@link BananasCommerce.checkout} */ type Result = VariableResult<{ success: CheckoutData; "invalid-args": InvalidArgs; "not-found": NotFound; "internal-error": InternalError; }>; /** `200` */ type CheckoutData = CamelCasedObjectKeys<components["schemas"]["POSCheckoutResponse"]>; /** `201` */ type Created = CamelCasedObjectKeys<components["schemas"]["POSCheckoutResponse"]>; /** `400` */ type InvalidArgs = CamelCasedObjectKeys<components["schemas"]["ErrorDetail_LocationErrors_"]>; /** `404` */ type NotFound = CamelCasedObjectKeys<components["schemas"]["ErrorDetail_str_"]>; /** `503` */ type InternalError = CamelCasedObjectKeys<components["schemas"]["ErrorDetail_str_"]>; } /** @see {@link BananasCommerce.checkout} */ export declare namespace Receipt { /** @see {@link BananasCommerce.checkout} */ type Args = CamelCasedObjectKeys<operations["bcom_pos_rest_views_checkout_receipt"]["parameters"]["path"]> & SiteArgs; /** @see {@link BananasCommerce.checkout} */ type Result = VariableResult<{ success: Receipt; "not-found": NotFound; }>; /** `200` */ type Receipt = CamelCasedObjectKeys<components["schemas"]["CheckoutReceiptResponse"]>; /** `404` */ type NotFound = CamelCasedObjectKeys<components["schemas"]["ErrorDetail_str_"]>; } /** @see {@link BananasCommerce.availability} */ export declare namespace Availability { /** @see {@link BananasCommerce.availability} */ type Args = CamelCasedObjectKeys<operations["bcom_pos_rest_views_availability"]["parameters"]["query"]> & SiteArgs; /** @see {@link BananasCommerce.availability} */ type Result = VariableResult<{ success: AvailabilityResponse; "internal-error": InternalError; }>; /** `200` */ type AvailabilityResponse = CamelCasedObjectKeys<components["schemas"]["AvailabilityResponse"]>; /** `503` */ type InternalError = CamelCasedObjectKeys<components["schemas"]["ErrorDetail_str_"]>; } /** @see {@link BananasCommerce.cart} */ export declare namespace Cart { /** @see {@link BananasCommerce.cart} */ type Args = CamelCasedObjectKeys<components["schemas"]["CartRequest"]> & SiteArgs; /** @see {@link BananasCommerce.cart} */ type Result = VariableResult<{ success: Cart; "invalid-args": InvalidArgs; "not-found": NotFound; "internal-error": InternalError; }>; /** `200` */ type Cart = CamelCasedObjectKeys<components["schemas"]["CartResponse"]>; /** `400` */ type InvalidArgs = CamelCasedObjectKeys<components["schemas"]["ErrorDetail_LocationErrors_"]>; /** `404` */ type NotFound = CamelCasedObjectKeys<components["schemas"]["ErrorDetail_str_"]>; /** `503` */ type InternalError = CamelCasedObjectKeys<components["schemas"]["ErrorDetail_str_"]>; /** * An item passed to {@link BananasCommerce.cart}. */ type Item = Args["items"][number]; /** * An item of the {@link Cart} result of {@link BananasCommerce.cart}. */ type ResultItem = Cart["items"][number]; }