cobinhood-rx
Version:
CobinhoodRx is a rxjs node wrapper for the CobinhoodRx Api.
71 lines • 3.72 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Model = require("../../Model");
const DataKeys_1 = require("../../Enum/DataKeys");
const Observable_1 = require("rxjs/Observable");
const HttpMethod_1 = require("../../Enum/HttpMethod");
const Validator_1 = require("../../Helpers/Validator");
class WalletAPI {
constructor(transportManager, config) {
this.transportManager = transportManager;
this.apiVersion = config.apiVersion;
this.baseUrl = config.baseUrl;
this.baseEndPoint = `${this.baseUrl}${this.apiVersion}/wallet`;
}
getWalletBalances() {
return this.transportManager.privateRequest(HttpMethod_1.HttpMethod.GET, `${this.baseEndPoint}/balances`)
.map(data => this.transportManager.processResponse(data, Model.Balance, DataKeys_1.DataKeyValues.Balances))
.catch(this.catchErrorHandler);
}
getLedger(currency, limit = 10) {
return this.transportManager.privateRequest(HttpMethod_1.HttpMethod.GET, `${this.baseEndPoint}/ledger`, {
currency,
limit
})
.map(data => this.transportManager.processResponse(data, Model.Ledger, DataKeys_1.DataKeyValues.Ledger))
.catch(this.catchErrorHandler);
}
getDepositAddresses(currency) {
return this.transportManager.privateRequest(HttpMethod_1.HttpMethod.GET, `${this.baseEndPoint}/deposit_addresses`, {
currency
})
.map(data => this.transportManager.processResponse(data, Model.DepositAddress, DataKeys_1.DataKeyValues.DepositAddresses))
.catch(this.catchErrorHandler);
}
getWithdrawalAddresses(currency) {
return this.transportManager.privateRequest(HttpMethod_1.HttpMethod.GET, `${this.baseEndPoint}/withdrawal_addresses`, {
currency
})
.map(data => this.transportManager.processResponse(data, Model.WithdrawalAddress, DataKeys_1.DataKeyValues.WithdrawalAddresses))
.catch(this.catchErrorHandler);
}
getDeposit(depositId) {
return this.transportManager.privateRequest(HttpMethod_1.HttpMethod.GET, `${this.baseEndPoint}/deposits/${Validator_1.default.uuid(depositId)}`)
.map(data => this.transportManager.processResponse(data, Model.Deposit, DataKeys_1.DataKeyValues.Deposit))
.catch(this.catchErrorHandler);
}
getAllDeposits() {
return this.transportManager.privateRequest(HttpMethod_1.HttpMethod.GET, `${this.baseEndPoint}/deposits`)
.map(data => this.transportManager.processResponse(data, Model.Deposit, DataKeys_1.DataKeyValues.AllDeposits))
.catch(this.catchErrorHandler);
}
getWithdrawal(withdrawalId) {
return this.transportManager.privateRequest(HttpMethod_1.HttpMethod.GET, `${this.baseEndPoint}/withdrawals/${Validator_1.default.uuid(withdrawalId)}`)
.map(data => this.transportManager.processResponse(data, Model.Withdrawal, DataKeys_1.DataKeyValues.Withdrawal))
.catch(this.catchErrorHandler);
}
getAllWithdrawals(currency, status, limit) {
return this.transportManager.privateRequest(HttpMethod_1.HttpMethod.GET, `${this.baseEndPoint}/withdrawals`, {
currency,
status,
limit
})
.map(data => this.transportManager.processResponse(data, Model.Withdrawal, DataKeys_1.DataKeyValues.AllWithdrawals))
.catch(this.catchErrorHandler);
}
catchErrorHandler(res) {
return Observable_1.Observable.throw(res);
}
}
exports.WalletAPI = WalletAPI;
//# sourceMappingURL=WalletAPI.js.map