Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2013 Ning, Inc.
   *
   * Ning licenses this file to you under the Apache License, version 2.0
   * (the "License"); you may not use this file except in compliance with the
   * License.  You may obtain a copy of the License at:
   *
   *    http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
  * License for the specific language governing permissions and limitations
  * under the License.
  */
 
 package com.ning.billing.entitlement.api;
 
 
 
 import java.util.UUID;

An Entitlement is created using the EntitlementApi

It contains all the catalog information and current state that answers the entitlement question.

The users of that API will control all the entitlement behavior when making changes such as the effectiveDate, catalog info,... By default the system will use system wide policies to control the billing aspect, but specific APIs also allow to override those.

See also:
EntitlementApi
 
 public interface Entitlement extends Entity {

    
Used to control the effective date that should be used on Plan change or on cancellation.
 
     public enum EntitlementActionPolicy {
         /* Immediate */
         IMMEDIATE,
         /* End of Term */
         END_OF_TERM
     }

    
Possible states of an Entitlement
 
     public enum EntitlementState {
         /* The entitlement was created in that initial state */
         ACTIVE,
         /* The system blocked the entitlement */
         BLOCKED,
         /* The user cancelled the entitlement */
         CANCELLED
     }

    
Possible Entitlement source types.
 
     public enum EntitlementSourceType {
         NATIVE,
         MIGRATED,
         TRANSFERRED
     }

    

Returns:
the unique id of the base entitlement
 
     public UUID getBaseEntitlementId();


    

Returns:
the unique Id of the SubscriptionBundle
 
     public UUID getBundleId();
    

Returns:
the account id
 
     public UUID getAccountId();

    

Returns:
the external key that was supplied when creating the base entitlement
 
     public String getExternalKey();

    

Returns:
the state of the entitlement
    public EntitlementState getState();

    

Returns:
the entitlement source type
    public EntitlementSourceType getSourceType();

    

Returns:
the start date of the entitlement
    public LocalDate getEffectiveStartDate();

    

Returns:
the end date of the entitlement, that is the date at which it got cancelled.
    public LocalDate getEffectiveEndDate();

    

Returns:
the last Product prior to cancellation
    public Product getLastActiveProduct();

    

Returns:
the last Plan prior to cancellation
    public Plan getLastActivePlan();

    

Returns:
the last Phase prior to cancellation
    public PlanPhase getLastActivePhase();

    

Returns:
the last active PriceList
    public PriceList getLastActivePriceList();

    

Returns:
the last active ProductCategory
Cancels the Entitlement at the specified date. After this operation, the existing object becomes stale.

The date is interpreted by the system to be in the timezone specified at the Account

Parameters:
effectiveDate the date at which the entitlement should be cancelled
overrideBillingEffectiveDate use effectiveDate for billing cancellation date as well
context the context
Returns:
the new Entitlement after the cancellation was performed
Throws:
EntitlementApiException if cancellation failed
    public Entitlement cancelEntitlementWithDate(final LocalDate effectiveDatefinal boolean overrideBillingEffectiveDatefinal CallContext context)
            throws EntitlementApiException;


    
Cancel the Entitlement with a policy. After this operation, the existing object becomes stale.

Parameters:
policy the policy that is used by the system to calculate the cancellation date
context the context
Returns:
the new Entitlement after the cancellation was performed
Throws:
EntitlementApiException if cancellation failed
    public Entitlement cancelEntitlementWithPolicy(final EntitlementActionPolicy policyfinal CallContext context)
            throws EntitlementApiException;


    
Cancels the Entitlement at the specified date After this operation, the existing object becomes stale.

The date is interpreted by the system to be in the timezone specified at the Account

Parameters:
effectiveDate the date at which the entitlement should be cancelled
billingPolicy the billingPolicy
context the context
Returns:
the new Entitlement after the cancellation was performed
Throws:
EntitlementApiException if cancellation failed
    public Entitlement cancelEntitlementWithDateOverrideBillingPolicy(final LocalDate effectiveDatefinal BillingActionPolicy billingPolicyfinal CallContext context)
            throws EntitlementApiException;


    
Cancels the Entitlement at 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 date
billingPolicy the override billing policy
context the context
Returns:
the new Entitlement after the cancellation was performed
Throws:
EntitlementApiException if cancellation failed
    public Entitlement cancelEntitlementWithPolicyOverrideBillingPolicy(final EntitlementActionPolicy policyfinal BillingActionPolicy billingPolicyfinal 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:
context the context
    public void uncancelEntitlement(final CallContext context)
            throws EntitlementApiException;

    
Change Entitlement plan using default policy. After this operation, the existing object becomes stale.

The date is interpreted by the system to be in the timezone specified at the Account

Parameters:
productName the new product name
billingPeriod the new billing period
priceList the new priceList
context the context
Returns:
the new Entitlement after the change was performed
Throws:
EntitlementApiException if change failed
    public Entitlement changePlan(final String productNamefinal BillingPeriod billingPeriodfinal String priceListfinal CallContext context)
            throws EntitlementApiException;

    
Change Entitlement plan at the specified date. After this operation, the existing object becomes stale.

The date is interpreted by the system to be in the timezone specified at the Account

Parameters:
productName the new product name
billingPeriod the new billing period
priceList the new priceList
effectiveDate the date at which the entitlement should be changed
context the context
Returns:
the new Entitlement after the change was performed
Throws:
EntitlementApiException if change failed
    public Entitlement changePlanWithDate(final String productNamefinal BillingPeriod billingPeriodfinal String priceListfinal LocalDate effectiveDatefinal CallContext context)
            throws EntitlementApiException;


    
Change Entitlement plan 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 the Account

Parameters:
productName the new product name
billingPeriod the new billing period
priceList the new priceList
effectiveDate the date at which the entitlement should be changed
billingPolicy the override billing policy
context the context
Returns:
the new Entitlement after the change was performed
Throws:
EntitlementApiException if change failed
    public Entitlement changePlanOverrideBillingPolicy(final String productNamefinal BillingPeriod billingPeriodfinal String priceListfinal LocalDate effectiveDate,
                                                   final BillingActionPolicy billingPolicyfinal CallContext context)
            throws EntitlementApiException;


    
Pauses an Entitlement until it gets resumed. After this operation, the existing object becomes stale.

The date is interpreted by the system to be in the timezone specified at the Account

Parameters:
serviceName the service name of who is blocking
effectiveDate the date at which the entitlement should be paused
context the context
Returns:
the new Entitlement after the operation was performed
Throws:
EntitlementApiException if the entitlement was not in ACTIVE state public Entitlement block(String serviceName, final LocalDate effectiveDate, final CallContext context) throws EntitlementApiException;


    
Resumes an Entitlement that was paused After this operation, the existing object becomes stale.

The date is interpreted by the system to be in the timezone specified at the Account

Parameters:
serviceName the service name of who is blocking
effectiveDate the date at which the entitlement should be resumed
context the context
Returns:
the new Entitlement after the operation was performed
Throws:
EntitlementApiException public Entitlement unblock(String serviceName, final LocalDate effectiveDate, final CallContext context) throws EntitlementApiException;
New to GrepCode? Check out our FAQ X