Completed
Push — master ( f2b799...761b51 )
by Tobias
04:02
created

src/Api/Customer.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Billogram\Api;
6
7
use Billogram\Exception\Domain\NotFoundException;
8
use Billogram\Exception\Domain\ValidationException;
9
use Billogram\Model\Customer\Customer as Model;
10
use Billogram\Model\Customer\CustomerCollection;
11
use Psr\Http\Message\ResponseInterface;
12
13
/**
14
 * @author Ibrahim Hizeoui <[email protected]>
15
 */
16 View Code Duplication
class Customer extends HttpApi
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    /**
19
     * @param array $param
20
     *
21
     * @return CustomerCollection|ResponseInterface
22
     *
23
     * @see https://billogram.com/api/documentation#customers_list
24
     */
25 1
    public function search(array $param = [])
26
    {
27 1
        $param = array_merge(['page' => 1, 'page_size' => 100], $param);
28 1
        $response = $this->httpGet('/customer', $param);
29
30 1
        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 1
    public function fetch(int $customerNo)
43
    {
44 1
        $response = $this->httpGet('/customer/'.$customerNo);
45
46 1
        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 1
    public function create(array $customer)
59
    {
60 1
        $response = $this->httpPost('/customer', $customer);
61
62 1
        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 1
    public function update(int $customerNo, array $customer)
77
    {
78 1
        $response = $this->httpPut('/customer/'.$customerNo, $customer);
79
80 1
        return $this->handleResponse($response, Model::class);
81
    }
82
}
83