UNPKG

@yeepay/yop-typescript-sdk

Version:

TypeScript SDK for interacting with YOP (YeePay Open Platform)

31 lines (30 loc) 1.71 kB
import type { YopConfig, YopRequestOptions, ContentType, YopResponse } from "./types.js"; /** * YopClient provides methods for interacting with the repay Open Platform (YOP) API. * It handles request signing, response verification, and configuration management. * * The client can be configured either through an explicit configuration object * passed to the constructor or via environment variables. */ export declare class YopClient { private readonly config; private readonly yopPublicKeyObject; private readonly timeout; /** * Creates an instance of YopClient. * ... (constructor docs remain the same) ... */ constructor(config?: YopConfig); /** * Loads and validates the configuration, merging provided config, environment variables, and defaults. * Returns the configuration containing the public key as string or Buffer. * @param config Optional configuration object provided during instantiation. * @returns The validated and merged YopConfig with publicKey as string/Buffer. * @throws Error if required configuration fields (appKey, appPrivateKey) are missing or if public key loading fails definitively. */ private _loadConfig; request<T extends YopResponse = YopResponse>(options: YopRequestOptions): Promise<T>; get<T extends YopResponse = YopResponse>(apiUrl: string, params: Record<string, unknown>, timeout?: number): Promise<T>; post<T extends YopResponse = YopResponse>(apiUrl: string, body: Record<string, unknown>, contentType?: ContentType, timeout?: number): Promise<T>; postJson<T extends YopResponse = YopResponse>(apiUrl: string, body: Record<string, unknown>, timeout?: number): Promise<T>; }