diff --git a/include/api/Api.hpp b/include/api/Api.hpp index 3fc0c73..03d83da 100644 --- a/include/api/Api.hpp +++ b/include/api/Api.hpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -60,6 +61,7 @@ namespace kdeck std::list> GetMarketPositions(std::string_view eventTicker = ""); private: + std::string userAgent; std::string basePath; std::shared_ptr objectMapper; std::shared_ptr<_Api> _api; diff --git a/include/api/Api.hxx b/include/api/Api.hxx index dd0a333..deacf0b 100644 --- a/include/api/Api.hxx +++ b/include/api/Api.hxx @@ -35,16 +35,35 @@ namespace kdeck case 404: case 500: case 503: - auto errorResponse = response->readBodyToDto>(objectMapper.get()); + oatpp::String contentType = response->getHeaders().get("Content-Type"); - if (errorResponse->error->message) + // the MIME type could contain parameters (e.g. "application/json; charset=utf-8") + if (contentType->find("application/json") != std::string::npos) { - OATPP_LOGE("Api", "Error => %s", errorResponse->error->message->c_str()); + auto errorResponse = response->readBodyToDto>(objectMapper.get()); + + if (errorResponse->error->message) + { + OATPP_LOGE("Api", "Error => %s", errorResponse->error->message->c_str()); + } + + return errorResponse.getPtr(); } + else + { + // NOTE: It appears the API may be behind a Web Application Firewall (WAF) + // and in some cases is rejecting requests with an HTML response. We + // consider this a hard error and throw, since it violates the spec. + // Source: https://github.com/krazkidd/kdeck/issues/69 - return errorResponse.getPtr(); + oatpp::String errorBody = response->readBodyToString(); + + OATPP_LOGE("Api", "Error => (%s)\n%s", contentType->c_str(), errorBody->c_str()); + + throw std::runtime_error("Unknown API error."); + } } - throw std::runtime_error("Unknown JSON error."); + throw std::runtime_error("Unknown API error."); } } diff --git a/include/api/_Api.hpp b/include/api/_Api.hpp index e19f2d5..cb87625 100644 --- a/include/api/_Api.hpp +++ b/include/api/_Api.hpp @@ -1,6 +1,7 @@ #ifndef _API_HPP #define _API_HPP +#include "oatpp/core/Types.hpp" #include "oatpp/core/macro/codegen.hpp" #include "oatpp/parser/json/mapping/ObjectMapper.hpp" #include "oatpp/web/client/ApiClient.hpp" @@ -26,14 +27,14 @@ namespace kdeck headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("POST", "{basePath}/login", Login, PATH(String, basePath), BODY_DTO(Object, req)) + API_CALL("POST", "{basePath}/login", Login, HEADER(String, userAgent, "User-Agent"), PATH(String, basePath), BODY_DTO(Object, req)) API_CALL_HEADERS(Logout) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("POST", "{basePath}/logout", Logout, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer")) + API_CALL("POST", "{basePath}/logout", Logout, HEADER(String, userAgent, "User-Agent"), PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer")) // exchange ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// @@ -42,19 +43,19 @@ namespace kdeck { headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/exchange/announcements", GetExchangeAnnouncements, PATH(String, basePath)) + API_CALL("GET", "{basePath}/exchange/announcements", GetExchangeAnnouncements, HEADER(String, userAgent, "User-Agent"), PATH(String, basePath)) API_CALL_HEADERS(GetExchangeSchedule) { headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/exchange/schedule", GetExchangeSchedule, PATH(String, basePath)) + API_CALL("GET", "{basePath}/exchange/schedule", GetExchangeSchedule, HEADER(String, userAgent, "User-Agent"), PATH(String, basePath)) API_CALL_HEADERS(GetExchangeStatus) { headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/exchange/status", GetExchangeStatus, PATH(String, basePath)) + API_CALL("GET", "{basePath}/exchange/status", GetExchangeStatus, HEADER(String, userAgent, "User-Agent"), PATH(String, basePath)) // market /////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// @@ -64,54 +65,119 @@ namespace kdeck headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/events", GetEvents, PATH(String, basePath), BODY_DTO(Object, req)) + API_CALL( + "GET", + "{basePath}/events", + GetEvents, + HEADER(String, userAgent, "User-Agent"), + PATH(String, basePath), + QUERY(String, cursor), + QUERY(Int32, limit), + QUERY(String, status), + QUERY(String, series_ticker), + QUERY(Boolean, with_nested_markets) + ) API_CALL_HEADERS(GetEvent) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/events/{event_ticker}", GetEvent, PATH(String, basePath), PATH(String, event_ticker), BODY_DTO(Object, req)) + API_CALL( + "GET", + "{basePath}/events/{event_ticker}", + GetEvent, + HEADER(String, userAgent, "User-Agent"), + PATH(String, basePath), + PATH(String, event_ticker), + QUERY(Boolean, with_nested_markets) + ) API_CALL_HEADERS(GetMarkets) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/markets", GetMarkets, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), BODY_DTO(Object, req)) + API_CALL( + "GET", + "{basePath}/markets", + GetMarkets, + HEADER(String, userAgent, "User-Agent"), + PATH(String, basePath), + AUTHORIZATION(String, authString, "Bearer"), + QUERY(String, cursor), + QUERY(Int32, limit), + QUERY(String, event_ticker), + QUERY(String, series_ticker), + QUERY(Int64, max_close_ts), + QUERY(Int64, min_close_ts), + QUERY(String, status), + QUERY(String, tickers) + ) API_CALL_HEADERS(GetTrades) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/markets/trades", GetTrades, PATH(String, basePath), BODY_DTO(Object, req)) + API_CALL( + "GET", + "{basePath}/markets/trades", + GetTrades, + HEADER(String, userAgent, "User-Agent"), + PATH(String, basePath), + QUERY(String, cursor), + QUERY(Int32, limit), + QUERY(String, ticker), + QUERY(Int64, min_ts), + QUERY(Int64, max_ts) + ) API_CALL_HEADERS(GetMarket) { headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/markets/{ticker}", GetMarket, PATH(String, basePath), PATH(String, ticker)) + API_CALL("GET", "{basePath}/markets/{ticker}", GetMarket, HEADER(String, userAgent, "User-Agent"), PATH(String, basePath), PATH(String, ticker)) API_CALL_HEADERS(GetMarketOrderbook) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/markets/{ticker}/orderbook", GetMarketOrderbook, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), QUERY(String, ticker), BODY_DTO(Object, req)) + API_CALL( + "GET", + "{basePath}/markets/{ticker}/orderbook", + GetMarketOrderbook, + HEADER(String, userAgent, "User-Agent"), + PATH(String, basePath), + AUTHORIZATION(String, authString, "Bearer"), + QUERY(String, ticker), + QUERY(Int32, depth) + ) API_CALL_HEADERS(GetSeries) { headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/series/{series_ticker}", GetSeries, PATH(String, basePath), PATH(String, series_ticker)) + API_CALL("GET", "{basePath}/series/{series_ticker}", GetSeries, HEADER(String, userAgent, "User-Agent"), PATH(String, basePath), PATH(String, series_ticker)) API_CALL_HEADERS(GetMarketCandlesticks) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/series/{series_ticker}/markets/{ticker}/candlesticks", GetMarketCandlesticks, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), PATH(String, series_ticker), PATH(String, ticker), BODY_DTO(Object, req)) + API_CALL( + "GET", + "{basePath}/series/{series_ticker}/markets/{ticker}/candlesticks", + GetMarketCandlesticks, + HEADER(String, userAgent, "User-Agent"), + PATH(String, basePath), + AUTHORIZATION(String, authString, "Bearer"), + PATH(String, series_ticker), PATH(String, ticker), + QUERY(Int64, start_ts), + QUERY(Int64, end_ts), + QUERY(Int64, period_interval) + ) // portfolio //////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// @@ -120,70 +186,119 @@ namespace kdeck { headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/portfolio/balance", GetBalance, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer")) + API_CALL("GET", "{basePath}/portfolio/balance", GetBalance, HEADER(String, userAgent, "User-Agent"), PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer")) API_CALL_HEADERS(GetFills) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/portfolio/fills", GetFills, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), BODY_DTO(Object, req)) + API_CALL( + "GET", + "{basePath}/portfolio/fills", + GetFills, + HEADER(String, userAgent, "User-Agent"), + PATH(String, basePath), + AUTHORIZATION(String, authString, "Bearer"), + QUERY(String, ticker), + QUERY(String, order_id), + QUERY(Int64, min_ts), + QUERY(Int64, max_ts), + QUERY(Int32, limit), + QUERY(String, cursor) + ) API_CALL_HEADERS(GetOrders) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/portfolio/orders", GetOrders, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), BODY_DTO(Object, req)) + API_CALL( + "GET", + "{basePath}/portfolio/orders", + GetOrders, + HEADER(String, userAgent, "User-Agent"), + PATH(String, basePath), + AUTHORIZATION(String, authString, "Bearer"), + QUERY(String, ticker), + QUERY(String, event_ticker), + QUERY(Int64, min_ts), + QUERY(Int64, max_ts), + QUERY(String, status), + QUERY(String, cursor), + QUERY(Int32, limit) + ) API_CALL_HEADERS(CreateOrder) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("POST", "{basePath}/portfolio/orders", CreateOrder, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), BODY_DTO(Object, req)) + API_CALL("POST", "{basePath}/portfolio/orders", CreateOrder, HEADER(String, userAgent, "User-Agent"), PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), BODY_DTO(Object, req)) API_CALL_HEADERS(GetOrder) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/portfolio/orders/{order_id}", GetOrder, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), PATH(String, order_id)) + API_CALL("GET", "{basePath}/portfolio/orders/{order_id}", GetOrder, HEADER(String, userAgent, "User-Agent"), PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), PATH(String, order_id)) API_CALL_HEADERS(CancelOrder) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("DELETE", "{basePath}/portfolio/orders/{order_id}", CancelOrder, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), PATH(String, order_id)) + API_CALL("DELETE", "{basePath}/portfolio/orders/{order_id}", CancelOrder, HEADER(String, userAgent, "User-Agent"), PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), PATH(String, order_id)) API_CALL_HEADERS(AmendOrder) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("POST", "{basePath}/portfolio/orders/{order_id}/amend", AmendOrder, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), PATH(String, order_id), BODY_DTO(Object, req)) + API_CALL("POST", "{basePath}/portfolio/orders/{order_id}/amend", AmendOrder, HEADER(String, userAgent, "User-Agent"), PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), PATH(String, order_id), BODY_DTO(Object, req)) API_CALL_HEADERS(DecreaseOrder) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("POST", "{basePath}/portfolio/orders/{order_id}/decrease", DecreaseOrder, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), PATH(String, order_id), BODY_DTO(Object, req)) + API_CALL("POST", "{basePath}/portfolio/orders/{order_id}/decrease", DecreaseOrder, HEADER(String, userAgent, "User-Agent"), PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), PATH(String, order_id), BODY_DTO(Object, req)) API_CALL_HEADERS(GetPositions) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/portfolio/positions", GetPositions, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), BODY_DTO(Object, req)) + API_CALL( + "GET", + "{basePath}/portfolio/positions", + GetPositions, + HEADER(String, userAgent, "User-Agent"), + PATH(String, basePath), + AUTHORIZATION(String, authString, "Bearer"), + QUERY(String, cursor), + QUERY(Int32, limit), + QUERY(String, count_filter), + QUERY(String, settlement_status), + QUERY(String, ticker), + QUERY(String, event_ticker) + ) API_CALL_HEADERS(GetPortfolioSettlements) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/portfolio/settlements", GetPortfolioSettlements, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), BODY_DTO(Object, req)) + API_CALL( + "GET", + "{basePath}/portfolio/settlements", + GetPortfolioSettlements, + HEADER(String, userAgent, "User-Agent"), + PATH(String, basePath), + AUTHORIZATION(String, authString, "Bearer"), + QUERY(Int64, limit), + QUERY(String, cursor) + ) }; diff --git a/include/api/types.hpp b/include/api/types.hpp index a19a1ec..9feb2b4 100644 --- a/include/api/types.hpp +++ b/include/api/types.hpp @@ -274,16 +274,6 @@ namespace kdeck }; - struct EventRequest - : public oatpp::DTO - { - - DTO_INIT(EventRequest, DTO /* extends */) - - DTO_FIELD(Boolean, with_nested_markets); - - }; - struct MarketsResponse : public oatpp::DTO { @@ -384,16 +374,6 @@ namespace kdeck }; - struct MarketOrderbookRequest - : public oatpp::DTO - { - - DTO_INIT(MarketOrderbookRequest, DTO /* extends */) - - DTO_FIELD(Int32, depth); - - }; - struct SettlementSource : public oatpp::DTO { @@ -500,18 +480,6 @@ namespace kdeck }; - struct MarketCandlesticksRequest - : public oatpp::DTO - { - - DTO_INIT(MarketCandlesticksRequest, DTO /* extends */) - - DTO_FIELD(Int64, start_ts); - DTO_FIELD(Int64, end_ts); - DTO_FIELD(Int32, period_interval); - - }; - // portfolio //////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////// @@ -773,17 +741,6 @@ namespace kdeck }; - class PortfolioSettlementsRequest - : public oatpp::DTO - { - - DTO_INIT(PortfolioSettlementsRequest, DTO /* extends */) - - DTO_FIELD(Int64, limit); - DTO_FIELD(String, cursor); - - }; - class Settlement : public oatpp::DTO { diff --git a/src/api/Api.auth.cpp b/src/api/Api.auth.cpp index 308a718..be2cb32 100644 --- a/src/api/Api.auth.cpp +++ b/src/api/Api.auth.cpp @@ -29,7 +29,7 @@ namespace kdeck req->email = std::string{email}; req->password = std::string{password}; - ApiResult res = HandleResponse(_api->Login(basePath, req)); + ApiResult res = HandleResponse(_api->Login(userAgent, basePath, req)); if (std::holds_alternative>(res)) { @@ -47,7 +47,7 @@ namespace kdeck { OATPP_LOGD("Api", "Logout"); - ApiResult res = HandleResponse(_api->Logout(basePath, login->token)); + ApiResult res = HandleResponse(_api->Logout(userAgent, basePath, login->token)); if (std::holds_alternative>(res)) { diff --git a/src/api/Api.cpp b/src/api/Api.cpp index b0bf0ca..fb49593 100644 --- a/src/api/Api.cpp +++ b/src/api/Api.cpp @@ -1,3 +1,4 @@ +#include #include #include "oatpp/network/tcp/client/ConnectionProvider.hpp" @@ -8,6 +9,7 @@ #include "oatpp-openssl/client/ConnectionProvider.hpp" #include "oatpp-openssl/configurer/TrustStore.hpp" +#include "app_config.hpp" #include "api/Api.hpp" namespace kdeck @@ -19,6 +21,8 @@ namespace kdeck Api::Api(std::string_view apiEndpointUrl, std::string_view sslTrustStoreDir) : login{nullptr} { + userAgent = std::string{kProjectName} + std::string{"/"} + std::string{kProjectVersion}; + auto url = oatpp::network::Url::Parser::parseUrl(std::string{apiEndpointUrl}); // remove leading slash because oatpp's API_CALL() macro preserves it somehow diff --git a/src/api/Api.exchange.cpp b/src/api/Api.exchange.cpp index 87ccb66..6481e90 100644 --- a/src/api/Api.exchange.cpp +++ b/src/api/Api.exchange.cpp @@ -10,7 +10,7 @@ namespace kdeck { OATPP_LOGD("Api", "GetExchangeAnnouncements"); - ApiResult res = HandleResponse(_api->GetExchangeAnnouncements(basePath)); + ApiResult res = HandleResponse(_api->GetExchangeAnnouncements(userAgent, basePath)); if (std::holds_alternative>(res)) { @@ -28,7 +28,7 @@ namespace kdeck { OATPP_LOGD("Api", "GetExchangeSchedule"); - ApiResult res = HandleResponse(_api->GetExchangeSchedule(basePath)); + ApiResult res = HandleResponse(_api->GetExchangeSchedule(userAgent, basePath)); if (std::holds_alternative>(res)) { @@ -46,7 +46,7 @@ namespace kdeck { OATPP_LOGD("Api", "GetExchangeStatus"); - ApiResult res = HandleResponse(_api->GetExchangeStatus(basePath)); + ApiResult res = HandleResponse(_api->GetExchangeStatus(userAgent, basePath)); if (std::holds_alternative>(res)) { diff --git a/src/api/Api.market.cpp b/src/api/Api.market.cpp index 653cfa4..2194a5b 100644 --- a/src/api/Api.market.cpp +++ b/src/api/Api.market.cpp @@ -12,7 +12,7 @@ namespace kdeck auto req = EventsRequest::createShared(); - ApiResult res = HandleResponse(_api->GetEvents(basePath, req)); + ApiResult res = HandleResponse(_api->GetEvents(userAgent, basePath, req->cursor, req->limit, req->status, req->series_ticker, req->with_nested_markets)); if (std::holds_alternative>(res)) { @@ -30,9 +30,7 @@ namespace kdeck { OATPP_LOGD("Api", "GetEvent"); - auto req = EventRequest::createShared(); - - ApiResult res = HandleResponse(_api->GetEvent(basePath, std::string{eventTicker}, req)); + ApiResult res = HandleResponse(_api->GetEvent(userAgent, basePath, std::string{eventTicker}, nullptr)); if (std::holds_alternative>(res)) { @@ -53,7 +51,7 @@ namespace kdeck auto req = MarketsRequest::createShared(); - ApiResult res = HandleResponse(_api->GetMarkets(basePath, login->token, req)); + ApiResult res = HandleResponse(_api->GetMarkets(userAgent, basePath, login->token, req->cursor, req->limit, req->event_ticker, req->series_ticker, req->max_close_ts, req->min_close_ts, req->status, req->tickers)); if (std::holds_alternative>(res)) { @@ -73,7 +71,7 @@ namespace kdeck auto req = TradesRequest::createShared(); - ApiResult res = HandleResponse(_api->GetTrades(basePath, req)); + ApiResult res = HandleResponse(_api->GetTrades(userAgent, basePath, req->cursor, req->limit, req->ticker, req->min_ts, req->max_ts)); if (std::holds_alternative>(res)) { @@ -92,7 +90,7 @@ namespace kdeck { OATPP_LOGD("Api", "GetMarket"); - ApiResult res = HandleResponse(_api->GetMarket(basePath, std::string{marketTicker})); + ApiResult res = HandleResponse(_api->GetMarket(userAgent, basePath, std::string{marketTicker})); if (std::holds_alternative>(res)) { @@ -111,9 +109,7 @@ namespace kdeck { OATPP_LOGD("Api", "GetMarketOrderbook"); - auto req = MarketOrderbookRequest::createShared(); - - ApiResult res = HandleResponse(_api->GetMarketOrderbook(basePath, login->token, std::string{marketTicker}, req)); + ApiResult res = HandleResponse(_api->GetMarketOrderbook(userAgent, basePath, login->token, std::string{marketTicker}, nullptr)); if (std::holds_alternative>(res)) { @@ -132,7 +128,7 @@ namespace kdeck { OATPP_LOGD("Api", "GetSeries"); - ApiResult res = HandleResponse(_api->GetSeries(basePath, std::string{seriesTicker})); + ApiResult res = HandleResponse(_api->GetSeries(userAgent, basePath, std::string{seriesTicker})); if (std::holds_alternative>(res)) { @@ -151,9 +147,7 @@ namespace kdeck { OATPP_LOGD("Api", "GetMarketCandlesticks"); - auto req = MarketCandlesticksRequest::createShared(); - - ApiResult res = HandleResponse(_api->GetMarketCandlesticks(basePath, login->token, std::string{seriesTicker}, std::string{marketTicker}, req)); + ApiResult res = HandleResponse(_api->GetMarketCandlesticks(userAgent, basePath, login->token, std::string{seriesTicker}, std::string{marketTicker}, nullptr, nullptr, nullptr)); if (std::holds_alternative>(res)) { diff --git a/src/api/Api.portfolio.cpp b/src/api/Api.portfolio.cpp index fd41b21..f69e071 100644 --- a/src/api/Api.portfolio.cpp +++ b/src/api/Api.portfolio.cpp @@ -12,7 +12,7 @@ namespace kdeck { OATPP_LOGD("Api", "GetBalance"); - ApiResult res = HandleResponse(_api->GetBalance(basePath, login->token)); + ApiResult res = HandleResponse(_api->GetBalance(userAgent, basePath, login->token)); if (std::holds_alternative>(res)) { @@ -32,7 +32,7 @@ namespace kdeck auto req = OrdersRequest::createShared(); - ApiResult res = HandleResponse(_api->GetOrders(basePath, login->token, req)); + ApiResult res = HandleResponse(_api->GetOrders(userAgent, basePath, login->token, req->ticker, req->event_ticker, req->min_ts, req->max_ts, req->status, req->cursor, req->limit)); if (std::holds_alternative>(res)) { @@ -53,7 +53,7 @@ namespace kdeck auto req = CreateOrderRequest::createShared(); - ApiResult res = HandleResponse(_api->CreateOrder(basePath, login->token, req)); + ApiResult res = HandleResponse(_api->CreateOrder(userAgent, basePath, login->token, req)); if (std::holds_alternative>(res)) { @@ -72,7 +72,7 @@ namespace kdeck { OATPP_LOGD("Api", "GetOrder"); - ApiResult res = HandleResponse(_api->GetOrder(basePath, login->token, std::string{orderId})); + ApiResult res = HandleResponse(_api->GetOrder(userAgent, basePath, login->token, std::string{orderId})); if (std::holds_alternative>(res)) { @@ -91,7 +91,7 @@ namespace kdeck { OATPP_LOGD("Api", "CancelOrder"); - ApiResult res = HandleResponse(_api->CancelOrder(basePath, login->token, std::string{orderId})); + ApiResult res = HandleResponse(_api->CancelOrder(userAgent, basePath, login->token, std::string{orderId})); if (std::holds_alternative>(res)) { @@ -112,7 +112,7 @@ namespace kdeck auto req = AmendOrderRequest::createShared(); - ApiResult res = HandleResponse(_api->AmendOrder(basePath, login->token, std::string{orderId}, req)); + ApiResult res = HandleResponse(_api->AmendOrder(userAgent, basePath, login->token, std::string{orderId}, req)); if (std::holds_alternative>(res)) { @@ -133,7 +133,7 @@ namespace kdeck auto req = DecreaseOrderRequest::createShared(); - ApiResult res = HandleResponse(_api->DecreaseOrder(basePath, login->token, std::string{orderId}, req)); + ApiResult res = HandleResponse(_api->DecreaseOrder(userAgent, basePath, login->token, std::string{orderId}, req)); if (std::holds_alternative>(res)) { @@ -154,7 +154,7 @@ namespace kdeck auto req = PositionsRequest::createShared(); - ApiResult res = HandleResponse(_api->GetPositions(basePath, login->token, req)); + ApiResult res = HandleResponse(_api->GetPositions(userAgent, basePath, login->token, req->cursor, req->limit, req->count_filter, req->settlement_status, req->ticker, req->event_ticker)); if (std::holds_alternative>(res)) { @@ -192,9 +192,7 @@ namespace kdeck { OATPP_LOGD("Api", "GetPortfolioSettlements"); - auto req = PortfolioSettlementsRequest::createShared(); - - ApiResult res = HandleResponse(_api->GetPortfolioSettlements(basePath, login->token, req)); + ApiResult res = HandleResponse(_api->GetPortfolioSettlements(userAgent, basePath, login->token, nullptr, nullptr)); if (std::holds_alternative>(res)) {