/** * Get the customer linked to the authorization request. * @param array $options * @return Customer */ public function fetchCustomer($options = array()) { $request = new Request($this->client); $path = "/authorization-requests/" . urlencode($this->getId()) . "/customers"; $data = array(); $response = $request->get($path, $data, $options); $returnValues = array(); // Handling for field customer $body = $response->getBody(); $body = $body['customer']; $customer = new Customer($this->client); $returnValues['customer'] = $customer->fillWithData($body); return array_values($returnValues)[0]; }
/** * Get all the customers. * @param array $options * @return array */ public function all($options = array()) { $request = new Request($this->client); $path = "/customers"; $data = array(); $response = $request->get($path, $data, $options); $returnValues = array(); // Handling for field customers $a = array(); $body = $response->getBody(); foreach ($body['customers'] as $v) { $tmp = new Customer($this->client); $tmp->fillWithData($v); $a[] = $tmp; } $returnValues['Customers'] = $a; return array_values($returnValues)[0]; }
/** * Assign a customer to the invoice. * @param string $customerId * @param array $options * @return Customer */ public function assignCustomer($customerId, $options = array()) { $request = new Request($this->client); $path = "/invoices/" . urlencode($this->getId()) . "/customers"; $data = array("customer_id" => $customerId); $response = $request->post($path, $data, $options); $returnValues = array(); // Handling for field customer $body = $response->getBody(); $body = $body['customer']; $customer = new Customer($this->client); $returnValues['customer'] = $customer->fillWithData($body); return array_values($returnValues)[0]; }
/** * Set Customer * Customer owning the token * @param object $value * @return $this */ public function setCustomer($value) { if (is_object($value)) { $this->customer = $value; } else { $obj = new Customer($this->client); $obj->fillWithData($value); $this->customer = $obj; } return $this; }