Skip to content

Commit 571451e

Browse files
committed
marketsummary returns an array, so we fix that and only return one.
1 parent eeac7f4 commit 571451e

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bittrex-typescript",
3-
"version": "2.0.4",
3+
"version": "2.1.0",
44
"description": "Bittrex client using typescript",
55
"main": "src/index.js",
66
"types": "src/index.d.ts",

src/Bittrex.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ export declare class BittrexClient implements Bittrex {
3838
currencies(): Promise<CurrencyData[]>;
3939
ticker(market: string): Promise<TickerData>;
4040
marketHistory(market: string): Promise<MarketHistoryData[]>;
41+
/**
42+
* The Bittrex API is stupid. It returns an [] of MarketSummaryData when it should only return one item, so we unwind that.
43+
*/
4144
marketSummary(market: string): Promise<MarketSummaryData>;
4245
marketSummaries(): Promise<MarketSummaryData[]>;
4346
orderBook(market: string, type: 'buy' | 'sell' | 'both'): Promise<OrderBookData | OrderBookItem[]>;

src/Bittrex.js

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Bittrex.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Bittrex.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,12 @@ export class BittrexClient implements Bittrex {
8484
return this.transport.request(MarketHistoryData, '/public/getmarkethistory', {market: market}) as Promise<MarketHistoryData[]>;
8585
}
8686

87+
/**
88+
* The Bittrex API is stupid. It returns an [] of MarketSummaryData when it should only return one item, so we unwind that.
89+
*/
8790
public async marketSummary(market: string): Promise<MarketSummaryData> {
88-
return this.transport.request(MarketSummaryData, '/public/getmarketsummary', {market: market}) as Promise<MarketSummaryData>;
91+
const promise = this.transport.request(MarketSummaryData, '/public/getmarketsummary', {market: market}) as Promise<MarketSummaryData[]>;
92+
return promise.then((result:MarketSummaryData[]) => { return result[0]; });
8993
}
9094

9195
public async marketSummaries(): Promise<MarketSummaryData[]> {

0 commit comments

Comments
 (0)