UNPKG

@commercelayer/sdk

Version:
39 lines (36 loc) 1.35 kB
import { F as Fetch, f as InterceptorManager, g as FetchResponse } from './interceptor-k15jXzf0.cjs'; type RequestParams = Record<string, string | number | boolean>; type RequestHeaders = Record<string, string>; type RefreshToken = (expiredToken: string) => Promise<string>; type RequestConfig = { timeout?: number; params?: RequestParams; headers?: RequestHeaders; userAgent?: string; fetch?: Fetch; refreshToken?: RefreshToken; }; type ApiConfig = { organization?: string; domain?: string; accessToken: string; }; type ApiClientInitConfig = ApiConfig & RequestConfig; type ApiClientConfig = Partial<ApiClientInitConfig>; type Method = 'GET' | 'DELETE' | 'POST' | 'PUT' | 'PATCH'; declare class ApiClient { #private; static create(options: ApiClientInitConfig): ApiClient; private constructor(); get interceptors(): InterceptorManager; get requestHeaders(): RequestHeaders; config(config: ApiClientConfig): this; userAgent(userAgent: string): this; request(method: Method, path: string, body?: any, options?: ApiClientConfig): Promise<FetchResponse>; private customHeaders; get currentAccessToken(): string; get currentOrganization(): string; } // @ts-ignore export = ApiClient; export type { ApiClientConfig, ApiClientInitConfig, Method, RefreshToken, RequestConfig };