protected function doUnserialize(array $json) { // consult parent for further unserialization parent::doUnserialize($json); $this->unserializeArrayEntities('taxation', Bf_TaxationLink::getClassName(), $json); $this->unserializeArrayEntities('pricingComponents', Bf_PricingComponent::getClassName(), $json); $this->unserializeEntity('product', Bf_Product::getClassName(), $json); $this->unserializeEntity('metadata', Bf_MetadataJson::getClassName(), $json); }
/** * Constructs a Bf_CouponDiscount model. * @param string_ENUM['percentageDiscount', 'cashDiscount', 'unitsFree'] Nature of the discount being conferred. *** * <percentageDiscount> * Discounts from the price of the specified pricing component: a percentage. * Example: $amount = 31 // 31% discount * * <cashDiscount> * Discounts from the price of the specified pricing component: a lump sum. * Example: $amount = 31 // $31 discount * * <unitsFree> * Discounts from the price of the specified pricing component: a quantity of units. * Example: $amount = 31 // 31 ice creams free *** * @param union[string ($id | $name) | Bf_PricingComponent $entity] The pricing component to which the discount is applied. <string>: ID or name of the Bf_PricingComponent. <Bf_PricingComponent>: The Bf_PricingComponent. * @param number The magnitude of the discount being conferred. * @return Bf_CouponDiscount The created coupon discount. */ public static function construct($discountNature, $pricingComponent, $amount) { $pricingComponentIdentifier = Bf_PricingComponent::getIdentifier($pricingComponent); $model = new static(); $model->pricingComponent = $pricingComponentIdentifier; if ($discountNature === 'percentageDiscount') { $model->percentageDiscount = $amount; } else { if ($discountNature === 'cashDiscount') { $model->cashDiscount = $amount; } else { if ($discountNature === 'unitsFree') { $model->unitsFree = $amount; } else { throw new Bf_UnsupportedParameterException("Unsupported/unrecognised 'discountNature': '{$discountNature}'."); } } } return $model; }
/** * Removes for the specified subscription pending value changes for the given pricing component * @param union[string($id|$name) | Bf_PricingComponent] Reference to pricing component whose pending changes you wish to discard. <string>: ID or name of the Bf_PricingComponent. <Bf_PricingComponent>: The Bf_PricingComponent. * @param union[string | Bf_Subscription] $subscription The Bf_Subscription from which the Bf_PricingComponent should be removed. <string>: ID of the Bf_Subscription. <Bf_Subscription>: The Bf_Subscription. * @return Bf_PricingComponentValue[] The remaining pricing component values in effect for the provided Bf_PricingComponent */ public static function removePendingValueChangeFromSubscription($pricingComponent, $subscription, $queryParams = array()) { $subscriptionID = Bf_Subscription::getIdentifier($subscription); $pricingComponentRef = Bf_PricingComponent::getIdentifier($pricingComponent); $endpoint = sprintf("%s/values/%s", rawurlencode($subscriptionID), rawurlencode($pricingComponentRef)); $responseEntity = Bf_PricingComponentValue::getClassName(); return static::retireAndGrabCollection($endpoint, NULL, $customClient, $responseEntity, $queryParams); }
public static function initStatics() { self::$_resourcePath = new Bf_ResourcePath('pricing-components', 'PricingComponent'); }