Bourse.ResponseParser (bourse v0.1.0)

Copy Markdown View Source

Applies v4 normalization field maps to exchange responses.

Summary

Functions

Applies a parser mapping to raw response data and builds the configured target struct.

Resolves the unified network code for a raw row against an authored network_code rule.

Types

context()

@type context() :: map() | keyword()

parse_result()

@type parse_result() :: {:ok, struct() | [struct()]} | {:error, term()}

parser_config()

@type parser_config() :: map()

Functions

apply_mappings(data, mapping, context)

@spec apply_mappings(term(), parser_config(), context()) :: parse_result()

Applies a parser mapping to raw response data and builds the configured target struct.

network_code_for_row(data, rule)

@spec network_code_for_row(term(), map()) :: String.t() | nil

Resolves the unified network code for a raw row against an authored network_code rule.

Public because row selection (choosing which raw row answers a requested network, in the internal unified read-parse layer) must resolve the network exactly as the field extraction does. Two implementations would let the selected row and its parsed network disagree.

The authored alias table answers first; a chain it does not know is resolved against the loaded currency catalog and the venue's network options, so a network listed after the last authoring pass surfaces with its unified code. Returns nil when neither knows the chain id. Carve C-T421 records the ordering.

iex> rule = %{"network_aliases" => %{"USDT-TRC20" => "TRC20"}}
iex> Bourse.ResponseParser.network_code_for_row(%{"chain" => "USDT-TRC20", "ccy" => "USDT"}, rule)
"TRC20"

iex> rule = %{"network_aliases" => %{"USDT-TRC20" => "TRC20"}}
iex> Bourse.ResponseParser.network_code_for_row(%{"chain" => "USDT-Unlisted", "ccy" => "USDT"}, rule)
nil