/** * Get all the invoices. * @param array $options * @return array */ public function all($options = array()) { $request = new Request($this->client); $path = "/invoices"; $data = array(); $response = $request->get($path, $data, $options); $returnValues = array(); // Handling for field invoices $a = array(); $body = $response->getBody(); foreach ($body['invoices'] as $v) { $tmp = new Invoice($this->client); $tmp->fillWithData($v); $a[] = $tmp; } $returnValues['Invoices'] = $a; return array_values($returnValues)[0]; }
/** * Create a new invoice from the product. * @param array $options * @return Invoice */ public function createInvoice($options = array()) { $request = new Request($this->client); $path = "/products/" . urlencode($this->getId()) . "/invoices"; $data = array(); $response = $request->post($path, $data, $options); $returnValues = array(); // Handling for field invoice $body = $response->getBody(); $body = $body['invoice']; $invoice = new Invoice($this->client); $returnValues['invoice'] = $invoice->fillWithData($body); return array_values($returnValues)[0]; }