Completed
Push — master ( 6d9ae5...9656aa )
by
18:43 queued 08:49
created

Recipient   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 60
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 4 1
A create() 0 4 1
A update() 0 6 1
A find() 0 6 1
A refresh() 0 4 1
A destroy() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the PhpMob package.
5
 *
6
 * (c) Ishmael Doss <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PhpMob\Omise\Api;
13
14
use PhpMob\Omise\Api;
15
use PhpMob\Omise\Domain\Recipient as Domain;
16
use PhpMob\Omise\Domain\Pagination;
17
18
/**
19
 * @author Prawit <[email protected]>
20
 *
21
 * @see https://www.omise.co/recipients-api
22
 */
23
final class Recipient extends Api
24
{
25
    /**
26
     * @param array $parameters
27
     *
28
     * @return Pagination
29
     */
30
    public function all(array $parameters = [])
31
    {
32
        return $this->doRequest('GET', '/recipients', $parameters);
33
    }
34
35
    /**
36
     * @param Domain $recipient
37
     */
38
    public function create(Domain $recipient)
39
    {
40
        $recipient->updateStore($this->doRequest('POST', '/recipients', $recipient->getCreateData())->toArray());
41
    }
42
43
    /**
44
     * @param Domain $recipient
45
     */
46
    public function update(Domain $recipient)
47
    {
48
        self::assertNotEmpty($recipient->id);
49
50
        $recipient->updateStore($this->doRequest('PATCH', '/recipients/'.$recipient->id, $recipient->getUpdateData())->toArray());
51
    }
52
53
    /**
54
     * @param string $id
55
     *
56
     * @return Domain
57
     */
58
    public function find($id)
59
    {
60
        self::assertNotEmpty($id);
61
62
        return $this->doRequest('GET', '/recipients/'.$id);
63
    }
64
65
    /**
66
     * @param Domain $recipient
67
     */
68
    public function refresh(Domain $recipient)
69
    {
70
        $recipient->updateStore($this->find($recipient->id)->toArray());
71
    }
72
73
    /**
74
     * @param Domain $recipient
75
     */
76
    public function destroy(Domain $recipient)
77
    {
78
        self::assertNotEmpty($recipient->id);
79
80
        $recipient->updateStore($this->doRequest('DELETE', '/recipients/'.$recipient->id)->toArray());
81
    }
82
}
83