Interface Entitlement
-
- All Superinterfaces:
Entity
- All Known Subinterfaces:
Subscription
public interface Entitlement extends Entity
An Entitlement is created using theEntitlementApiIt contains apis to return entitlement state (i.e information about whether the user can access the service purchased through the subscription), and also apis to modify the state of the subscription (upgrade, downgrade, cancellation).The apis
cancelEntitlementandchangePlanare relying on either dates and/or policies to achieve correct result.The dates provided are
LocalDateand they are interpreted by the system using the the account timezone:Example: Let's assume for instance a point in time set to 2017-04-24:00.00.01.000Z, and a user that makes a
changePlanapi call by specifying an effective date of 2017-04-24 for an account with a UTC-8 TZ. In the account timezone, the clock shows 2017-04-23:16.00.01.000(-8), and so the change will be effective in the future, any time during the 24 hours period that starts at 2017-04-24:00.00.00.000(-8), with no specific guarantee about the time.In order to ensure that the api call happens immediately (as the call returns), one can pass a null effective date.
The policies provide an easy way to achieve desired results without having to do any date computation. However, when using the
IMMEDIATEpolicy, it is interesting to notice that the policy will be converted into an effective date and so the same principle discussed earlier with interpreting the date into the account timezone will occur, resulting in the operation to not necessarily happen immediately (as the call returns) but instead within the 24 hours window. The result will be correct in the sense that the service will move to the new Plan on the right day, and if necessary billing pro-ration will show the correct amount.In the case of
PENDINGsubscriptions, that is for which the (billing and/or entitlement) effective start date are in the future, providing anIMMEDIATEpolicy or a null effective date will default to the effective start date of the subscription.- See Also:
EntitlementApi
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classEntitlement.EntitlementActionPolicyUsed to control the effective date that should be used on Plan change or on cancellation.static classEntitlement.EntitlementSourceTypePossibleEntitlementsource types.static classEntitlement.EntitlementStatePossible states of anEntitlement
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description EntitlementcancelEntitlementWithDate(org.joda.time.DateTime entitlementEffectiveDate, org.joda.time.DateTime billingEffectiveDate, Iterable<PluginProperty> properties, CallContext context)Cancels theEntitlementwith the specified entitlementEffectiveDate and billingEffectiveDate After this operation, the existing object becomes stale.EntitlementcancelEntitlementWithDate(org.joda.time.LocalDate effectiveDate, boolean overrideBillingEffectiveDate, Iterable<PluginProperty> properties, CallContext context)Cancels theEntitlementat the specified date.EntitlementcancelEntitlementWithDateOverrideBillingPolicy(org.joda.time.LocalDate effectiveDate, BillingActionPolicy billingPolicy, Iterable<PluginProperty> properties, CallContext context)Cancels theEntitlementat the specified date After this operation, the existing object becomes stale.EntitlementcancelEntitlementWithPolicy(Entitlement.EntitlementActionPolicy policy, Iterable<PluginProperty> properties, CallContext context)Cancel theEntitlementwith a policy.EntitlementcancelEntitlementWithPolicyOverrideBillingPolicy(Entitlement.EntitlementActionPolicy policy, BillingActionPolicy billingPolicy, Iterable<PluginProperty> properties, CallContext context)Cancels theEntitlementat the specified date and overrides the default billing policy.EntitlementchangePlan(EntitlementSpecifier spec, Iterable<PluginProperty> properties, CallContext context)ChangeEntitlementplan using default policy.EntitlementchangePlanOverrideBillingPolicy(EntitlementSpecifier spec, org.joda.time.LocalDate effectiveDate, BillingActionPolicy billingPolicy, Iterable<PluginProperty> properties, CallContext context)ChangeEntitlementplan at the specified date and overrides the billing policy.EntitlementchangePlanWithDate(EntitlementSpecifier spec, org.joda.time.DateTime effectiveDate, Iterable<PluginProperty> properties, CallContext context)ChangeEntitlementplan at the specified date.EntitlementchangePlanWithDate(EntitlementSpecifier spec, org.joda.time.LocalDate effectiveDate, Iterable<PluginProperty> properties, CallContext context)ChangeEntitlementplan at the specified date.UUIDgetAccountId()UUIDgetBaseEntitlementId()IntegergetBillCycleDayLocal()The billCycleDay should be interpreted in the account timezone.StringgetBundleExternalKey()UUIDgetBundleId()org.joda.time.DateTimegetEffectiveEndDate()org.joda.time.DateTimegetEffectiveStartDate()StringgetExternalKey()PlanPhasegetLastActivePhase()PlangetLastActivePlan()PriceListgetLastActivePriceList()ProductgetLastActiveProduct()ProductCategorygetLastActiveProductCategory()IntegergetQuantity()Entitlement.EntitlementSourceTypegetSourceType()Entitlement.EntitlementStategetState()voiduncancelEntitlement(Iterable<PluginProperty> properties, CallContext context)Removes a pending future cancellation on an entitlement.voidundoChangePlan(Iterable<PluginProperty> properties, CallContext context)voidupdateBCD(int bcd, org.joda.time.LocalDate effectiveFromDate, CallContext context)voidupdateQuantity(int quantity, org.joda.time.LocalDate effectiveFromDate, CallContext context)-
Methods inherited from interface org.killbill.billing.util.entity.Entity
getCreatedDate, getId, getUpdatedDate
-
-
-
-
Method Detail
-
getBaseEntitlementId
UUID getBaseEntitlementId()
- Returns:
- the unique id of the base entitlement
-
getExternalKey
String getExternalKey()
- Returns:
- external key
-
getBundleId
UUID getBundleId()
- Returns:
- the unique Id of the SubscriptionBundle
-
getBundleExternalKey
String getBundleExternalKey()
- Returns:
- the bundle external key associated with this entitlement
-
getAccountId
UUID getAccountId()
- Returns:
- the account id
-
getState
Entitlement.EntitlementState getState()
- Returns:
- the state of the entitlement
-
getSourceType
Entitlement.EntitlementSourceType getSourceType()
- Returns:
- the entitlement source type
-
getEffectiveStartDate
org.joda.time.DateTime getEffectiveStartDate()
- Returns:
- the start date of the entitlement
-
getEffectiveEndDate
org.joda.time.DateTime getEffectiveEndDate()
- Returns:
- the end date of the entitlement, that is the date at which it got cancelled.
-
getLastActiveProduct
Product getLastActiveProduct()
- Returns:
- the last
Productprior to cancellation
-
getLastActivePlan
Plan getLastActivePlan()
- Returns:
- the last
Planprior to cancellation
-
getLastActivePhase
PlanPhase getLastActivePhase()
- Returns:
- the last
Phaseprior to cancellation
-
getLastActivePriceList
PriceList getLastActivePriceList()
- Returns:
- the last active PriceList
-
getLastActiveProductCategory
ProductCategory getLastActiveProductCategory()
- Returns:
- the last active ProductCategory
-
getBillCycleDayLocal
Integer getBillCycleDayLocal()
The billCycleDay should be interpreted in the account timezone. The billCycleDay is used to determine when to bill a specific subscription- Returns:
- the billCycleDay for that subscription
-
getQuantity
Integer getQuantity()
- Returns:
- the quantity or number of subscription that should be billed for.
-
cancelEntitlementWithDate
Entitlement cancelEntitlementWithDate(org.joda.time.LocalDate effectiveDate, boolean overrideBillingEffectiveDate, Iterable<PluginProperty> properties, CallContext context) throws EntitlementApiException
Cancels theEntitlementat the specified date. After this operation, the existing object becomes stale.- Parameters:
effectiveDate- the date at which the entitlement should be cancelledoverrideBillingEffectiveDate- use effectiveDate for billing cancellation date as well, instead of relying on default catalog policies.properties- plugin specific propertiescontext- the context- Returns:
- the new
Entitlementafter the cancellation was performed - Throws:
EntitlementApiException- if cancellation failedThe date is interpreted by the system to be in the timezone specified at the
Account
-
cancelEntitlementWithDate
Entitlement cancelEntitlementWithDate(org.joda.time.DateTime entitlementEffectiveDate, org.joda.time.DateTime billingEffectiveDate, Iterable<PluginProperty> properties, CallContext context) throws EntitlementApiException
Cancels theEntitlementwith the specified entitlementEffectiveDate and billingEffectiveDate After this operation, the existing object becomes stale.- Parameters:
entitlementEffectiveDate- the datetime at which the entitlement should be cancelledbillingEffectiveDate- the datetime at which billing should be cancelledproperties- plugin specific propertiescontext- the context- Returns:
- the new
Entitlementafter the cancellation was performed - Throws:
EntitlementApiException- if cancellation failedThe date is interpreted by the system to be in the timezone specified at the
Account
-
cancelEntitlementWithPolicy
Entitlement cancelEntitlementWithPolicy(Entitlement.EntitlementActionPolicy policy, Iterable<PluginProperty> properties, CallContext context) throws EntitlementApiException
Cancel theEntitlementwith a policy. After this operation, the existing object becomes stale.The billing effective date will be computed from the default catalog policies.
- Parameters:
policy- the policy that is used by the system to calculate the entitlement cancellation dateproperties- plugin specific propertiescontext- the context- Returns:
- the new
Entitlementafter the cancellation was performed - Throws:
EntitlementApiException- if cancellation failed
-
cancelEntitlementWithDateOverrideBillingPolicy
Entitlement cancelEntitlementWithDateOverrideBillingPolicy(org.joda.time.LocalDate effectiveDate, BillingActionPolicy billingPolicy, Iterable<PluginProperty> properties, CallContext context) throws EntitlementApiException
Cancels theEntitlementat the specified date After this operation, the existing object becomes stale.- Parameters:
effectiveDate- the date at which the entitlement should be cancelledbillingPolicy- the billingPolicy that should be use to compute the billing cancellation dateproperties- plugin specific propertiescontext- the context- Returns:
- the new
Entitlementafter the cancellation was performed - Throws:
EntitlementApiException- if cancellation failed
-
cancelEntitlementWithPolicyOverrideBillingPolicy
Entitlement cancelEntitlementWithPolicyOverrideBillingPolicy(Entitlement.EntitlementActionPolicy policy, BillingActionPolicy billingPolicy, Iterable<PluginProperty> properties, CallContext context) throws EntitlementApiException
Cancels theEntitlementat the specified date and overrides the default billing policy. After this operation, the existing object becomes stale.- Parameters:
policy- the policy that is used by the system to calculate the cancellation datebillingPolicy- the override billing policyproperties- plugin specific propertiescontext- the context- Returns:
- the new
Entitlementafter the cancellation was performed - Throws:
EntitlementApiException- if cancellation failed
-
uncancelEntitlement
void uncancelEntitlement(Iterable<PluginProperty> properties, CallContext context) throws EntitlementApiException
Removes a pending future cancellation on an entitlement.
The call will only succeed if the entitlement has been cancelled previously and if the effectiveDate of the cancellation did not occur yet. In such a case it will remove both the cancellation event at the entitlement and billing level-- regardless of when is the effectiveDate of the billing cancellation event.- Parameters:
properties- plugin specific propertiescontext- the context- Throws:
EntitlementApiException
-
changePlan
Entitlement changePlan(EntitlementSpecifier spec, Iterable<PluginProperty> properties, CallContext context) throws EntitlementApiException
ChangeEntitlementplan using default policy. After this operation, the existing object becomes stale.- Parameters:
spec- the product specification for the changeproperties- plugin specific propertiescontext- the context- Returns:
- the new
Entitlementafter the change was performed - Throws:
EntitlementApiException- if change failed
-
undoChangePlan
void undoChangePlan(Iterable<PluginProperty> properties, CallContext context) throws EntitlementApiException
- Parameters:
properties- plugin specific propertiescontext- the context- Throws:
EntitlementApiException
-
changePlanWithDate
Entitlement changePlanWithDate(EntitlementSpecifier spec, org.joda.time.LocalDate effectiveDate, Iterable<PluginProperty> properties, CallContext context) throws EntitlementApiException
ChangeEntitlementplan at the specified date. After this operation, the existing object becomes stale.- Parameters:
spec- the product specification for the changeeffectiveDate- the effective date at which the entitlement and billing should be changedproperties- plugin specific propertiescontext- the context- Returns:
- the new
Entitlementafter the change was performed - Throws:
EntitlementApiException- if change failed
-
changePlanWithDate
Entitlement changePlanWithDate(EntitlementSpecifier spec, org.joda.time.DateTime effectiveDate, Iterable<PluginProperty> properties, CallContext context) throws EntitlementApiException
ChangeEntitlementplan at the specified date. After this operation, the existing object becomes stale.- Parameters:
spec- the product specification for the changeeffectiveDate- the effective datetime at which the entitlement and billing should be changedproperties- plugin specific propertiescontext- the context- Returns:
- the new
Entitlementafter the change was performed - Throws:
EntitlementApiException- if change failed
-
changePlanOverrideBillingPolicy
Entitlement changePlanOverrideBillingPolicy(EntitlementSpecifier spec, org.joda.time.LocalDate effectiveDate, BillingActionPolicy billingPolicy, Iterable<PluginProperty> properties, CallContext context) throws EntitlementApiException
ChangeEntitlementplan at the specified date and overrides the billing policy. After this operation, the existing object becomes stale. The date is interpreted by the system to be in the timezone specified at theAccount- Parameters:
spec- the product specification for the changeeffectiveDate- unused (reserved for future use)billingPolicy- the overriden billing policy that will determine effective date for the changePlan operation.properties- plugin specific propertiescontext- the context- Returns:
- the new
Entitlementafter the change was performed - Throws:
EntitlementApiException- if change failed
-
updateBCD
void updateBCD(int bcd, org.joda.time.LocalDate effectiveFromDate, CallContext context) throws EntitlementApiException- Parameters:
bcd- the new BCD for that subscriptioneffectiveFromDate- date after which that BCD change becomes activecontext- the context- Throws:
EntitlementApiException
-
updateQuantity
void updateQuantity(int quantity, org.joda.time.LocalDate effectiveFromDate, CallContext context) throws EntitlementApiException- Parameters:
quantity- the quantity or equivalent number of subscriptions that should be billedeffectiveFromDate- date after which that quantity change becomes activecontext- the context- Throws:
EntitlementApiException
-
-