Current section
Files
Jump to
Current section
Files
src/glupbit@quotation@market.erl
-module(glupbit@quotation@market).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/glupbit/quotation/market.gleam").
-export([trading_pair_decoder/0, list_all/1, list_all_detailed/1]).
-export_type([trading_pair/0, market_event/0, market_caution/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(" Trading pair listing — `GET /market/all`.\n").
-type trading_pair() :: {trading_pair,
binary(),
binary(),
binary(),
gleam@option:option(market_event())}.
-type market_event() :: {market_event, boolean(), market_caution()}.
-type market_caution() :: {market_caution,
boolean(),
boolean(),
boolean(),
boolean(),
boolean()}.
-file("src/glupbit/quotation/market.gleam", 82).
-spec market_caution_decoder() -> gleam@dynamic@decode:decoder(market_caution()).
market_caution_decoder() ->
gleam@dynamic@decode:field(
<<"PRICE_FLUCTUATIONS"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_bool/1},
fun(Price_fluctuations) ->
gleam@dynamic@decode:field(
<<"TRADING_VOLUME_SOARING"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_bool/1},
fun(Trading_volume_soaring) ->
gleam@dynamic@decode:field(
<<"DEPOSIT_AMOUNT_SOARING"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_bool/1},
fun(Deposit_amount_soaring) ->
gleam@dynamic@decode:field(
<<"GLOBAL_PRICE_DIFFERENCES"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_bool/1},
fun(Global_price_differences) ->
gleam@dynamic@decode:field(
<<"CONCENTRATION_OF_SMALL_ACCOUNTS"/utf8>>,
{decoder,
fun gleam@dynamic@decode:decode_bool/1},
fun(Concentration_of_small_accounts) ->
gleam@dynamic@decode:success(
{market_caution,
Price_fluctuations,
Trading_volume_soaring,
Deposit_amount_soaring,
Global_price_differences,
Concentration_of_small_accounts}
)
end
)
end
)
end
)
end
)
end
).
-file("src/glupbit/quotation/market.gleam", 76).
-spec market_event_decoder() -> gleam@dynamic@decode:decoder(market_event()).
market_event_decoder() ->
gleam@dynamic@decode:field(
<<"warning"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_bool/1},
fun(Warning) ->
gleam@dynamic@decode:field(
<<"caution"/utf8>>,
market_caution_decoder(),
fun(Caution) ->
gleam@dynamic@decode:success(
{market_event, Warning, Caution}
)
end
)
end
).
-file("src/glupbit/quotation/market.gleam", 59).
?DOC(" Decoder for a TradingPair JSON object.\n").
-spec trading_pair_decoder() -> gleam@dynamic@decode:decoder(trading_pair()).
trading_pair_decoder() ->
gleam@dynamic@decode:field(
<<"market"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Market) ->
gleam@dynamic@decode:field(
<<"korean_name"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(Korean_name) ->
gleam@dynamic@decode:field(
<<"english_name"/utf8>>,
{decoder, fun gleam@dynamic@decode:decode_string/1},
fun(English_name) ->
gleam@dynamic@decode:optional_field(
<<"market_event"/utf8>>,
none,
gleam@dynamic@decode:optional(
market_event_decoder()
),
fun(Market_event) ->
gleam@dynamic@decode:success(
{trading_pair,
Market,
Korean_name,
English_name,
Market_event}
)
end
)
end
)
end
)
end
).
-file("src/glupbit/quotation/market.gleam", 54).
-spec list_decoder() -> gleam@dynamic@decode:decoder(list(trading_pair())).
list_decoder() ->
gleam@dynamic@decode:list(trading_pair_decoder()).
-file("src/glupbit/quotation/market.gleam", 36).
?DOC(" List all trading pairs.\n").
-spec list_all(glupbit@client:public_client()) -> {ok,
glupbit@types:api_response(list(trading_pair()))} |
{error, glupbit@types:api_error()}.
list_all(C) ->
glupbit@client:public_get(C, <<"/market/all"/utf8>>, [], list_decoder()).
-file("src/glupbit/quotation/market.gleam", 43).
?DOC(" List all trading pairs with detailed market event info.\n").
-spec list_all_detailed(glupbit@client:public_client()) -> {ok,
glupbit@types:api_response(list(trading_pair()))} |
{error, glupbit@types:api_error()}.
list_all_detailed(C) ->
glupbit@client:public_get(
C,
<<"/market/all"/utf8>>,
[{<<"is_details"/utf8>>, <<"true"/utf8>>}],
list_decoder()
).