|
| 1 | +module Aevo |
| 2 | + |
| 3 | +export AevoCommonQuery, |
| 4 | + AevoPublicQuery, |
| 5 | + AevoAccessQuery, |
| 6 | + AevoAPIError, |
| 7 | + AevoClient, |
| 8 | + AevoData |
| 9 | + |
| 10 | +using Serde |
| 11 | +using Dates, NanoDates, TimeZones, Base64, Nettle |
| 12 | + |
| 13 | +using ..CryptoAPIs |
| 14 | +import ..CryptoAPIs: Maybe, AbstractAPIsError, AbstractAPIsData, AbstractAPIsQuery, AbstractAPIsClient |
| 15 | + |
| 16 | +abstract type AevoData <: AbstractAPIsData end |
| 17 | +abstract type AevoCommonQuery <: AbstractAPIsQuery end |
| 18 | +abstract type AevoPublicQuery <: AevoCommonQuery end |
| 19 | +abstract type AevoAccessQuery <: AevoCommonQuery end |
| 20 | + |
| 21 | +""" |
| 22 | +AevoClient <: AbstractAPIsClient |
| 23 | +
|
| 24 | +Client info. |
| 25 | +
|
| 26 | +## Required fields |
| 27 | +- `base_url::String`: Base URL for the client. |
| 28 | +
|
| 29 | +## Optional fields |
| 30 | +- `public_key::String`: Public key for authentication. |
| 31 | +- `secret_key::String`: Secret key for authentication. |
| 32 | +- `interface::String`: Interface for the client. |
| 33 | +- `proxy::String`: Proxy information for the client. |
| 34 | +- `account_name::String`: Account name associated with the client. |
| 35 | +- `description::String`: Description of the client. |
| 36 | +""" |
| 37 | +Base.@kwdef struct AevoClient <: AbstractAPIsClient |
| 38 | + base_url::String |
| 39 | + public_key::Maybe{String} = nothing |
| 40 | + secret_key::Maybe{String} = nothing |
| 41 | + interface::Maybe{String} = nothing |
| 42 | + proxy::Maybe{String} = nothing |
| 43 | + account_name::Maybe{String} = nothing |
| 44 | + description::Maybe{String} = nothing |
| 45 | +end |
| 46 | + |
| 47 | +""" |
| 48 | + AevoAPIError{T} <: AbstractAPIsError |
| 49 | +
|
| 50 | +Exception thrown when an API method fails with code `T`. |
| 51 | +
|
| 52 | +## Required fields |
| 53 | +- `error::String`: Error message. |
| 54 | +""" |
| 55 | +struct AevoAPIError{T} <: AbstractAPIsError |
| 56 | + error::String |
| 57 | + |
| 58 | + function AevoAPIError(error::String, x...) |
| 59 | + return new{Symbol(error)}(error, x...) |
| 60 | + end |
| 61 | +end |
| 62 | + |
| 63 | +CryptoAPIs.error_type(::AevoClient) = AevoAPIError |
| 64 | + |
| 65 | +function Base.show(io::IO, e::AevoAPIError) |
| 66 | + return print(io, "error = ", "\"", e.error) |
| 67 | +end |
| 68 | + |
| 69 | +function CryptoAPIs.request_sign!(::AevoClient, query::Q, ::String)::Q where {Q<:AevoCommonQuery} |
| 70 | + return query |
| 71 | +end |
| 72 | + |
| 73 | +function CryptoAPIs.request_body(::Q)::String where {Q<:AevoCommonQuery} |
| 74 | + return "" |
| 75 | +end |
| 76 | + |
| 77 | +function CryptoAPIs.request_query(query::Q)::String where {Q<:AevoCommonQuery} |
| 78 | + return Serde.to_query(query) |
| 79 | +end |
| 80 | + |
| 81 | +function CryptoAPIs.request_headers(client::AevoClient, ::AevoCommonQuery)::Vector{Pair{String,String}} |
| 82 | + return Pair{String,String}[ |
| 83 | + "accept" => "application/json", |
| 84 | + ] |
| 85 | +end |
| 86 | + |
| 87 | +include("Utils.jl") |
| 88 | +include("Errors.jl") |
| 89 | + |
| 90 | +include("Futures/Futures.jl") |
| 91 | +using .Futures |
| 92 | + |
| 93 | +end |
0 commit comments