Ejemplo n.º 1
0
 /**
  * Implements Base\BaseObject::__toString().
  *
  * @return string
  */
 public function __toString()
 {
     $endDate = $startDate = '';
     $endDateTime = $this->getEndDateTime();
     $startDateTime = $this->getStartDateTime();
     if ($endDateTime instanceof DateTime) {
         $endDate = $endDateTime->format('Y-m-d H:i:s');
     }
     if ($startDateTime instanceof DateTime) {
         $startDate = $startDateTime->format('Y-m-d H:i:s');
     }
     $obj = array('developer' => array('id' => $this->developer_or_company_id), 'endDate' => $endDate, 'startDate' => $startDate, 'id' => $this->id, 'ratePlan' => null);
     if (isset($this->ratePlan)) {
         $obj['ratePlan'] = array('id' => $this->ratePlan->getId());
     }
     return json_encode($obj);
 }
Ejemplo n.º 2
0
 /**
  * Set Parent Rate Plan
  * @param \Apigee\Mint\RatePlan $parent_rate_plan
  */
 public function setParentRatePlan(RatePlan $parent_rate_plan)
 {
     $parent_rate_plan->setChildRatePlan($this);
     $this->parentRatePlan = $parent_rate_plan;
 }
Ejemplo n.º 3
0
 /**
  * Retrieve the ratePlan associated with a given product
  * @param string $product_id
  *   Product Id
  * @param string $developer_id
  *   Developer email
  * @throws ParameterException
  *   Throw if no developer id is provided or email property is null
  * @throws MintApiException
  *   Throw if Exception is related to Mint API
  * @throws \Exception
  *   Throw if any other exception
  * @return \Apigee\Mint\RatePlan
  *   The RatePlan associated to this Product
  */
 public function getRatePlanByProduct($product_id, $developer_id = null)
 {
     if (empty($developer_id)) {
         if (!empty($this->email)) {
             $developer_id = $this->email;
         } else {
             throw new ParameterException("Developer id not specified");
         }
     }
     try {
         $url = rawurlencode($developer_id) . '/products/' . rawurlencode($product_id) . '/rate-plan-by-developer-product/';
         $this->get($url);
         $ratePlan = new RatePlan(null, $this->config);
         $ratePlan->loadFromRawData($this->responseObj);
         return $ratePlan;
     } catch (\Exception $e) {
         if (MintApiException::isMintExceptionCode($e)) {
             throw new MintApiException($e);
         } else {
             throw $e;
         }
     }
     return $products;
 }