/** * Gets (by name or ID) Bf_ProductRatePlans belonging to a Bf_Product by name or ID * @param union[string ($id | $name) | Bf_Product $entity] $product The Product whose rate plans you wish to GET. <string>: ID or name of the Bf_Product. <Bf_Product>: The Bf_Product. * @param union[string ($id | $name) | Bf_ProductRatePlan $entity] $ratePlan The ProductRatePlan that you wish to GET from that Product. <string>: ID or name of the Bf_ProductRatePlan. <Bf_ProductRatePlan>: The Bf_ProductRatePlan. * @return Bf_ProductRatePlan */ public static function getByProductAndRatePlanID($product, $ratePlan, $queryParams = array(), $customClient = NULL) { $productID = Bf_Product::getIdentifier($product); $ratePlanID = Bf_ProductRatePlan::getIdentifier($ratePlan); $endpoint = sprintf("product/%s/rate-plan/%s", rawurlencode($productID), rawurlencode($ratePlanID)); return static::getFirst($endpoint, $queryParams, $customClient); }
/** * Assigns to this Bf_Coupon a Bf_ProductRatePlan and Bf_Product. * @param union[string ($id | $name) | Bf_ProductRatePlan $ratePlan] The product discounted by the coupon. <string>: ID or name of the Bf_ProductRatePlan. <Bf_ProductRatePlan>: The Bf_ProductRatePlan. * @param union[string ($id | $name) | Bf_Product $entity | NULL] (Default: NULL) The product discounted by the coupon. <string>: ID or name of the Bf_Product. <Bf_Product>: The Bf_Product. <NULL>: Fetch first result for Bf_ProductRatePlan (if identifying rate plan by name, please ensure this rate plan's name is unique), and use its Bf_Product. * @return Bf_Coupon The modified coupon model. */ public function setRatePlan($ratePlan, $product = NULL) { if (is_null($product)) { // get rate plan $ratePlanEntity = Bf_ProductRatePlan::fetchIfNecessary($ratePlan); $product = $ratePlanEntity->productID; } $productIdentifier = Bf_Product::getIdentifier($product); $ratePlanIdentifier = Bf_ProductRatePlan::getIdentifier($ratePlan); $this->product = $productIdentifier; $this->productRatePlan = $ratePlanIdentifier; return $this; }
/** * Gets Bf_Subscriptions for a given product ID * @param union[string | Bf_Product] $product The Bf_Product to which the Bf_Coupon should be applied. <string>: ID of the Bf_Product. <Bf_Product>: The Bf_Product. * @return Bf_Subscription[] */ public static function getByProductID($product, $options = NULL, $customClient = NULL) { $product = Bf_Product::getIdentifier($product); $endpoint = sprintf("product/%s", rawurlencode($product)); return static::getCollection($endpoint, $options, $customClient); }