Packages

Type-safe Gleam client library for the Upbit cryptocurrency exchange API

Current section

Files

Jump to
glupbit src glupbit.erl
Raw

src/glupbit.erl

-module(glupbit).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/glupbit.gleam").
-export([new/0, new_auth/1, new_from_env/0, access_key/1, secret_key/1, credentials/2, market/1, to_public/1]).
-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(
" Glupbit — Type-safe Gleam client for the Upbit cryptocurrency exchange API.\n"
"\n"
" ## Quick Start\n"
"\n"
" ```gleam\n"
" import glupbit\n"
" import glupbit/quotation/market\n"
"\n"
" // Public client (no auth needed)\n"
" let client = glupbit.new()\n"
" let assert Ok(pairs) = market.list_all(client)\n"
"\n"
" // Authenticated client from environment variables\n"
" let assert Ok(auth_client) = glupbit.new_from_env()\n"
" ```\n"
).
-file("src/glupbit.gleam", 22).
?DOC(" Create a public client for quotation (market data) endpoints.\n").
-spec new() -> glupbit@client:public_client().
new() ->
glupbit@client:new_public().
-file("src/glupbit.gleam", 27).
?DOC(" Create an authenticated client for all endpoints.\n").
-spec new_auth(glupbit@auth:credentials()) -> glupbit@client:auth_client().
new_auth(Creds) ->
glupbit@client:new_auth(Creds).
-file("src/glupbit.gleam", 32).
?DOC(" Create an authenticated client from environment variables.\n").
-spec new_from_env() -> {ok, glupbit@client:auth_client()} | {error, binary()}.
new_from_env() ->
glupbit@client:new_auth_from_env().
-file("src/glupbit.gleam", 37).
?DOC(" Wrap a raw string as an AccessKey.\n").
-spec access_key(binary()) -> glupbit@auth:access_key().
access_key(Key) ->
glupbit@auth:access_key(Key).
-file("src/glupbit.gleam", 42).
?DOC(" Wrap a raw string as a SecretKey.\n").
-spec secret_key(binary()) -> glupbit@auth:secret_key().
secret_key(Key) ->
glupbit@auth:secret_key(Key).
-file("src/glupbit.gleam", 47).
?DOC(" Bundle credentials from an access key and secret key.\n").
-spec credentials(glupbit@auth:access_key(), glupbit@auth:secret_key()) -> glupbit@auth:credentials().
credentials(Ak, Sk) ->
glupbit@auth:credentials(Ak, Sk).
-file("src/glupbit.gleam", 52).
?DOC(" Parse a market code like `\"KRW-BTC\"` into a validated Market.\n").
-spec market(binary()) -> {ok, glupbit@types:market()} | {error, nil}.
market(Code) ->
glupbit@types:market(Code).
-file("src/glupbit.gleam", 57).
?DOC(" Downcast an AuthClient to a PublicClient for quotation calls.\n").
-spec to_public(glupbit@client:auth_client()) -> glupbit@client:public_client().
to_public(Auth_client) ->
glupbit@client:to_public(Auth_client).