Packages

Synapse API client for Elixir.

Current section

Files

Jump to
ex_synapse lib ex_synapse subnets.ex
Raw

lib/ex_synapse/subnets.ex

defmodule ExSynapse.Subnets do
@moduledoc "Subnets resources are generic transaction classes that store basic information regarding a node's subnet. Subnets are virtual account and routing numbers issued on top of Synapse managed Deposit Accounts. Developers can use subnets to allow uses to be able to fund their deposit account via external ACH or Wire transfers. These account and routing numbers can be plugged into any third party software that is capable of sending ACHs or Wires and when the transfers arrive, a transaction will be created automatically and funds will be added on to the associated deposit account."
alias ExSynapse.Utils
def get_all_subnets(user_id, node_id, opts \\ []) do
query_params = Keyword.take(opts, [:page, :per_page])
ExSynapse.request :get,
request_url(endpoint(user_id, node_id), query_params),
[],
opts
end
def create_subnet(user_id, node_id, data, opts \\ []) do
ExSynapse.request :post, endpoint(user_id, node_id), data, opts
end
def get_subnet(user_id, node_id, subnet_id, opts \\ []) do
ExSynapse.request :get, endpoint(user_id, node_id, subnet_id), [], opts
end
def update_subnet(user_id, node_id, subnet_id, data, opts \\ []) do
ExSynapse.request :patch, endpoint(user_id, node_id, subnet_id), data, opts
end
defp endpoint(user_id, node_id) do
"users/#{user_id}/nodes/#{node_id}/subnets"
end
defp endpoint(user_id, node_id, subnet_id) do
Path.join endpoint(user_id, node_id), subnet_id
end
defp request_url(resource_url, []) do
resource_url
end
defp request_url(resource_url, query_params) do
"#{resource_url}?#{Utils.encode query_params}"
end
end