Packages

Elixir client library for cryptocurrency exchanges — generated from CCXT specs via compile-time macros.

Current section

Files

Jump to
ccxt_client lib ccxt ws subscription method_topics.ex
Raw

lib/ccxt/ws/subscription/method_topics.ex

defmodule CCXT.WS.Subscription.MethodTopics do
@moduledoc """
Exmo-style subscribe frame.
%{"method" => "subscribe", "topics" => ["spot/ticker:BTC_USDT"]}
Config keys: `:op_field` (default `"method"`), `:args_field`
(default `"topics"`).
"""
@behaviour CCXT.WS.Subscription.Behaviour
@impl true
def subscribe(channels, config) when is_list(channels) do
build(channels, config, "subscribe")
end
@impl true
def unsubscribe(channels, config) when is_list(channels) do
build(channels, config, "unsubscribe")
end
defp build(channels, config, action) do
method = Map.get(config, :op_field, "method")
topics = Map.get(config, :args_field, "topics")
%{method => action, topics => channels}
end
end