Exemple #1
0
 /**
  * Get all the coupons.
  * @param array $options
  * @return array
  */
 public function all($options = array())
 {
     $request = new Request($this->client);
     $path = "/coupons";
     $data = array();
     $response = $request->get($path, $data, $options);
     $returnValues = array();
     // Handling for field coupons
     $a = array();
     $body = $response->getBody();
     foreach ($body['coupons'] as $v) {
         $tmp = new Coupon($this->client);
         $tmp->fillWithData($v);
         $a[] = $tmp;
     }
     $returnValues['Coupons'] = $a;
     return array_values($returnValues)[0];
 }
 /**
  * Set Coupon
  * Coupon used to create this discount, if any
  * @param  object $value
  * @return $this
  */
 public function setCoupon($value)
 {
     if (is_object($value)) {
         $this->coupon = $value;
     } else {
         $obj = new Coupon($this->client);
         $obj->fillWithData($value);
         $this->coupon = $obj;
     }
     return $this;
 }