Client configuration for Google API calls.
Prefer building a client once and passing it via opts:
client = Noizu.Google.Client.new(access_token: System.fetch_env!("GOOGLE_ACCESS_TOKEN"))
Noizu.Google.Api.SearchConsole.Sites.list(client: client)When client is omitted, a default client is built from application config
(:noizu_google).
Summary
Functions
Default client from application config.
Ensure a usable access token, refreshing when only a refresh_token is set.
Build a client from keyword options merged over application env defaults.
Normalize API base URL (trailing slash).
Return a client with an updated access token.
Ensure the client has an access token.
Types
@type t() :: %Noizu.Google.Client{ access_token: String.t() | nil, adsense_base: String.t(), analytics_admin_base: String.t(), analytics_data_base: String.t(), api_base: String.t(), authorize_url: String.t(), client_id: String.t() | nil, client_secret: String.t() | nil, finch: atom(), google_ads_base: String.t(), oauth_base: String.t(), pool_timeout: pos_integer(), receive_timeout: pos_integer(), refresh_token: String.t() | nil, webmasters_base: String.t() }
Functions
@spec default() :: t()
Default client from application config.
@spec ensure_access_token(t()) :: {:ok, t()} | {:error, Noizu.Google.Error.t()}
Ensure a usable access token, refreshing when only a refresh_token is set.
Returns {:ok, client} with access_token populated, or an error.
Build a client from keyword options merged over application env defaults.
Normalize API base URL (trailing slash).
Return a client with an updated access token.
@spec require_token(t()) :: {:ok, t()} | {:error, Noizu.Google.Error.t()}
Ensure the client has an access token.
Returns {:ok, client} or {:error, %Noizu.Google.Error{}}.