UNPKG

@commercelayer/sdk

Version:
37 lines (34 loc) 1.36 kB
import { F as Fetch, f as InterceptorManager, g as FetchResponse } from './interceptor-k15jXzf0.js'; 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; } export { type ApiClientConfig, type ApiClientInitConfig, type Method, type RefreshToken, type RequestConfig, ApiClient as default };