RevenueCat (revenuecat v0.4.0)

Copy Markdown

Minimal RevenueCat client.

Exposes get_customer/1 (cached) and fetch_customer/1 (remote).

Summary

Functions

Fetch a single customer attribute struct by name.

Fetch the current offering struct from an Offerings struct.

Fetch a single entitlement struct by id.

Return the entitlements map from a customer.

Fetch a customer by app user id, bypassing the customer cache.

Get Offerings for a given app_user_id.

Get a customer by app user id, using the customer cache when possible.

Return true if the customer has the given entitlement id.

Return true if the customer has the given subscription id.

Fetch a single offering struct by id from an Offerings struct.

Fetch a single subscription struct by id.

Return the subscriptions map from a customer.

Update customer attributes and return the updated customer.

Types

entitlement_map()

@type entitlement_map() :: map()

Functions

attribute(customer, name)

@spec attribute(RevenueCat.Customer.t(), String.t() | atom()) ::
  RevenueCat.Customer.Attribute.t() | nil

Fetch a single customer attribute struct by name.

current_offering(offerings)

@spec current_offering(RevenueCat.Offerings.t()) ::
  RevenueCat.Offerings.Offering.t() | nil

Fetch the current offering struct from an Offerings struct.

entitlement(customer, entitlement_id)

@spec entitlement(RevenueCat.Customer.t() | map(), String.t() | atom()) ::
  RevenueCat.Customer.Entitlement.t() | nil

Fetch a single entitlement struct by id.

entitlements(customer)

@spec entitlements(RevenueCat.Customer.t()) :: map()

Return the entitlements map from a customer.

Returns an empty map for non-customer inputs.

fetch_customer(app_user_id)

@spec fetch_customer(String.t()) :: {:ok, RevenueCat.Customer.t()} | {:error, term()}

Fetch a customer by app user id, bypassing the customer cache.

fetch_offerings(app_user_id, opts \\ [])

@spec fetch_offerings(
  String.t(),
  keyword()
) :: {:ok, RevenueCat.Offerings.t()} | {:error, term()}

Get Offerings for a given app_user_id.

This endpoint can optionally take a :platform (string) which will be sent as the X-Platform header (lower-cased to x-platform), e.g. "ios".

get_customer(app_user_id)

@spec get_customer(String.t()) :: {:ok, RevenueCat.Customer.t()} | {:error, term()}

Get a customer by app user id, using the customer cache when possible.

has_entitlement?(customer, entitlement_id)

@spec has_entitlement?(RevenueCat.Customer.t(), String.t() | atom()) :: boolean()

Return true if the customer has the given entitlement id.

has_subscription?(customer, subscription_id)

@spec has_subscription?(RevenueCat.Customer.t(), String.t() | atom()) :: boolean()

Return true if the customer has the given subscription id.

offering(offerings, offering_id)

@spec offering(RevenueCat.Offerings.t(), String.t() | atom()) ::
  RevenueCat.Offerings.Offering.t() | nil

Fetch a single offering struct by id from an Offerings struct.

subscription(customer, subscription_id)

@spec subscription(RevenueCat.Customer.t(), String.t() | atom()) ::
  RevenueCat.Customer.Subscription.t() | nil

Fetch a single subscription struct by id.

subscriptions(customer)

@spec subscriptions(RevenueCat.Customer.t()) :: map()

Return the subscriptions map from a customer.

Returns an empty map for non-customer inputs.

update_customer_attributes(app_user_id, attributes)

@spec update_customer_attributes(String.t(), map()) ::
  {:ok, RevenueCat.Customer.t()} | {:error, term()}

Update customer attributes and return the updated customer.