Chargebeex.SubscriptionEntitlement (chargebeex v0.6.0)
View SourceStruct that represent a Chargebee's API subscription entitlement resource.
Summary
Types
"switch" | "custom" | "quantity" | "range"
Parameters for the set_availability
function.
A single subscription entitlement map.
Functions
Allows to list Subscription Entitlements
Enables or disables specific subscription_entitlements for a subscription.
Types
@type feature_type() :: String.t()
"switch" | "custom" | "quantity" | "range"
@type set_availability_params() :: %{ :is_enabled => boolean(), optional(:subscription_entitlements) => [subscription_entitlement()], optional(any()) => any() }
Parameters for the set_availability
function.
@type subscription_entitlement() :: %{feature_id: String.t()}
A single subscription entitlement map.
@type t() :: %Chargebeex.SubscriptionEntitlement{ feature_id: String.t() | nil, feature_name: String.t() | nil, feature_type: feature_type() | nil, is_enabled: boolean() | nil, is_overridden: boolean() | nil, name: String.t() | nil, object: String.t() | nil, subscription_id: String.t() | nil, value: String.t() | nil }
Functions
Allows to list Subscription Entitlements
Available filters can be found here: https://apidocs.chargebee.com/docs/api/subscription_entitlements#list_subscription_entitlements
Examples
iex> filters = %{limit: 2}
iex(2)> Chargebeex.SubscriptionEntitlement.list(filters)
{:ok, [%Chargebeex.SubscriptionEntitlement{...}, %Chargebeex.SubscriptionEntitlement{...}], %{"next_offset" => nil}}
@spec set_availability(String.t(), set_availability_params(), keyword()) :: any()
Enables or disables specific subscription_entitlements for a subscription.
For more info, check the API doc: https://apidocs.eu.chargebee.com/docs/api/subscription_entitlements?lang=curl#enable/disable_subscription_entitlements
Examples
#
iex(1)> subscription_id = "BTLybZUInBGCXDMY"
"BTLybZUInBGCXDMY"
iex(2)> params = %{
...(2)> "is_enabled" => true,
...(2)> "subscription_entitlements" => [
...(2)> %{
...(2)> "feature_id" => "foo_feature"
...(2)> }
...(2)> ]
...(2)> }
%{
"is_enabled" => true,
"subscription_entitlements" => [
%{"feature_id" => "foo_feature"}
]
}
iex(3)> Chargebeex.SubscriptionEntitlement.set_availability(subscription_id, params)
{:ok,
[%Chargebeex.SubscriptionEntitlement{...}], %{"next_offset" => nil}}