AirtelMoney.TokenManager (airtel_money v0.1.0)

Copy Markdown View Source

GenServer for managing OAuth tokens.

Automatically obtains, caches, and refreshes OAuth tokens. Refreshes tokens 5 minutes before expiry.

Summary

Functions

Returns a specification to start this module under a supervisor.

Forces a token refresh.

Starts the token manager.

Returns the current OAuth token.

Types

t()

@type t() :: %AirtelMoney.TokenManager{
  config: map() | nil,
  expires_at: integer() | nil,
  token: String.t() | nil
}

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

refresh()

@spec refresh() :: :ok | {:error, AirtelMoney.Error.t()}

Forces a token refresh.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the token manager.

token()

@spec token() :: {:ok, String.t()} | {:error, AirtelMoney.Error.t()}

Returns the current OAuth token.