UNPKG

@binance/pay

Version:

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

323 lines (316 loc) 11.2 kB
//#region rolldown:runtime var __defProp = Object.defineProperty; var __export = (all) => { let target = {}; for (var name$1 in all) __defProp(target, name$1, { get: all[name$1], enumerable: true }); return target; }; //#endregion let __binance_common = require("@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 (0, __binance_common.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 (0, __binance_common.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 (0, __binance_common.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 = (0, __binance_common.buildUserAgent)(name, version); if (config?.configurationRestAPI) { const configRestAPI = new __binance_common.ConfigurationRestAPI(config.configurationRestAPI); configRestAPI.basePath = configRestAPI.basePath || __binance_common.PAY_REST_API_PROD_URL; configRestAPI.baseOptions = configRestAPI.baseOptions || {}; configRestAPI.baseOptions.headers = { ...configRestAPI.baseOptions.headers || {}, "User-Agent": userAgent }; this.restAPI = new RestAPI(configRestAPI); } } }; //#endregion Object.defineProperty(exports, 'BadRequestError', { enumerable: true, get: function () { return __binance_common.BadRequestError; } }); Object.defineProperty(exports, 'ConnectorClientError', { enumerable: true, get: function () { return __binance_common.ConnectorClientError; } }); Object.defineProperty(exports, 'ForbiddenError', { enumerable: true, get: function () { return __binance_common.ForbiddenError; } }); Object.defineProperty(exports, 'NetworkError', { enumerable: true, get: function () { return __binance_common.NetworkError; } }); Object.defineProperty(exports, 'NotFoundError', { enumerable: true, get: function () { return __binance_common.NotFoundError; } }); Object.defineProperty(exports, 'PAY_REST_API_PROD_URL', { enumerable: true, get: function () { return __binance_common.PAY_REST_API_PROD_URL; } }); exports.Pay = Pay; Object.defineProperty(exports, 'PayRestAPI', { enumerable: true, get: function () { return rest_api_exports; } }); Object.defineProperty(exports, 'RateLimitBanError', { enumerable: true, get: function () { return __binance_common.RateLimitBanError; } }); Object.defineProperty(exports, 'RequiredError', { enumerable: true, get: function () { return __binance_common.RequiredError; } }); Object.defineProperty(exports, 'ServerError', { enumerable: true, get: function () { return __binance_common.ServerError; } }); Object.defineProperty(exports, 'TooManyRequestsError', { enumerable: true, get: function () { return __binance_common.TooManyRequestsError; } }); Object.defineProperty(exports, 'UnauthorizedError', { enumerable: true, get: function () { return __binance_common.UnauthorizedError; } }); //# sourceMappingURL=index.js.map