UNPKG

@binance/fiat

Version:

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

341 lines (333 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, FIAT_REST_API_PROD_URL: () => import_common4.FIAT_REST_API_PROD_URL, Fiat: () => Fiat, FiatRestAPI: () => rest_api_exports, ForbiddenError: () => import_common4.ForbiddenError, NetworkError: () => import_common4.NetworkError, NotFoundError: () => import_common4.NotFoundError, 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/fiat.ts var import_common3 = require("@binance/common"); // package.json var name = "@binance/fiat"; var version = "2.0.5"; // src/rest-api/index.ts var rest_api_exports = {}; __export(rest_api_exports, { FiatApi: () => FiatApi, RestAPI: () => RestAPI }); // src/rest-api/modules/fiat-api.ts var import_common = require("@binance/common"); var FiatApiAxiosParamCreator = function(configuration) { return { /** * Get Fiat Deposit/Withdraw History * * If beginTime and endTime are not sent, the recent 30-day data will be returned. * * Weight: 90000 * * @summary Get Fiat Deposit/Withdraw History (USER_DATA) * @param {string} transactionType 0-buy,1-sell * @param {number} [beginTime] * @param {number} [endTime] * @param {number} [page] default 1 * @param {number} [rows] default 100, max 500 * @param {number} [recvWindow] * * @throws {RequiredError} */ getFiatDepositWithdrawHistory: async (transactionType, beginTime, endTime, page, rows, recvWindow) => { (0, import_common.assertParamExists)("getFiatDepositWithdrawHistory", "transactionType", transactionType); const localVarQueryParameter = {}; if (transactionType !== void 0 && transactionType !== null) { localVarQueryParameter["transactionType"] = transactionType; } if (beginTime !== void 0 && beginTime !== null) { localVarQueryParameter["beginTime"] = beginTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (page !== void 0 && page !== null) { localVarQueryParameter["page"] = page; } if (rows !== void 0 && rows !== null) { localVarQueryParameter["rows"] = rows; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/fiat/orders", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; }, /** * Get Fiat Deposit/Withdraw History * * If beginTime and endTime are not sent, the recent 30-day data will be returned. * paymentMethod: Only when requesting payments history for buy (transactionType=0), response contains paymentMethod representing the way of purchase. Now we have: * Cash Balance * Credit Card * Online Banking * Bank Transfer * * Weight: 1 * * @summary Get Fiat Payments History (USER_DATA) * @param {string} transactionType 0-buy,1-sell * @param {number} [beginTime] * @param {number} [endTime] * @param {number} [page] default 1 * @param {number} [rows] default 100, max 500 * @param {number} [recvWindow] * * @throws {RequiredError} */ getFiatPaymentsHistory: async (transactionType, beginTime, endTime, page, rows, recvWindow) => { (0, import_common.assertParamExists)("getFiatPaymentsHistory", "transactionType", transactionType); const localVarQueryParameter = {}; if (transactionType !== void 0 && transactionType !== null) { localVarQueryParameter["transactionType"] = transactionType; } if (beginTime !== void 0 && beginTime !== null) { localVarQueryParameter["beginTime"] = beginTime; } if (endTime !== void 0 && endTime !== null) { localVarQueryParameter["endTime"] = endTime; } if (page !== void 0 && page !== null) { localVarQueryParameter["page"] = page; } if (rows !== void 0 && rows !== null) { localVarQueryParameter["rows"] = rows; } if (recvWindow !== void 0 && recvWindow !== null) { localVarQueryParameter["recvWindow"] = recvWindow; } let _timeUnit; if ("timeUnit" in configuration) _timeUnit = configuration.timeUnit; return { endpoint: "/sapi/v1/fiat/payments", method: "GET", params: localVarQueryParameter, timeUnit: _timeUnit }; } }; }; var FiatApi = class { constructor(configuration) { this.configuration = configuration; this.localVarAxiosParamCreator = FiatApiAxiosParamCreator(configuration); } /** * Get Fiat Deposit/Withdraw History * * If beginTime and endTime are not sent, the recent 30-day data will be returned. * * Weight: 90000 * * @summary Get Fiat Deposit/Withdraw History (USER_DATA) * @param {GetFiatDepositWithdrawHistoryRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetFiatDepositWithdrawHistoryResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof FiatApi * @see {@link https://developers.binance.com/docs/fiat/rest-api/Get-Fiat-Deposit-Withdraw-History Binance API Documentation} */ async getFiatDepositWithdrawHistory(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.getFiatDepositWithdrawHistory( requestParameters?.transactionType, requestParameters?.beginTime, requestParameters?.endTime, requestParameters?.page, requestParameters?.rows, requestParameters?.recvWindow ); return (0, import_common.sendRequest)( this.configuration, localVarAxiosArgs.endpoint, localVarAxiosArgs.method, localVarAxiosArgs.params, localVarAxiosArgs?.timeUnit, { isSigned: true } ); } /** * Get Fiat Deposit/Withdraw History * * If beginTime and endTime are not sent, the recent 30-day data will be returned. * paymentMethod: Only when requesting payments history for buy (transactionType=0), response contains paymentMethod representing the way of purchase. Now we have: * Cash Balance * Credit Card * Online Banking * Bank Transfer * * Weight: 1 * * @summary Get Fiat Payments History (USER_DATA) * @param {GetFiatPaymentsHistoryRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetFiatPaymentsHistoryResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @memberof FiatApi * @see {@link https://developers.binance.com/docs/fiat/rest-api/Get-Fiat-Payments-History Binance API Documentation} */ async getFiatPaymentsHistory(requestParameters) { const localVarAxiosArgs = await this.localVarAxiosParamCreator.getFiatPaymentsHistory( requestParameters?.transactionType, requestParameters?.beginTime, requestParameters?.endTime, requestParameters?.page, requestParameters?.rows, 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.fiatApi = new FiatApi(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 Fiat Deposit/Withdraw History * * If beginTime and endTime are not sent, the recent 30-day data will be returned. * * Weight: 90000 * * @summary Get Fiat Deposit/Withdraw History (USER_DATA) * @param {GetFiatDepositWithdrawHistoryRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetFiatDepositWithdrawHistoryResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @see {@link https://developers.binance.com/docs/fiat/rest-api/Get-Fiat-Deposit-Withdraw-History Binance API Documentation} */ getFiatDepositWithdrawHistory(requestParameters) { return this.fiatApi.getFiatDepositWithdrawHistory(requestParameters); } /** * Get Fiat Deposit/Withdraw History * * If beginTime and endTime are not sent, the recent 30-day data will be returned. * paymentMethod: Only when requesting payments history for buy (transactionType=0), response contains paymentMethod representing the way of purchase. Now we have: * Cash Balance * Credit Card * Online Banking * Bank Transfer * * Weight: 1 * * @summary Get Fiat Payments History (USER_DATA) * @param {GetFiatPaymentsHistoryRequest} requestParameters Request parameters. * @returns {Promise<RestApiResponse<GetFiatPaymentsHistoryResponse>>} * @throws {RequiredError | ConnectorClientError | UnauthorizedError | ForbiddenError | TooManyRequestsError | RateLimitBanError | ServerError | NotFoundError | NetworkError | BadRequestError} * @see {@link https://developers.binance.com/docs/fiat/rest-api/Get-Fiat-Payments-History Binance API Documentation} */ getFiatPaymentsHistory(requestParameters) { return this.fiatApi.getFiatPaymentsHistory(requestParameters); } }; // src/fiat.ts var Fiat = 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.FIAT_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, FIAT_REST_API_PROD_URL, Fiat, FiatRestAPI, ForbiddenError, NetworkError, NotFoundError, RateLimitBanError, RequiredError, ServerError, TooManyRequestsError, UnauthorizedError }); //# sourceMappingURL=index.js.map