ExQuickbooks.Token (ex_quickbooks v0.9.0)

Copy Markdown View Source

OAuth token data returned by QuickBooks.

The struct preserves the access token, refresh token, their expiry metadata, and the realm ID when the caller has it from the OAuth callback.

Summary

Functions

Returns true when the access token has expired at or before the given time.

Builds a token struct from the QuickBooks OAuth response body.

Returns true when the refresh token has expired at or before the given time.

Types

t()

@type t() :: %ExQuickbooks.Token{
  access_token: String.t(),
  access_token_expires_at: DateTime.t(),
  expires_in: pos_integer(),
  realm_id: String.t() | nil,
  refresh_token: String.t(),
  refresh_token_expires_at: DateTime.t(),
  refresh_token_expires_in: pos_integer(),
  token_type: String.t()
}

Functions

access_token_expired?(token, current_time \\ DateTime.utc_now())

@spec access_token_expired?(t(), DateTime.t()) :: boolean()

Returns true when the access token has expired at or before the given time.

from_oauth_response(response_body, options \\ [])

@spec from_oauth_response(
  map(),
  keyword()
) :: {:ok, t()} | {:error, ExQuickbooks.Error.t()}

Builds a token struct from the QuickBooks OAuth response body.

refresh_token_expired?(token, current_time \\ DateTime.utc_now())

@spec refresh_token_expired?(t(), DateTime.t()) :: boolean()

Returns true when the refresh token has expired at or before the given time.