Skip to content

Commit 0432f0e

Browse files
committed
refactor: rename methods
1 parent 1db170a commit 0432f0e

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

lib/client.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export class Client {
210210
*
211211
* @returns An object/dict of quotation prices of currencies, indexed by source currency code.
212212
*/
213-
getPricesHistory(params?: {
213+
getPriceHistory(params?: {
214214
from?: string;
215215
to?: string;
216216
until?: string;
@@ -246,7 +246,7 @@ export class Client {
246246
* @param {string} symbol A symbol id.
247247
* @returns The ticker's last price of a symbol.
248248
*/
249-
getTickerLastPriceOfSymbol(symbol: string): Promise<Ticker> {
249+
getTickerLastPrice(symbol: string): Promise<Ticker> {
250250
return this.get(`public/price/ticker/${symbol}`);
251251
}
252252

@@ -300,7 +300,7 @@ export class Client {
300300
*
301301
* @return A list of trades of the symbol
302302
*/
303-
getTradesOfSymbol(
303+
getTradesBySymbol(
304304
symbol: string,
305305
params?: {
306306
sort?: SORT;
@@ -350,7 +350,7 @@ export class Client {
350350
*
351351
* @return The order book of the symbol
352352
*/
353-
getOrderBookOfSymbol(symbol: string, depth?: number): Promise<OrderBook> {
353+
getOrderBook(symbol: string, depth?: number): Promise<OrderBook> {
354354
return this.get(`public/orderbook/${symbol}`, { depth });
355355
}
356356

@@ -433,7 +433,7 @@ export class Client {
433433
*
434434
* @return A list of candles of a symbol
435435
*/
436-
getCandlesOfSymbol(
436+
getCandlesBySymbol(
437437
symbol: string,
438438
params?: {
439439
period?: PERIOD;
@@ -479,7 +479,7 @@ export class Client {
479479
*
480480
* @return the spot trading balance of a currency.
481481
*/
482-
async getSpotTradingBalanceOfCurrency(currency: string): Promise<Balance> {
482+
async getSpotTradingBalance(currency: string): Promise<Balance> {
483483
const balance = await this.get(`spot/balance/${currency}`);
484484
balance.currency = currency;
485485
return balance;
@@ -774,7 +774,7 @@ export class Client {
774774
*
775775
* @return A list of wallet balances
776776
*/
777-
getWalletBalance(): Promise<Balance[]> {
777+
getWalletBalances(): Promise<Balance[]> {
778778
return this.get("wallet/balance");
779779
}
780780

@@ -789,7 +789,7 @@ export class Client {
789789
*
790790
* @return The wallet balance of the currency
791791
*/
792-
async getWalletBalanceOfCurrency(currency: string): Promise<Balance> {
792+
async getWalletBalance(currency: string): Promise<Balance> {
793793
let balance = await this.get(`wallet/balance/${currency}`);
794794
balance.currency = currency;
795795
return balance;
@@ -977,7 +977,7 @@ Accepted values: never, optionally, required
977977
}
978978

979979
/**
980-
* Get an estimate of the withdrawal fee
980+
* Get an estimate of a withdrawal fee
981981
*
982982
* Requires the "Payment information" API key Access Right.
983983
*

test/rest/market_data.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ describe("Rest client test", () => {
108108
describe("Get Prices History", () => {
109109
it("for all currencies as origin", async function () {
110110
this.timeout(0);
111-
let pricesHistory = await client.getPricesHistory({
111+
let pricesHistory = await client.getPriceHistory({
112112
to: "ETH",
113113
period: PERIOD._15_MINUTES,
114114
});
@@ -120,7 +120,7 @@ describe("Rest client test", () => {
120120
});
121121
it("for one currency pair", async function () {
122122
this.timeout(0);
123-
let pricesHistory = await client.getPricesHistory({
123+
let pricesHistory = await client.getPriceHistory({
124124
to: "ETH",
125125
from: "BTC",
126126
period: PERIOD._15_MINUTES,
@@ -149,7 +149,7 @@ describe("Rest client test", () => {
149149
describe("Get Ticker Price Of Symbol", () => {
150150
it("", async function () {
151151
this.timeout(0);
152-
let price = await client.getTickerLastPriceOfSymbol("EOSETH");
152+
let price = await client.getTickerLastPrice("EOSETH");
153153
assert(goodTickerPrice(price), "not a good ticker price");
154154
});
155155
});
@@ -179,7 +179,7 @@ describe("Rest client test", () => {
179179
describe("Get Trades of symbol", () => {
180180
it("", async function () {
181181
this.timeout(0);
182-
let trades = await client.getTradesOfSymbol("EOSETH");
182+
let trades = await client.getTradesBySymbol("EOSETH");
183183
assert(!emptyList(trades), "empty dict of trades");
184184
assert(goodList(goodPublicTrade, trades), "not good trades");
185185
});
@@ -202,7 +202,7 @@ describe("Rest client test", () => {
202202
describe("Get Order book of symbol", () => {
203203
it("", async function () {
204204
this.timeout(0);
205-
let orderBook = await client.getOrderBookOfSymbol("EOSETH");
205+
let orderBook = await client.getOrderBook("EOSETH");
206206
assert(goodOrderbook(orderBook), "not good orderbook");
207207
});
208208
});
@@ -243,7 +243,7 @@ describe("Rest client test", () => {
243243
describe("Get candles Of Symbol", () => {
244244
it("with period and limit", async function () {
245245
this.timeout(0);
246-
let candles = await client.getCandlesOfSymbol("ADAETH", {
246+
let candles = await client.getCandlesBySymbol("ADAETH", {
247247
period: PERIOD._30_MINUTES,
248248
limit: 2,
249249
});

test/rest/spot_trading.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe("spot trading", () => {
3434
describe("get spot trading balance of currency", () => {
3535
it("", async function () {
3636
this.timeout(0);
37-
let balance = await client.getSpotTradingBalanceOfCurrency("ADA");
37+
let balance = await client.getSpotTradingBalance("ADA");
3838
assert(goodBalance(balance), "not good balance");
3939
});
4040
});

test/rest/wallet_management.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
goodList,
1212
goodTransaction,
1313
} from "../test_helpers";
14+
import { Address } from "../../lib/models";
1415
const keys = require("/home/ismael/cryptomarket/keys.json");
1516

1617
describe("wallet management", () => {
@@ -25,14 +26,14 @@ describe("wallet management", () => {
2526
describe("Get wallet balance", () => {
2627
it("", async function () {
2728
this.timeout(0);
28-
let balances = await client.getWalletBalance();
29+
let balances = await client.getWalletBalances();
2930
assert(goodList(goodBalance, balances), "not good balance");
3031
});
3132
});
3233
describe("get wallet balance of currency", () => {
3334
it("", async function () {
3435
this.timeout(0);
35-
let balance = await client.getWalletBalanceOfCurrency("ADA");
36+
let balance = await client.getWalletBalance("ADA");
3637
assert(goodBalance(balance), "not good balance");
3738
});
3839
});
@@ -55,7 +56,7 @@ describe("wallet management", () => {
5556
this.timeout(0);
5657
let oldAddress = await client.getDepositCryptoAddress("EOS");
5758
let newAddres = await client.createDepositCryptoAddress("EOS");
58-
assert(oldAddress.address !== newAddres.address, "not a new address");
59+
assert(!sameAddress(oldAddress, newAddres), "not a new address");
5960
assert(goodAddress(newAddres), "not good address");
6061
});
6162
});
@@ -178,7 +179,7 @@ describe("wallet management", () => {
178179
it("", async function () {
179180
this.timeout(0);
180181
// original wallet amount
181-
let startingADAInWallet = await client.getWalletBalanceOfCurrency("ADA");
182+
let startingADAInWallet = await client.getWalletBalance("ADA");
182183
// transfer to spot
183184
let transactionID = await client.transferBetweenWalletAndExchange({
184185
source: ACCOUNT.WALLET,
@@ -198,7 +199,7 @@ describe("wallet management", () => {
198199
assert(transactionID !== "", "not good identifier of transfer to wallet");
199200

200201
// end wallet amount
201-
let endADAInWallet = await client.getWalletBalanceOfCurrency("ADA");
202+
let endADAInWallet = await client.getWalletBalance("ADA");
202203
assert(
203204
startingADAInWallet.available === endADAInWallet.available,
204205
"not good tranfer"
@@ -238,3 +239,8 @@ describe("wallet management", () => {
238239
});
239240
});
240241
});
242+
function sameAddress(oldAddress: Address, newAddres: Address) {
243+
return oldAddress.address === newAddres.address && oldAddress.currency && newAddres.currency
244+
&& oldAddress.payment_id === newAddres.payment_id && oldAddress.public_key === oldAddress.public_key
245+
}
246+

0 commit comments

Comments
 (0)