@@ 16-82 (lines=67) @@ | ||
13 | /** |
|
14 | * @author Ibrahim Hizeoui <[email protected]> |
|
15 | */ |
|
16 | class Customer extends HttpApi |
|
17 | { |
|
18 | /** |
|
19 | * @param array $param |
|
20 | * |
|
21 | * @return CustomerCollection|ResponseInterface |
|
22 | * |
|
23 | * @see https://billogram.com/api/documentation#customers_list |
|
24 | */ |
|
25 | public function search(array $param = []) |
|
26 | { |
|
27 | $param = array_merge(['page' => 1, 'page_size' => 100], $param); |
|
28 | $response = $this->httpGet('/customer', $param); |
|
29 | ||
30 | return $this->handleResponse($response, CustomerCollection::class); |
|
31 | } |
|
32 | ||
33 | /** |
|
34 | * @param int $customerNo |
|
35 | * |
|
36 | * @return Model|ResponseInterface |
|
37 | * |
|
38 | * @throws NotFoundException |
|
39 | * |
|
40 | * @see https://billogram.com/api/documentation#customers_fetch |
|
41 | */ |
|
42 | public function fetch(int $customerNo) |
|
43 | { |
|
44 | $response = $this->httpGet('/customer/'.$customerNo); |
|
45 | ||
46 | return $this->handleResponse($response, Model::class); |
|
47 | } |
|
48 | ||
49 | /** |
|
50 | * @param array $customer |
|
51 | * |
|
52 | * @return Model|ResponseInterface |
|
53 | * |
|
54 | * @throws ValidationException |
|
55 | * |
|
56 | * @see https://billogram.com/api/documentation#customers_create |
|
57 | */ |
|
58 | public function create(array $customer) |
|
59 | { |
|
60 | $response = $this->httpPost('/customer', $customer); |
|
61 | ||
62 | return $this->handleResponse($response, Model::class); |
|
63 | } |
|
64 | ||
65 | /** |
|
66 | * @param int $customerNo |
|
67 | * @param array $customer |
|
68 | * |
|
69 | * @return Model|ResponseInterface |
|
70 | * |
|
71 | * @throws NotFoundException |
|
72 | * @throws ValidationException |
|
73 | * |
|
74 | * @see https://billogram.com/api/documentation#customers_edit |
|
75 | */ |
|
76 | public function update(int $customerNo, array $customer) |
|
77 | { |
|
78 | $response = $this->httpPut('/customer/'.$customerNo, $customer); |
|
79 | ||
80 | return $this->handleResponse($response, Model::class); |
|
81 | } |
|
82 | } |
|
83 |
@@ 15-78 (lines=64) @@ | ||
12 | /** |
|
13 | * @author Ibrahim Hizeoui <[email protected]> |
|
14 | */ |
|
15 | class Invoice extends HttpApi |
|
16 | { |
|
17 | /** |
|
18 | * @param array $param |
|
19 | * |
|
20 | * @return InvoiceCollection|ResponseInterface |
|
21 | * |
|
22 | * @see https://billogram.com/api/documentation#billogram_call_create |
|
23 | */ |
|
24 | public function search(array $param = []) |
|
25 | { |
|
26 | $param = array_merge(['page' => 1, 'page_size' => 100], $param); |
|
27 | $response = $this->httpGet('/billogram', $param); |
|
28 | ||
29 | return $this->handleResponse($response, InvoiceCollection::class); |
|
30 | } |
|
31 | ||
32 | /** |
|
33 | * @param string $invoiceId |
|
34 | * |
|
35 | * @return Model|ResponseInterface |
|
36 | * |
|
37 | * @see https://billogram.com/api/documentation#billogram_call_create |
|
38 | */ |
|
39 | public function fetch(string $invoiceId) |
|
40 | { |
|
41 | $response = $this->httpGet('/billogram/'.$invoiceId); |
|
42 | ||
43 | return $this->handleResponse($response, Model::class); |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * @param array $invoice |
|
48 | * |
|
49 | * @return Model|ResponseInterface |
|
50 | * |
|
51 | * @see https://billogram.com/api/documentation#billogram_call_create |
|
52 | * |
|
53 | * @throws ValidationException |
|
54 | */ |
|
55 | public function create(array $invoice) |
|
56 | { |
|
57 | $response = $this->httpPost('/billogram', $invoice); |
|
58 | ||
59 | return $this->handleResponse($response, Model::class); |
|
60 | } |
|
61 | ||
62 | /** |
|
63 | * @param string $invoiceId |
|
64 | * @param array $invoice |
|
65 | * |
|
66 | * @return Model|ResponseInterface |
|
67 | * |
|
68 | * @see https://billogram.com/api/documentation#billogram_call_create |
|
69 | * |
|
70 | * @throws ValidationException |
|
71 | */ |
|
72 | public function update(string $invoiceId, array $invoice) |
|
73 | { |
|
74 | $response = $this->httpPut('/billogram/'.$invoiceId, $invoice); |
|
75 | ||
76 | return $this->handleResponse($response, Model::class); |
|
77 | } |
|
78 | } |
|
79 |