Packages

Elixir Client for Flagsmith. Ship features with confidence using feature flags and remote config. Host yourself or use our hosted version at.

Current section

Files

Jump to
flagsmith_elixir_sdk lib flagsmith sdk.ex
Raw

lib/flagsmith/sdk.ex

defmodule Flagsmith.SDK do
alias __MODULE__
@moduledoc """
Documentation for `Flagsmith.SDK`.
This SDK library allows you to interact with common `Flagsmith` API endpoints easily,
allowing both static compile time configuration or runtime configuration.
If configured statically you don't need to generate a client, you can call the
`Flagsmith.SDK.API` functions directly passing only the necessary parameters
for them. You can configure the SDK statically with MFA's too for the relevant
properties, such as `environment_key` and the target host/url, in a way that
is retrieved at runtime through custom functions.
You can also create a new client definition and use that as the first argument for
each `Flagsmith.SDK.API` call if you prefer.
"""
@doc """
Returns a new `Flagsmith.SDK.Client.t()` instance that can be used to make SDK calls.
It takes as optional arguments:
1: The environment key as a string
2: The base url for the API endpoint as a string
In case none of those are provided it falls back to retrieving them from the static
application environmnet. In case those fail as well it raises an error.
"""
@spec new(SDK.Types.environment_key() | nil, SDK.Types.base_url() | nil) ::
{:ok, SDK.Client.t()} | {:error, term()}
def new(environment_key \\ nil, base_url \\ nil),
do: SDK.Client.new(environment_key, base_url)
end