UNPKG

@binance/pay

Version:

Official Binance Pay Connector - A lightweight library that provides a convenient interface to Binance's Pay REST API.

240 lines (234 loc) 9.6 kB
import { t as __export } from "./chunk.mjs"; import { BadRequestError, ConfigurationRestAPI, ConnectorClientError, ForbiddenError, NetworkError, NotFoundError, PAY_REST_API_PROD_URL, PAY_REST_API_PROD_URL as PAY_REST_API_PROD_URL$1, RateLimitBanError, RequiredError, ServerError, TooManyRequestsError, UnauthorizedError, buildUserAgent, sendRequest } from "@binance/common"; //#region package.json var name = "@binance/pay"; var version = "5.1.1"; //#endregion //#region src/rest-api/modules/pay-api.ts /** * Binance Pay REST API * * OpenAPI Specification for the Binance Pay REST API * * The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ /** * PayApi - axios parameter creator */ const PayApiAxiosParamCreator = function(configuration) { return { getPayTradeHistory: async (startTime, endTime, limit, recvWindow) => { const localVarQueryParameter = {}; const localVarBodyParameter = {}; if (startTime !== void 0 && startTime !== null) localVarQueryParameter["startTime"] = startTime; if (endTime !== void 0 && endTime !== null) localVarQueryParameter["endTime"] = endTime; if (limit !== void 0 && limit !== null) localVarQueryParameter["limit"] = limit; if (recvWindow !== void 0 && recvWindow !== null) localVarQueryParameter["recvWindow"] = recvWindow; let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/pay/transactions", method: "GET", queryParams: localVarQueryParameter, bodyParams: localVarBodyParameter, timeUnit: _timeUnit }; } }; }; /** * PayApi - object-oriented interface * @class PayApi */ var PayApi = class { constructor(configuration) { this.configuration = configuration; this.localVarAxiosParamCreator = PayApiAxiosParamCreator(configuration); } /** * Get Pay Trade History * * If startTime and endTime are not sent, the recent 90 days' data will be returned. * The max interval between startTime and endTime is 90 days. * Support for querying orders within the last 18 months. * For payerInfo and receiverInfo,there are different return values in different orderTypes. * Sender's perspective when orderType is C2C * payerInfo : binanceId * receiverInfo : name, binanceId/accountId/email/countryCode/phoneNumber/mobileCode (based on user input) * Receiver's perspective when orderType is C2C * payerInfo : name * receiverInfo : binanceId * Sender's perspective when orderType is CRYPTO_BOX * payerInfo : binanceId * receiverInfo : name(the value is always "Crypto Box") * Receiver's perspective when orderType is CRYPTO_BOX * payerInfo : name * receiverInfo : binanceId * Sender's perspective when orderType is PAY * payerInfo : binanceId * receiverInfo : name * Receiver's perspective when orderType is PAY * payerInfo : name * receiverInfo : binanceId, name * Sender's perspective when orderType is PAY_REFUND * payerInfo : binanceId, name * receiverInfo : name, accountId * Receiver's perspective when orderType is PAY_REFUND * payerInfo : name * receiverInfo : binanceId * Sender's perspective when orderType is PAYOUT * payerInfo : binanceId, name * receiverInfo : name, accountId * Receiver's perspective when orderType is PAYOUT * payerInfo : name * receiverInfo : binanceId * Receiver's perspective when orderType is CRYPTO_BOX_RF * payerInfo : name(the value is always "Crypto Box") * receiverInfo : binanceId * Sender's perspective when orderType is REMITTANCE * payerInfo : binanceId * receiverInfo : name, institutionName, cardNumber, digitalWalletId * * Weight: 3000 * * @summary Get Pay Trade History * @param {GetPayTradeHistoryRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetPayTradeHistoryResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof PayApi * @see {@link https://developers.binance.com/docs/pay/rest-api/Get-Pay-Trade-History Binance API Documentation} */ async getPayTradeHistory(requestParameters = {}) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.getPayTradeHistory(requestParameters?.startTime, requestParameters?.endTime, requestParameters?.limit, requestParameters?.recvWindow); return sendRequest(this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.queryParams, localVarAxiosArgs.bodyParams, localVarAxiosArgs?.timeUnit, { isSigned: true }); } }; //#endregion //#region src/rest-api/rest-api.ts /** * Binance Pay REST API * * OpenAPI Specification for the Binance Pay REST API * * The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ var RestAPI = class { constructor(configuration) { this.configuration = configuration; this.payApi = new PayApi(configuration); } /** * Generic function to send a request. * @param endpoint - The API endpoint to call. * @param method - HTTP method to use (GET, POST, DELETE, etc.). * @param queryParams - Query parameters for the request. * @param bodyParams - Body parameters for the request. * * @returns A promise resolving to the response data object. */ sendRequest(endpoint, method, queryParams = {}, bodyParams = {}) { return sendRequest(this.configuration, endpoint, method, queryParams, bodyParams, void 0); } /** * Generic function to send a signed request. * @param endpoint - The API endpoint to call. * @param method - HTTP method to use (GET, POST, DELETE, etc.). * @param queryParams - Query parameters for the request. * @param bodyParams - Body parameters for the request. * * @returns A promise resolving to the response data object. */ sendSignedRequest(endpoint, method, queryParams = {}, bodyParams = {}) { return sendRequest(this.configuration, endpoint, method, queryParams, bodyParams, void 0, { isSigned: true }); } /** * Get Pay Trade History * * If startTime and endTime are not sent, the recent 90 days' data will be returned. * The max interval between startTime and endTime is 90 days. * Support for querying orders within the last 18 months. * For payerInfo and receiverInfo,there are different return values in different orderTypes. * Sender's perspective when orderType is C2C * payerInfo : binanceId * receiverInfo : name, binanceId/accountId/email/countryCode/phoneNumber/mobileCode (based on user input) * Receiver's perspective when orderType is C2C * payerInfo : name * receiverInfo : binanceId * Sender's perspective when orderType is CRYPTO_BOX * payerInfo : binanceId * receiverInfo : name(the value is always "Crypto Box") * Receiver's perspective when orderType is CRYPTO_BOX * payerInfo : name * receiverInfo : binanceId * Sender's perspective when orderType is PAY * payerInfo : binanceId * receiverInfo : name * Receiver's perspective when orderType is PAY * payerInfo : name * receiverInfo : binanceId, name * Sender's perspective when orderType is PAY_REFUND * payerInfo : binanceId, name * receiverInfo : name, accountId * Receiver's perspective when orderType is PAY_REFUND * payerInfo : name * receiverInfo : binanceId * Sender's perspective when orderType is PAYOUT * payerInfo : binanceId, name * receiverInfo : name, accountId * Receiver's perspective when orderType is PAYOUT * payerInfo : name * receiverInfo : binanceId * Receiver's perspective when orderType is CRYPTO_BOX_RF * payerInfo : name(the value is always "Crypto Box") * receiverInfo : binanceId * Sender's perspective when orderType is REMITTANCE * payerInfo : binanceId * receiverInfo : name, institutionName, cardNumber, digitalWalletId * * Weight: 3000 * * @summary Get Pay Trade History * @param {GetPayTradeHistoryRequest} requestParameters Request parameters. * * @returns {Promise<RestApiResponse<GetPayTradeHistoryResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @see {@link https://developers.binance.com/docs/pay/rest-api/Get-Pay-Trade-History Binance API Documentation} */ getPayTradeHistory(requestParameters = {}) { return this.payApi.getPayTradeHistory(requestParameters); } }; //#endregion //#region src/rest-api/index.ts var rest_api_exports = /* @__PURE__ */ __export({ PayApi: () => PayApi, RestAPI: () => RestAPI }); //#endregion //#region src/pay.ts var Pay = class { constructor(config) { const userAgent = buildUserAgent(name, version); if (config?.configurationRestAPI) { const configRestAPI = new ConfigurationRestAPI(config.configurationRestAPI); configRestAPI.basePath = configRestAPI.basePath || PAY_REST_API_PROD_URL$1; configRestAPI.baseOptions = configRestAPI.baseOptions || {}; configRestAPI.baseOptions.headers = { ...configRestAPI.baseOptions.headers || {}, "User-Agent": userAgent }; this.restAPI = new RestAPI(configRestAPI); } } }; //#endregion export { BadRequestError, ConnectorClientError, ForbiddenError, NetworkError, NotFoundError, PAY_REST_API_PROD_URL, Pay, rest_api_exports as PayRestAPI, RateLimitBanError, RequiredError, ServerError, TooManyRequestsError, UnauthorizedError }; //# sourceMappingURL=index.mjs.map