UNPKG

@binance/pay

Version:

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

337 lines (329 loc) 13 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name2 in all) __defProp(target, name2, { get: all[name2], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var index_exports = {}; __export(index_exports, { BadRequestError: () => import_common4.BadRequestError, ConnectorClientError: () => import_common4.ConnectorClientError, ForbiddenError: () => import_common4.ForbiddenError, NetworkError: () => import_common4.NetworkError, NotFoundError: () => import_common4.NotFoundError, PAY_REST_API_PROD_URL: () => import_common4.PAY_REST_API_PROD_URL, Pay: () => Pay, PayRestAPI: () => rest_api_exports, RateLimitBanError: () => import_common4.RateLimitBanError, RequiredError: () => import_common4.RequiredError, ServerError: () => import_common4.ServerError, TooManyRequestsError: () => import_common4.TooManyRequestsError, UnauthorizedError: () => import_common4.UnauthorizedError }); module.exports = __toCommonJS(index_exports); // src/pay.ts var import_common3 = require("@binance/common"); // package.json var name = "@binance/pay"; var version = "3.0.7"; // src/rest-api/index.ts var rest_api_exports = {}; __export(rest_api_exports, { PayApi: () => PayApi, RestAPI: () => RestAPI }); // src/rest-api/modules/pay-api.ts var import_common = require("@binance/common"); var PayApiAxiosParamCreator = function(configuration) { return { /** * 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, accountId * 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, accountId * receiverInfo : binanceId * Sender's perspective when orderType is PAY * payerInfo : binanceId * receiverInfo : name * Receiver's perspective when orderType is PAY * payerInfo : name, accountId * 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 {number} [startTime] * @param {number} [endTime] * @param {number} [limit] default 100, max 100 * @param {number} [recvWindow] * * @throws {RequiredError} */ getPayTradeHistory: async (startTime, endTime, limit, recvWindow) => { const localVarQueryParameter = {}; 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", params: localVarQueryParameter, timeUnit: _timeUnit }; } }; }; 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, accountId * 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, accountId * receiverInfo : binanceId * Sender's perspective when orderType is PAY * payerInfo : binanceId * receiverInfo : name * Receiver's perspective when orderType is PAY * payerInfo : name, accountId * 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, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } }; // src/rest-api/rest-api.ts var import_common2 = require("@binance/common"); 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 params - Query parameters for the request. * * @returns A promise resolving to the response data object. */ sendRequest(endpoint, method, params = {}) { return (0, import_common2.sendRequest)(this.configuration, endpoint, method, params, 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 params - Query parameters for the request. * * @returns A promise resolving to the response data object. */ sendSignedRequest(endpoint, method, params = {}) { return (0, import_common2.sendRequest)(this.configuration, endpoint, method, params, 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, accountId * 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, accountId * receiverInfo : binanceId * Sender's perspective when orderType is PAY * payerInfo : binanceId * receiverInfo : name * Receiver's perspective when orderType is PAY * payerInfo : name, accountId * 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); } }; // src/pay.ts var Pay = class { constructor(config) { const userAgent = (0, import_common3.buildUserAgent)(name, version); if (config?.configurationRestAPI) { const configRestAPI = new import_common3.ConfigurationRestAPI( config.configurationRestAPI ); configRestAPI.basePath = configRestAPI.basePath || import_common3.PAY_REST_API_PROD_URL; configRestAPI.baseOptions = configRestAPI.baseOptions || {}; configRestAPI.baseOptions.headers = { ...configRestAPI.baseOptions.headers || {}, "User-Agent": userAgent }; this.restAPI = new RestAPI(configRestAPI); } } }; // src/index.ts var import_common4 = require("@binance/common"); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { BadRequestError, ConnectorClientError, ForbiddenError, NetworkError, NotFoundError, PAY_REST_API_PROD_URL, Pay, PayRestAPI, RateLimitBanError, RequiredError, ServerError, TooManyRequestsError, UnauthorizedError }); //# sourceMappingURL=index.js.map