Skip to content

Instantly share code, notes, and snippets.

@dmoss18
Created Apr 29, 2021
Embed
What would you like to do?
Ale topic mappings to our back-end services
defmodule Apex.AleTopic do
@moduledoc """
Utility functions for working with ALE topics.
"""
alias __MODULE__
@enforce_keys [:name, :apex_api, :api_endpoint]
defstruct name: nil, apex_api: nil, api_endpoint: nil, base_url: Apex.Config.api_host, partition: Apex.Config.partition
@doc """
Generates a full URL for Apex's ALE API based on a given topic `name` and
optional `partition` and `query_params`.
# Examples
iex> topic = %Apex.AleTopic{base_url: "http://example.com", name: "my-example-topic", apex_api: :apex_api, api_endpoint: "/apex/example"}
iex> Apex.AleTopic.url(topic)
"http://example.com/ale/api/v1/read/my-example-topic/TWTT"
iex> Apex.AleTopic.url(%{topic | partition: "FOO"})
"http://example.com/ale/api/v1/read/my-example-topic/FOO"
"""
@spec url(%Apex.AleTopic{base_url: binary, name: binary, partition: binary}) :: binary
def url(%Apex.AleTopic{base_url: base_url, name: name, partition: partition}) do
"#{base_url}/ale/api/v1/read/#{name}/#{partition}"
end
def ale_topics_configs do
[
%AleTopic{name: "alps-acat-status", apex_api: :alps, api_endpoint: "/apex/acat-status"},
%AleTopic{name: "atlas-account_request-status", apex_api: :atlas, api_endpoint: "/apex/account-request-status"},
%AleTopic{name: "sentinel-ach-relationship-status", apex_api: :sentinel, api_endpoint: "/apex/ach-relationship-status"},
%AleTopic{name: "sentinel-ach-transfer-status", apex_api: :sentinel, api_endpoint: "/apex/ach-transfer-status"},
%AleTopic{name: "sentinel-wire-transfer-status", apex_api: :sentinel, api_endpoint: "/apex/wire-transfer-status"},
%AleTopic{name: "sentinel-check-transfer-status", apex_api: :sentinel, api_endpoint: "/apex/check-transfer-status"},
%AleTopic{name: "sketch-investigation-status", apex_api: :atlas, api_endpoint: "/account-opening-applications/investigations/status"},
%AleTopic{name: "third-party-journal-status", apex_api: :digital_assets, api_endpoint: "/apex/third-party-journal-status"},
]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment