@umerx/umerx-blackdog-configurator-client-typescript
Advanced tools
Comparing version 0.0.31 to 0.0.32
@@ -1,3 +0,3 @@ | ||
import { Symbol as SymbolTypes, Strategy as StrategyTypes, StrategyLog as StrategyLogTypes, StrategyValue as StrategyValueTypes, Order as OrderTypes, Position as PositionTypes, StrategyTemplateSeaDogDiscountScheme as StrategyTemplateSeaDogDiscountSchemeTypes, } from '@umerx/umerx-blackdog-configurator-types-typescript'; | ||
import axios from 'axios'; | ||
import { Response as ResponseTypes, Symbol as SymbolTypes, Strategy as StrategyTypes, StrategyLog as StrategyLogTypes, StrategyValue as StrategyValueTypes, Order as OrderTypes, Position as PositionTypes, StrategyTemplateSeaDogDiscountScheme as StrategyTemplateSeaDogDiscountSchemeTypes, } from '@umerx/umerx-blackdog-configurator-types-typescript'; | ||
import axios, { AxiosError } from 'axios'; | ||
export class ClientResponseError extends Error { | ||
@@ -19,8 +19,22 @@ statusCode; | ||
async getMany(query) { | ||
const response = await axios.get(`${this.baseUrl}/?${new URLSearchParams(Object.entries(query)).toString()}`); | ||
const responseBody = SymbolTypes.SymbolGetManyResponseBodyFromRaw(response.data); | ||
if (responseBody.status !== 'success') { | ||
throw new ClientResponseError(responseBody.message, response.status, responseBody); | ||
try { | ||
const response = await axios.get(`${this.baseUrl}/?${new URLSearchParams(Object.entries(query)).toString()}`); | ||
const responseBody = SymbolTypes.SymbolGetManyResponseBodyFromRaw(response.data); | ||
if (responseBody.status !== 'success') { | ||
throw new ClientResponseError(responseBody.message, response.status, responseBody); | ||
} | ||
return responseBody; | ||
} | ||
return responseBody; | ||
catch (e) { | ||
if (e instanceof AxiosError && undefined !== e?.status) { | ||
try { | ||
const errorResponse = ResponseTypes.ResponseBaseErrorFromRaw(e?.response?.data); | ||
throw new ClientResponseError(errorResponse.message, e.status, errorResponse); | ||
} | ||
catch (e2) { | ||
throw e; | ||
} | ||
} | ||
throw e; | ||
} | ||
} | ||
@@ -27,0 +41,0 @@ async getSingle(params) { |
{ | ||
"name": "@umerx/umerx-blackdog-configurator-client-typescript", | ||
"private": false, | ||
"version": "0.0.31", | ||
"version": "0.0.32", | ||
"main": "build/index.js", | ||
@@ -6,0 +6,0 @@ "types": "build/index.d.ts", |
70928
550