import type { TapPayConfig } from '../config/TapPayConfig'; import type { TapPayBaseResponse } from '../payments/PaymentResponse'; /** * 抽象基類,提供所有 Service 共享的功能 * * 負責 HTTP 請求處理、錯誤管理和超時控制。 * 所有 Service 類別都應繼承此類別。 */ export declare abstract class BaseService { protected readonly config: Required; /** * 建立 BaseService 實例 * * @param config - TapPay 客戶端配置 */ constructor(config: Required); /** * 向 TapPay API 發送請求 * * 將請求發送至指定的 API 端點,處理所有錯誤情況,包括: * - HTTP 錯誤(狀態碼非 2xx) * - 超時錯誤(超過配置的超時時間) * - JSON 解析錯誤 * - TapPay 回應錯誤(status !== 0) * * 請求會附上 API 密鑰作為 `x-api-key` 標頭。 * * @template T - 回應資料類型,必須包含 `status` 欄位 * @param endpoint - API 端點路徑(例如:`/tpc/payment/pay-by-prime`) * @param body - 請求 payload(將轉換為 JSON) * @returns 解析後的 TapPay API 回應 * @throws {TapPayError} 當 HTTP 請求失敗或 TapPay 回應狀態碼非 0 時 * @throws {TapPayTimeoutError} 當請求超過配置的超時時間時 * * @example * ```typescript * const response = await this.sendRequest( * '/tpc/payment/pay-by-prime', * { prime: 'token_from_frontend', amount: 100, ... } * ) * ``` */ protected sendRequest(endpoint: string, body: Record): Promise; } //# sourceMappingURL=BaseService.d.ts.map