unilink_client v1.0.2 UnilinkClient behaviour View Source

Documentation for UnilinkClient.

Link to this section Summary

Types

Profit map returned by Unilink service in callback when user requests payout. Should be used in handle_profit/1 callback to add user balance

Functions

Returns URL to which we should redirect user so he can login seemlessly to Unilink

Finds secret for given api_key (from settings provided by UnilinkClient implementation)

Callbacks

Invoked on lazy work to delay it

Invoked at server start to delay startup

Invoked to get API keys and secrets. Allows to setup multiple platforms

Invoked when user requests withdrawal of his affiliation funds

Link to this section Types

Link to this type profit() View Source
profit() :: %{
  id: String.t(),
  user_id: String.t(),
  amount: Decimal.t(),
  timestamp: integer()
}

Profit map returned by Unilink service in callback when user requests payout. Should be used in handle_profit/1 callback to add user balance.

Link to this section Functions

Link to this function get_login_url(api_key, user_id) View Source
get_login_url(String.t(), String.t()) :: String.t()

Returns URL to which we should redirect user so he can login seemlessly to Unilink

Link to this function get_secret(api_key) View Source
get_secret(String.t()) :: {:ok, String.t()} | {:error, :setting_not_found}

Finds secret for given api_key (from settings provided by UnilinkClient implementation)

Link to this section Callbacks

Link to this callback get_server_lazy_work_delay() View Source (optional)
get_server_lazy_work_delay() :: integer()

Invoked on lazy work to delay it

Link to this callback get_server_start_delay() View Source (optional)
get_server_start_delay() :: integer()

Invoked at server start to delay startup

Invoked to get API keys and secrets. Allows to setup multiple platforms.

Typically you want to implement it to return just UnilinkClient.Setting struct. It is possible to return multiple UnilinkClient.Setting structs (in a list) if you handle multiple Unilink accounts in one service.

Link to this callback handle_profit(profit) View Source
handle_profit(profit()) :: :ok | {:error, atom()}

Invoked when user requests withdrawal of his affiliation funds.

Unilink follows at least once delivery semantics and will retry requests until successful response is received. Client Platform may receive the same request more than once and SHOULD make sure that users profit is assigned only once for each unique ID of payout request. Client Platform SHOULD respond with code 202 upon receival of already processed payout request.