Skip to content

Commit

Permalink
Merge pull request #24 from coinsambacom/fix/isistrade-null-response
Browse files Browse the repository at this point in the history
Fix: isistrade return can be null
  • Loading branch information
itxtoledo authored Mar 30, 2024
2 parents 48d8dd0 + 7f38085 commit 0136719
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@coinsamba/js-exchanges-connector",
"description": "Collection of JavaScript implementations of cryptocurrency exchange APIs",
"version": "2.1.16",
"version": "2.1.17",
"repository": "[email protected]:coinsambacom/js-exchanges-connector.git",
"author": "Gustavo <[email protected]>",
"license": "MIT",
Expand Down
26 changes: 14 additions & 12 deletions src/connectors/isistrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { parseBRLNumberString } from "../utils/utils";
interface BaseRes<T> {
success: boolean;
message: string;
result: T;
result: T | null;
}

interface IsisTradeOrderbookOrder {
Expand Down Expand Up @@ -49,15 +49,17 @@ export class isistrade<T = any> extends Exchange<T> {
>
>(`${this.baseUrl}/public/marketsummaries?basemarket=${quote}`);

return res.result.map((t) => ({
exchangeId: this.id,
base: t.marketAsset,
quote: t.baseAsset,
ask: parseBRLNumberString(t.ask),
bid: parseBRLNumberString(t.bid),
last: parseBRLNumberString(t.last),
vol: parseBRLNumberString(t.volume),
}));
return (
res.result?.map((t) => ({
exchangeId: this.id,
base: t.marketAsset,
quote: t.baseAsset,
ask: parseBRLNumberString(t.ask),
bid: parseBRLNumberString(t.bid),
last: parseBRLNumberString(t.last),
vol: parseBRLNumberString(t.volume),
})) ?? []
);
}

private parseOrder({
Expand All @@ -81,8 +83,8 @@ export class isistrade<T = any> extends Exchange<T> {
);

return {
asks: res.result.sell.map(this.parseOrder),
bids: res.result.buy.map(this.parseOrder),
asks: res.result?.sell.map(this.parseOrder) ?? [],
bids: res.result?.buy.map(this.parseOrder) ?? [],
};
}
}

0 comments on commit 0136719

Please sign in to comment.