Search in sources :

Example 1 with BlockPriceJson

use of org.killbill.billing.jaxrs.json.BlockPriceJson in project killbill by killbill.

the class SubscriptionResourceHelpers method buildUsagePrices.

private static void buildUsagePrices(final Currency currency, final PhasePriceJson input, final Collection<UsagePriceOverride> usagePrices) {
    for (final UsagePriceJson usageOverrideJson : input.getUsagePrices()) {
        final List<TierPriceOverride> tierPriceOverrides = new LinkedList<TierPriceOverride>();
        for (final TierPriceJson tierPriceJson : usageOverrideJson.getTierPrices()) {
            final List<TieredBlockPriceOverride> blockPriceOverrides = new LinkedList<TieredBlockPriceOverride>();
            for (final BlockPriceJson block : tierPriceJson.getBlockPrices()) {
                blockPriceOverrides.add(new TieredBlockPriceOverride() {

                    @Override
                    public String getUnitName() {
                        return block.getUnitName();
                    }

                    @Override
                    public Double getSize() {
                        return block.getSize();
                    }

                    @Override
                    public BigDecimal getPrice() {
                        return block.getPrice();
                    }

                    @Override
                    public Currency getCurrency() {
                        return currency;
                    }

                    @Override
                    public Double getMax() {
                        return block.getMax();
                    }
                });
            }
            tierPriceOverrides.add(new TierPriceOverride() {

                @Override
                public List<TieredBlockPriceOverride> getTieredBlockPriceOverrides() {
                    return blockPriceOverrides;
                }
            });
        }
        usagePrices.add(new UsagePriceOverride() {

            @Override
            public String getName() {
                return usageOverrideJson.getUsageName();
            }

            @Override
            public UsageType getUsageType() {
                return usageOverrideJson.getUsageType();
            }

            @Override
            public List<TierPriceOverride> getTierPriceOverrides() {
                return tierPriceOverrides;
            }
        });
    }
}
Also used : TieredBlockPriceOverride(org.killbill.billing.catalog.api.TieredBlockPriceOverride) TierPriceOverride(org.killbill.billing.catalog.api.TierPriceOverride) UsagePriceOverride(org.killbill.billing.catalog.api.UsagePriceOverride) TierPriceJson(org.killbill.billing.jaxrs.json.TierPriceJson) UsageType(org.killbill.billing.catalog.api.UsageType) LinkedList(java.util.LinkedList) BigDecimal(java.math.BigDecimal) UsagePriceJson(org.killbill.billing.jaxrs.json.UsagePriceJson) Currency(org.killbill.billing.catalog.api.Currency) List(java.util.List) LinkedList(java.util.LinkedList) BlockPriceJson(org.killbill.billing.jaxrs.json.BlockPriceJson) PlanPhasePriceOverride(org.killbill.billing.catalog.api.PlanPhasePriceOverride) TierPriceOverride(org.killbill.billing.catalog.api.TierPriceOverride) UsagePriceOverride(org.killbill.billing.catalog.api.UsagePriceOverride) TieredBlockPriceOverride(org.killbill.billing.catalog.api.TieredBlockPriceOverride)

Aggregations

BigDecimal (java.math.BigDecimal)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Currency (org.killbill.billing.catalog.api.Currency)1 PlanPhasePriceOverride (org.killbill.billing.catalog.api.PlanPhasePriceOverride)1 TierPriceOverride (org.killbill.billing.catalog.api.TierPriceOverride)1 TieredBlockPriceOverride (org.killbill.billing.catalog.api.TieredBlockPriceOverride)1 UsagePriceOverride (org.killbill.billing.catalog.api.UsagePriceOverride)1 UsageType (org.killbill.billing.catalog.api.UsageType)1 BlockPriceJson (org.killbill.billing.jaxrs.json.BlockPriceJson)1 TierPriceJson (org.killbill.billing.jaxrs.json.TierPriceJson)1 UsagePriceJson (org.killbill.billing.jaxrs.json.UsagePriceJson)1