upvest v0.1.1 Upvest.Utils View Source

Utility functions for Upvest

Link to this section Summary

Functions

Formats according the given string format specifier and returns the resulting string. The params argument needs to be List.

Returns current timestamp in seconds

Creates a struct from the given struct module and data

Link to this section Functions

Link to this function

sprintf(format, params)

View Source
sprintf(binary(), [any()]) :: binary()

Formats according the given string format specifier and returns the resulting string. The params argument needs to be List.

Examples

iex> sprintf("/foo/~r/bar", "hi") ...> /foo/hi/bar

Returns current timestamp in seconds

Link to this function

to_struct(data, module)

View Source
to_struct(list() | Enum.t(), module() | struct()) :: struct()

Creates a struct from the given struct module and data

Intended for transforming raw data received from Upvest to a struct.

Examples

iex> data = %{ ...> exponent: 12, ...> id: "51bfa4b5-6499-5fe2-998b-5fb3c9403ac7", ...> metadata: %{ ...> "genesis" => "AX7fqNywVSYFBjqMiAApi1KOjAz-7JvMoFXAewyabWD1Jk2KdzFroYsqUpxSa0hh" ...> }, ...> name: "Arweave (internal testnet)", ...> protocol: "arweave_testnet", ...> symbol: "AR" ...> } ...> to_struct([asset], Upvest.Tenancy.Asset) %Upvest.Tenancy.Asset{ exponent: 12, id: "51bfa4b5-6499-5fe2-998b-5fb3c9403ac7", metadata: %{

"genesis" => "AX7fqNywVSYFBjqMiAApi1KOjAz-7JvMoFXAewyabWD1Jk2KdzFroYsqUpxSa0hh"

}, name: "Arweave (internal testnet)", protocol: "arweave_testnet", symbol: "AR" }