verimor-api-sdk
Version:
A NodeJS SDK for the Verimor API
50 lines • 2.26 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AccountApi = void 0;
const base_api_1 = require("./base-api");
const error_response_1 = require("../models/error-response");
/**
* AccountApi class provides methods to interact with account-related endpoints.
*/
class AccountApi extends base_api_1.BaseApi {
/**
* Creates an instance of AccountApi.
* @param username - The API username.
* @param password - The API password.
* @param proxyConfig - Optional proxy configuration.
*/
constructor(username, password, proxyConfig) {
super(username, password, proxyConfig);
}
/**
* Retrieves the account balance.
* @returns Promise resolving to BalanceResponse.
* @throws ErrorResponse if the API call fails.
*/
getBalance() {
var _a;
return __awaiter(this, void 0, void 0, function* () {
try {
// Include credentials in query parameters
const params = this.withCredentialsParams({});
const response = yield this.apiClient.get('/balance', { params });
// The API returns balance as plain text
return parseFloat(response.data);
}
catch (error) {
throw new error_response_1.ErrorResponse(((_a = error.response) === null || _a === void 0 ? void 0 : _a.data) || error.message);
}
});
}
}
exports.AccountApi = AccountApi;
//# sourceMappingURL=account-api.js.map