Elixir SDK and client for the Polar API.
Configuration
PolarExpress does not read application configuration. Read credentials from your own application boundary, then pass them explicitly when creating a client:
client = PolarExpress.client(System.fetch_env!("POLAR_ACCESS_TOKEN"))
{:ok, customer} = PolarExpress.Services.CustomersService.create_customer(client, %{
email: "jane@example.com"
})Finch Supervision
The default client uses a Finch pool named PolarExpress.Finch. Add
PolarExpress to your supervision tree, or pass a custom Finch name with
:finch:
children = [
PolarExpress
]Per-Client Options
Override any client option when creating a client:
client = PolarExpress.client("pk_test_...", server: :sandbox)
client = PolarExpress.client(api_key: "pk_test_...", max_retries: 5)Options are resolved from explicit arguments and PolarExpress.Client struct
defaults only.
Supported Client Options
:api_key- Polar API key (required):server- API environment::productionor:sandbox(default::production):max_retries- Maximum retry attempts (default: 2):timeout_ms- Request timeout in ms (default: 30_000):finch- Custom Finch instance name (default:PolarExpress.Finch)
Summary
Functions
Get BenefitGrantsService module
Get BenefitsService module
Get CheckoutLinksService module
Get CheckoutsService module
Returns the child spec for the default Finch pool.
Raises because PolarExpress clients require explicit credentials.
Create a new PolarExpress client.
Create a new PolarExpress client with an explicit API key.
Get CustomFieldsService module
Get CustomerMetersService module
Get CustomerPortal namespace with 12 sub-services
Get CustomerSeatsService module
Get CustomerSessionsService module
Get CustomersService module
Get DiscountsService module
Get DisputesService module
Get EventTypesService module
Get EventsService module
Get FilesService module
Get LicenseKeysService module
Get MemberSessionsService module
Get MembersService module
Get MetersService module
Get MetricsService module
Get Oauth2Service module
Get OrdersService module
Get OrganizationAccessTokensService module
Get OrganizationsService module
Get PaymentsService module
Get ProductsService module
Get RefundsService module
Get SubscriptionsService module
Returns the library version.
Get WebhooksService module
Types
@type client_opts() :: [ api_key: String.t(), server: PolarExpress.Client.server(), base_url: String.t(), max_retries: non_neg_integer(), timeout_ms: pos_integer(), finch: atom() ]
Functions
Get BenefitGrantsService module
Get BenefitsService module
Get CheckoutLinksService module
Get CheckoutsService module
@spec child_spec(keyword()) :: Supervisor.child_spec()
Returns the child spec for the default Finch pool.
Add this to your supervision tree when using the default
PolarExpress.Finch pool:
children = [
PolarExpress
]Pass Finch options directly when you need to customize the pool:
{PolarExpress, name: MyApp.PolarFinch}
@spec client() :: no_return()
Raises because PolarExpress clients require explicit credentials.
Use client/1 or client/2 instead:
client = PolarExpress.client("pk_test_...")
@spec client(String.t() | client_opts()) :: PolarExpress.Client.t()
Create a new PolarExpress client.
When given a string, treated as an explicit API key.
When given a keyword list, :api_key must be present.
Examples
client = PolarExpress.client("pk_test_...")
client = PolarExpress.client(api_key: "pk_test_...", server: :sandbox)
@spec client( String.t(), keyword() ) :: PolarExpress.Client.t()
Create a new PolarExpress client with an explicit API key.
Get CustomFieldsService module
Get CustomerMetersService module
Get CustomerPortal namespace with 12 sub-services
Get CustomerSeatsService module
Get CustomerSessionsService module
Get CustomersService module
Get DiscountsService module
Get DisputesService module
Get EventTypesService module
Get EventsService module
Get FilesService module
Get LicenseKeysService module
Get MemberSessionsService module
Get MembersService module
Get MetersService module
Get MetricsService module
Get Oauth2Service module
Get OrdersService module
Get OrganizationAccessTokensService module
Get OrganizationsService module
Get PaymentsService module
Get ProductsService module
Get RefundsService module
Get SubscriptionsService module
@spec version() :: String.t()
Returns the library version.
Get WebhooksService module