View Source Nimrag.Client (Nimrag v0.1.0)
Struct containing all the required data to interact with the library and to make requests to Garmin.
See Nimrag.Client.new/1
for more details about the configuration.
Summary
Functions
Builds initial struct with the required configuration to interact with Garmin's API.
Adds OAuth1 or OAuth2 token to the client
Used to attach OAuth tokens to the client
Types
@type t() :: %Nimrag.Client{ connectapi: Req.Request.t(), domain: String.t(), oauth1_token: Nimrag.OAuth1Token.t() | nil, oauth2_token: Nimrag.OAuth2Token.t() | nil, rate_limit: [scale_ms: integer(), limit: integer()], req_options: Keyword.t() }
Functions
Builds initial struct with the required configuration to interact with Garmin's API.
Supported options:
:domain
- Garmin's domain, by default it's "garmin.com".:req_options
- Custom Req options to be passed to all requests.You can capture and proxy all requests with mitmmproxy,
req_options: [ connect_options: [ protocols: [:http2], transport_opts: [cacertfile: Path.expand("~/.mitmproxy/mitmproxy-ca-cert.pem")], proxy: {:http, "localhost", 8080, []} ] ]
:rate_limit
- Rate limit for all requests, see "Rate limit" in theNimrag
module, by default it's set to 60 requests every 30 seconds.rate_limit: [scale_ms: 30_000, limit: 10]
@spec put_oauth_token(t(), Nimrag.OAuth1Token.t()) :: t()
@spec put_oauth_token(t(), Nimrag.OAuth2Token.t()) :: t()
Adds OAuth1 or OAuth2 token to the client
@spec with_auth( t(), {Nimrag.OAuth1Token.t(), Nimrag.OAuth2Token.t()} ) :: t()
Used to attach OAuth tokens to the client
Example
Nimrag.Client.new() |> Nimrag.Client.with_auth(Nimrag.Credentials.read_oauth_tokens!())