Skip to content

Commit

Permalink
Serialize request objects as JSON in GET body.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
krazkidd committed Jul 16, 2024
1 parent cadf259 commit a156db6
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions include/api/_Api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>, eventsRequest))
API_CALL("GET", "{basePath}/events", GetEvents, PATH(String, basePath), BODY_DTO(Object<EventsRequest>, 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>, eventRequest))
API_CALL("GET", "{basePath}/events/{event_ticker}", GetEvent, PATH(String, basePath), PATH(String, event_ticker), BODY_DTO(Object<EventRequest>, 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>, marketsRequest))
API_CALL("GET", "{basePath}/markets", GetMarkets, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), BODY_DTO(Object<MarketsRequest>, 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>, tradesRequest))
API_CALL("GET", "{basePath}/markets/trades", GetTrades, PATH(String, basePath), BODY_DTO(Object<TradesRequest>, tradesRequest))

API_CALL_HEADERS(GetMarket)
{
Expand All @@ -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>, marketOrderbookRequest))
API_CALL("GET", "{basePath}/markets/{ticker}/orderbook", GetMarketOrderbook, PATH(String, basePath), AUTHORIZATION(String, authString, "Bearer"), QUERY(String, ticker), BODY_DTO(Object<MarketOrderbookRequest>, marketOrderbookRequest))

API_CALL_HEADERS(GetSeries)
{
Expand All @@ -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>, 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>, marketCandlesticksRequest))

// portfolio ////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit a156db6

Please sign in to comment.