import fs from 'fs'; import { Method, AxiosRequestConfig, AxiosInstance } from "axios"; import HttpClientInterface from "../Core/HttpClient/Contracts/HttpClientInterface"; import HttpClientMethodsMixin from '../Core/HttpClient/Mixins/HttpClientMethodsMixin'; import { LogHandler } from '../Types/global'; import HttpClientResponse from '../Core/HttpClient/HttpClientResponse'; import PresetMixin from '../Core/HttpClient/Mixins/PresetMixin'; import MerchantInterface from './Contracts/MerchantInterface'; declare class Client implements HttpClientInterface { protected merchant: MerchantInterface; protected throw: boolean; protected client: HttpClientInterface; protected defaultOptions: AxiosRequestConfig; V3_URI_PREFIXES: string[]; constructor(merchant: MerchantInterface, client: HttpClientInterface, defaultOptions?: Record); getInstance(): AxiosInstance; setInstance(instance: AxiosInstance): this; setLogger(logger: LogHandler): this; request(method: Method, url: string, payload?: AxiosRequestConfig): Promise; /** * 文件上传 * @see https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter2_1_1.shtml * @param uri 接口地址 * @param file 文件路径、文件Buffer或文件可读流 * @param meta 文件元信息,包含 filename 和 sha256 两个字段 * @param filename 文件名,必须以 .jpg、.bmp、.png 为后缀 * @returns */ uploadMedia(uri: string, file: string | fs.ReadStream | Buffer, meta?: Record, filename?: string): Promise; /** * 判断是否是V3请求 * @param url 请求地址 * @returns */ protected isV3Request(url: string): boolean; /** * 创建签名(V3) * @param method 请求方式 * @param url 请求地址 * @param payload 请求载荷 * @returns */ createSignature(method: string, url: string, payload: AxiosRequestConfig): string; /** * 创建签名(V2) * @param body 请求参数 * @returns */ protected attachLegacySignature(body: Record): Record; /** * 预设置mch_id(因nodejs不支持魔术方法,只好预先设置几个常用的方法) * @param new_mch_id * @returns */ withMchId(new_mch_id?: string): this; /** * 预设置mch_id别名(因nodejs不支持魔术方法,只好预先设置几个常用的方法) * @param new_alias * @returns */ withMchIdAs(new_alias?: string): this; } interface Client extends HttpClientMethodsMixin, PresetMixin { } export = Client;