Customers::update()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Lifeboat\Services;
4
5
use Lifeboat\Exceptions\ApiException;
6
use Lifeboat\Exceptions\OAuthException;
7
use Lifeboat\Models\Customer;
8
use Lifeboat\Resource\ListResource;
9
10
/**
11
 * Class Customers
12
 * @package Lifeboat\Services
13
 */
14
class Customers extends ApiService {
15
16
    /**
17
     * @param int $id
18
     * @return Customer|null
19
     * @throws ApiException
20
     * @throws OAuthException
21
     */
22
    public function fetch(int $id): ?Customer
23
    {
24
        /** @var Customer|null $fetch */
25
        $fetch = $this->_get('api/customers/customer' . $id);
26
        return $fetch;
27
    }
28
29
    /**
30
     * @param array $data
31
     * @return Customer|null
32
     * @throws ApiException
33
     * @throws OAuthException
34
     */
35
    public function create(array $data): ?Customer
36
    {
37
        /** @var Customer|null $create */
38
        $create = $this->_post('api/customers/customer', $data);
39
        return $create;
40
    }
41
42
    /**
43
     * @param int $id
44
     * @param array $data
45
     * @return Customer|null
46
     * @throws ApiException
47
     * @throws OAuthException
48
     */
49
    public function update(int $id, array $data): ?Customer
50
    {
51
        /** @var Customer|null $post */
52
        $post = $this->_post('api/customers/customer/' . $id, $data);
53
        return $post;
54
    }
55
56
    /**
57
     * @param string $search
58
     * @return ListResource
59
     */
60
    public function all(string $search = ''): ListResource {
61
        return new ListResource($this->getClient(), 'api/customers/all', ['search' => $search], 20);
62
    }
63
}
64