@nodeswork/applet
Version:
Nodeswork Applet Framework
207 lines (205 loc) • 6.48 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
const _ = require("underscore");
const request = require("request-promise");
const base_accounts_1 = require("./base-accounts");
const account_1 = require("../account");
const services_1 = require("../services");
let WEXAccount = class WEXAccount extends base_accounts_1.BaseAccount {
constructor($request) {
super($request);
this.$request = $request;
}
async getInfo() {
return (await this.$operate({
name: 'getInfo',
ref: 'getInfo',
method: 'GET',
})).return;
}
async trade(options) {
return (await this.$operate({
name: 'trade',
ref: 'Trade',
method: 'POST',
body: _.pick(options, 'pair', 'type', 'rate', 'amount'),
})).return;
}
async getActiveOrders(pair) {
return (await this.$operate({
name: 'getActiveOrders',
ref: 'ActiveOrders',
method: 'GET',
body: { pair },
})).return;
}
async getOrderInfo(orderId) {
return (await this.$operate({
name: 'getOrderInfo',
ref: 'OrderInfo',
method: 'GET',
body: { order_id: orderId },
})).return;
}
async cancelOrder(orderId) {
return (await this.$operate({
name: 'cancelOrder',
ref: 'CancelOrder',
method: 'POST',
body: { order_id: orderId },
})).return;
}
async getTradeHistory(options) {
return (await this.$operate({
name: 'getTradeHistory',
ref: 'TradeHistory',
method: 'GET',
body: _.pick(options, 'from', 'count', 'from_id', 'end_id', 'order', 'since', 'end', 'pair'),
})).return;
}
async getTransactionHistory(options) {
return (await this.$operate({
name: 'getTransactionHistory',
ref: 'TransHistory',
method: 'GET',
body: _.pick(options, 'from', 'count', 'from_id', 'end_id', 'order', 'since', 'end'),
})).return;
}
async getCoinDepositAddress(coinName) {
return (await this.$operate({
name: 'getCoinDepositAddress',
ref: 'CoinDepositAddress',
method: 'GET',
body: { coinName },
})).return;
}
async withdrawCoin(options) {
return (await this.$operate({
name: 'withdrawCoin',
ref: 'WithdrawCoin',
method: 'POST',
body: _.pick(options, 'coinName', 'amount', 'address'),
})).return;
}
async createCoupon(options) {
return (await this.$operate({
name: 'createCoupon',
ref: 'CreateCoupon',
method: 'POST',
body: _.pick(options, 'currency', 'amount', 'receiver'),
})).return;
}
async redeemCoupon(coupon) {
return (await this.$operate({
name: 'redeemCoupon',
ref: 'RedeemCoupon',
method: 'POST',
body: { coupon },
})).return;
}
static async getPublicInfo() {
return await request.get(wex.PUBLIC_API_PREFIX + '/info');
}
static async getPublicTicker(pairs) {
return await request.get(wex.PUBLIC_API_PREFIX + `/ticker/${pairs.join('-')}`);
}
static async getDepth(pairs) {
return await request.get(wex.PUBLIC_API_PREFIX + `/depth/${pairs.join('-')}`);
}
static async getTrades(pairs) {
return await request.get(wex.PUBLIC_API_PREFIX + `/trades/${pairs.join('-')}`);
}
};
WEXAccount = __decorate([
account_1.Account({
accountType: 'WEXAccount',
provider: 'wex',
}),
__metadata("design:paramtypes", [services_1.RequestService])
], WEXAccount);
exports.WEXAccount = WEXAccount;
var wex;
(function (wex) {
wex.PUBLIC_API_PREFIX = 'https://wex.nz/api/3';
wex.COINS = {
BTC: 'BTC',
LTC: 'LTC',
NMC: 'NMC',
NVC: 'NVC',
PPC: 'PPC',
DSH: 'DSH',
ETH: 'ETH',
BCH: 'BCH',
ZEC: 'ZEC',
};
wex.CURRENCIES = {
USD: 'USD',
EUR: 'EUR',
RUR: 'RUR',
};
wex.PAIRS = {
BTC_USD: 'btc_usd',
BTC_RUR: 'btc_rur',
BTC_EUR: 'btc_eur',
LTC_BTC: 'ltc_btc',
LTC_USD: 'ltc_usd',
LTC_RUR: 'ltc_rur',
LTC_EUR: 'ltc_eur',
NMC_BTC: 'nmc_btc',
NMC_USD: 'nmc_usd',
NVC_BTC: 'nvc_btc',
NVC_USD: 'nvc_usd',
USD_RUR: 'usd_rur',
EUR_USD: 'eur_usd',
EUR_RUR: 'eur_rur',
PPC_BTC: 'ppc_btc',
PPC_USD: 'ppc_usd',
DSH_BTC: 'dsh_btc',
DSH_USD: 'dsh_usd',
DSH_RUR: 'dsh_rur',
DSH_EUR: 'dsh_eur',
DSH_LTC: 'dsh_ltc',
DSH_ETH: 'dsh_eth',
ETH_BTC: 'eth_btc',
ETH_USD: 'eth_usd',
ETH_EUR: 'eth_eur',
ETH_LTC: 'eth_ltc',
ETH_RUR: 'eth_rur',
BCH_USD: 'bch_usd',
BCH_BTC: 'bch_btc',
ZEC_BTC: 'zec_btc',
ZEC_USD: 'zec_usd',
};
wex.ORDER_STATUS = {
ACTIVE: 0,
EXECUTED_ORDER: 1,
CANCELED: 2,
CANCELED_WITH_PARTIAL_EXECUTION: 3,
};
wex.TRANSACTION_TYPE = {
DEPOSIT: 1,
WITHDRAWAL: 2,
CREDIT: 4,
DEBIT: 5,
};
wex.TRANSACTION_STATUS = {
CANCELED_OR_FAILED: 0,
WAITING_FOR_ACCEPTANCE: 1,
SUCCESSFUL: 2,
NOT_CONFIRMED: 3,
};
wex.TRADE_TYPES = {
SELL: 'ask',
BUY: 'bid',
};
})(wex = exports.wex || (exports.wex = {}));
//# sourceMappingURL=wex-accounts.js.map