From a156db6c987b58fde95d78223519417e9cd05fad Mon Sep 17 00:00:00 2001 From: Mark Ross <6730333+krazkidd@users.noreply.github.com> Date: Tue, 16 Jul 2024 13:37:01 -0700 Subject: [PATCH] Serialize request objects as JSON in GET body. oatpp's QUERY() macro doesn't like objects. Kalshi seems to be accepting query params in the body (though the market API calls haven't been tested yet). --- include/api/_Api.hpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/include/api/_Api.hpp b/include/api/_Api.hpp index 360e0bf..3ce2b0e 100644 --- a/include/api/_Api.hpp +++ b/include/api/_Api.hpp @@ -61,27 +61,31 @@ namespace kdeck API_CALL_HEADERS(GetEvents) { + headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); } - API_CALL("GET", "{basePath}/events", GetEvents, PATH(String, basePath), QUERY(Object, eventsRequest)) + API_CALL("GET", "{basePath}/events", GetEvents, PATH(String, basePath), BODY_DTO(Object, eventsRequest)) 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), QUERY(Object, eventRequest)) + API_CALL("GET", "{basePath}/events/{event_ticker}", GetEvent, PATH(String, basePath), PATH(String, event_ticker), BODY_DTO(Object, eventRequest)) 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"), QUERY(Object, marketsRequest)) + API_CALL("GET", "{basePath}/markets", GetMarkets, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), BODY_DTO(Object, marketsRequest)) 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), QUERY(Object, tradesRequest)) + API_CALL("GET", "{basePath}/markets/trades", GetTrades, PATH(String, basePath), BODY_DTO(Object, tradesRequest)) API_CALL_HEADERS(GetMarket) { @@ -91,9 +95,10 @@ namespace kdeck 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), QUERY(Object, marketOrderbookRequest)) + API_CALL("GET", "{basePath}/markets/{ticker}/orderbook", GetMarketOrderbook, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), QUERY(String, ticker), BODY_DTO(Object, marketOrderbookRequest)) API_CALL_HEADERS(GetSeries) { @@ -103,9 +108,10 @@ namespace kdeck 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), QUERY(Object, marketCandlesticksRequest)) + 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, marketCandlesticksRequest)) // portfolio //////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////