UNPKG

airalo-sdk-type

Version:

UNOFFICIAL AIRALO API INTEGRATION FOR JAVASCRIPT/TYPESCRIPT

39 lines (38 loc) 1.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetBalance = void 0; const config_1 = require("../config"); const axios_master_1 = require("axios-master"); const auth_1 = require("./auth"); // Дансны үлдэгдлийг авах const GetBalance = async () => { try { const result = await (0, axios_master_1.axiosMasterLogger)({ method: "GET", url: `${config_1.config.host}/v2/balance`, headers: { Accept: "application/json", Authorization: `Bearer ${config_1.config.token}` } }, { name: "GetBalance", timeout: 20000, retryFunction: auth_1.getToken, shouldRetry: true, shouldRetryStatus: [401], logger: (data) => config_1.config.logger && console.log("GetBalance:", data.json) }); return { success: true, data: result.data ?? null, message: "Амжилттай." }; } catch (error) { const axiosError = error; console.error("GetBalance амжилтгүй:", axiosError.message); return { success: false, data: null, message: axiosError?.response?.data?.meta?.message ?? "Алдаа гарлаа." }; } }; exports.GetBalance = GetBalance; exports.default = { GetBalance: exports.GetBalance };