Search in sources :

Example 1 with ApiEventCreate

use of org.killbill.billing.subscription.events.user.ApiEventCreate in project killbill by killbill.

the class DefaultSubscriptionBaseApiService method getEventsOnCreation.

@Override
public List<SubscriptionBaseEvent> getEventsOnCreation(final UUID bundleId, final UUID subscriptionId, final DateTime alignStartDate, final DateTime bundleStartDate, final Plan plan, final PhaseType initialPhase, final String realPriceList, final DateTime effectiveDate, final DateTime processedDate, final InternalTenantContext internalTenantContext) throws CatalogApiException, SubscriptionBaseApiException {
    final TimedPhase[] curAndNextPhases = planAligner.getCurrentAndNextTimedPhaseOnCreate(alignStartDate, bundleStartDate, plan, initialPhase, realPriceList, effectiveDate, internalTenantContext);
    final ApiEventBuilder createBuilder = new ApiEventBuilder().setSubscriptionId(subscriptionId).setEventPlan(plan.getName()).setEventPlanPhase(curAndNextPhases[0].getPhase().getName()).setEventPriceList(realPriceList).setEffectiveDate(effectiveDate).setFromDisk(true);
    final SubscriptionBaseEvent creationEvent = new ApiEventCreate(createBuilder);
    final TimedPhase nextTimedPhase = curAndNextPhases[1];
    final PhaseEvent nextPhaseEvent = (nextTimedPhase != null) ? PhaseEventData.createNextPhaseEvent(subscriptionId, nextTimedPhase.getPhase().getName(), nextTimedPhase.getStartPhase()) : null;
    final List<SubscriptionBaseEvent> events = new ArrayList<SubscriptionBaseEvent>();
    events.add(creationEvent);
    if (nextPhaseEvent != null) {
        events.add(nextPhaseEvent);
    }
    return events;
}
Also used : ApiEventCreate(org.killbill.billing.subscription.events.user.ApiEventCreate) PhaseEvent(org.killbill.billing.subscription.events.phase.PhaseEvent) ApiEventBuilder(org.killbill.billing.subscription.events.user.ApiEventBuilder) TimedPhase(org.killbill.billing.subscription.alignment.TimedPhase) ArrayList(java.util.ArrayList) SubscriptionBaseEvent(org.killbill.billing.subscription.events.SubscriptionBaseEvent) PlanPhasePriceOverride(org.killbill.billing.catalog.api.PlanPhasePriceOverride)

Aggregations

ArrayList (java.util.ArrayList)1 PlanPhasePriceOverride (org.killbill.billing.catalog.api.PlanPhasePriceOverride)1 TimedPhase (org.killbill.billing.subscription.alignment.TimedPhase)1 SubscriptionBaseEvent (org.killbill.billing.subscription.events.SubscriptionBaseEvent)1 PhaseEvent (org.killbill.billing.subscription.events.phase.PhaseEvent)1 ApiEventBuilder (org.killbill.billing.subscription.events.user.ApiEventBuilder)1 ApiEventCreate (org.killbill.billing.subscription.events.user.ApiEventCreate)1