View Source CastorEDC.Client (ExCastorEDC v0.3.0)

Container for API client configuration values.

Link to this section Summary

Functions

By default the client will use https://data.castoredc.com/ as the endpoint

Link to this section Types

@type credentials() ::
  %{client_id: binary(), client_secret: binary()} | %{access_token: binary()}
@type t() :: %CastorEDC.Client{
  access_token: nil | String.t(),
  client_id: nil | uuid(),
  client_secret: nil | String.t(),
  endpoint: url(),
  grant_type: String.t(),
  options: [],
  scope: String.t()
}
@type url() :: String.t()
@type uuid() :: String.t()

Link to this section Functions

Link to this function

new(credentials, opts \\ [])

View Source
@spec new(
  credentials(),
  keyword()
) :: t()

By default the client will use https://data.castoredc.com/ as the endpoint

client = Client.new(%{client_id: "<client id>", client_secret: "<client secret>"})

You can pass a different endpoint as an option when your studies are located elsewhere e.g.

client = Client.new(
  %{client_id: "<client id>", client_secret: "<client secret>"},
  endpoint: "https://us.castoredc.com/"
)

Alternatively, when you have a long-lived access token you can pass it in directly

client = Client.new(%{access_token: "<access token>"})

Additionally it's possible to pass options e.g increasing the global_timeout.

client = Client.new(
  %{client_id: "<client id>", client_secret: "<client secret>"},
  global_timeout: 30_000
)

options

Options

  • :endpoint - An alternative endpoint e.g. https://us.castoredc.com/
  • :global_timeout - The global_timeout in milliseconds, by default it is 5000
  • :adapter - Any module that implements the Tesla.Adapter behavior
  • :adapter_options - The supported options for the given adapter