|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Invoice Ninja (https://invoiceninja.com). |
| 4 | + * |
| 5 | + * @link https://github.com/invoiceninja/sdk-php source repository |
| 6 | + * |
| 7 | + * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) |
| 8 | + * |
| 9 | + * @license https://opensource.org/licenses/MIT |
| 10 | + */ |
| 11 | + |
| 12 | +namespace InvoiceNinja\Sdk\Endpoints; |
| 13 | + |
| 14 | +use GuzzleHttp\Exception\GuzzleException; |
| 15 | +use InvoiceNinja\Sdk\InvoiceNinja; |
| 16 | + |
| 17 | +class Companies |
| 18 | +{ |
| 19 | + |
| 20 | + protected InvoiceNinja $ninja; |
| 21 | + |
| 22 | + protected string $uri = "/api/v1/companies"; |
| 23 | + |
| 24 | + public function __construct(InvoiceNinja $ninja) |
| 25 | + { |
| 26 | + $this->ninja = $ninja; |
| 27 | + } |
| 28 | + |
| 29 | + public function all(array $search = []) |
| 30 | + { |
| 31 | + $query = ['query' => $search]; |
| 32 | + |
| 33 | + return $this->ninja->send("GET", "{$this->uri}", $query); |
| 34 | + } |
| 35 | + |
| 36 | + public function get(string $entity_id, array $search = []) |
| 37 | + { |
| 38 | + $query = ['query' => $search]; |
| 39 | + |
| 40 | + return $this->ninja->send("GET", "{$this->uri}/{$entity_id}", $query); |
| 41 | + } |
| 42 | + |
| 43 | + public function update(string $entity_id, array $entity) |
| 44 | + { |
| 45 | + $query = ['form_params' => $entity]; |
| 46 | + |
| 47 | + return $this->ninja->send("PUT", "{$this->uri}/{$entity_id}", $query); |
| 48 | + } |
| 49 | + |
| 50 | + public function create(array $entity, array $includes = []) |
| 51 | + { |
| 52 | + $query = ['form_params' => $entity, 'query' => $includes]; |
| 53 | + |
| 54 | + return $this->ninja->send("POST", "{$this->uri}", $query); |
| 55 | + } |
| 56 | +} |
| 57 | + |
0 commit comments