UNPKG

@swishapp/browser

Version:

JS library to integrate Swish into a browser environment.

44 lines (43 loc) 3.07 kB
import { ApiResponse, Item, ItemControllerFindData, ItemDetail, ListControllerFindData, ListDetail, PaginatedApiResponse, SwishClientConfig } from "@swishapp/api-client"; export interface SwishApiConfig extends SwishClientConfig { loadProfile?: () => string | undefined; storeProfile?: (profile: string) => void; deleteProfile?: () => void; responseInterceptor?: (response: Response, request: Request) => Promise<void> | void; } export declare class SwishApi { private readonly cache; private readonly apiClient; private readonly config; private readonly itemsLoader; constructor(config: SwishApiConfig, cacheKeyPrefix: string); private processProfileHeader; get items(): { list: (query?: ItemControllerFindData["query"], options?: { batch?: boolean; }) => Promise<PaginatedApiResponse<Item>>; findById: (itemId: string) => Promise<ApiResponse<ItemDetail>>; create: (items: import("@swishapp/api-client").CreateItemInput) => Promise<ApiResponse<Item>>; delete: (itemIds: import("@swishapp/api-client").DeleteItemsInput["itemIds"]) => Promise<ApiResponse<unknown>>; updateById: (itemId: string, body: import("@swishapp/api-client").UpdateItemInput) => Promise<ApiResponse<Item>>; deleteById: (itemId: string) => Promise<ApiResponse<unknown>>; setListsById: (itemId: string, listIds: import("@swishapp/api-client").SetItemListsInput["listIds"]) => Promise<ApiResponse<ItemDetail>>; count: () => Promise<ApiResponse<import("@swishapp/api-client").ItemCount>>; }; get lists(): { list: (query?: ListControllerFindData["query"]) => Promise<PaginatedApiResponse<ListDetail>>; findById: (listId: string) => Promise<ApiResponse<ListDetail>>; create: (list: import("@swishapp/api-client").CreateListInput) => Promise<ApiResponse<import("@swishapp/api-client").List>>; updateById: (listId: string, body: import("@swishapp/api-client").UpdateListInput) => Promise<ApiResponse<import("@swishapp/api-client").List>>; deleteById: (listId: string) => Promise<ApiResponse<unknown>>; orderItems: (listId: string, itemIds: import("@swishapp/api-client").SetListItemsOrderInput["itemIds"]) => Promise<ApiResponse<import("@swishapp/api-client").List>>; addItemsToList: (listId: string, itemIds: import("@swishapp/api-client").AddItemsToListInput["itemIds"]) => Promise<ApiResponse<ListDetail>>; removeItemFromList: (listId: string, itemId: string) => Promise<ApiResponse<unknown>>; }; get profiles(): { customerAccountsVersion: () => Promise<ApiResponse<import("@swishapp/api-client").AccountsVersionResult>>; createToken: (body?: import("@swishapp/api-client").CreateProfileTokenInput) => Promise<ApiResponse<import("@swishapp/api-client").CreateProfileTokenResult>>; identify: (body: import("@swishapp/api-client").IdentifyProfileInput) => Promise<ApiResponse<import("@swishapp/api-client").IdentifyProfileResult>>; }; clearCache(): Promise<void>; }