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

Transfer   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

7 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 4 1
A create() 0 6 1
A createWithRecipient() 0 8 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\Transfer as Domain;
16
use PhpMob\Omise\Domain\Pagination;
17
18
/**
19
 * @author Prawit <[email protected]>
20
 *
21
 * @see https://www.omise.co/transfer-api
22
 */
23
final class Transfer 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', '/transfers', $parameters);
33
    }
34
35
    /**
36
     * @param Domain $transfers
37
     */
38
    public function create(Domain $transfers)
39
    {
40
        $data = $transfers->getCreateData();
41
42
        $transfers->updateStore($this->doRequest('POST', '/transfers', $data)->toArray());
43
    }
44
45
    /**
46
     * @param Domain $transfers
47
     */
48
    public function createWithRecipient(Domain $transfers)
49
    {
50
        $data = $transfers->getCreateData();
51
52
        self::assertNotEmpty(@$data['recipient'], 'Recipient Id can not be empty.');
53
54
        $this->create($transfers);
55
    }
56
57
    /**
58
     * @param Domain $transfers
59
     */
60
    public function update(Domain $transfers)
61
    {
62
        self::assertNotEmpty($transfers->id);
63
64
        $transfers->updateStore($this->doRequest('PATCH', '/transfers/'.$transfers->id, $transfers->getUpdateData())->toArray());
65
    }
66
67
    /**
68
     * @param string $id
69
     *
70
     * @return Domain
71
     */
72
    public function find($id)
73
    {
74
        self::assertNotEmpty($id);
75
76
        return $this->doRequest('GET', '/transfers/'.$id);
77
    }
78
79
    /**
80
     * @param Domain $transfers
81
     */
82
    public function refresh(Domain $transfers)
83
    {
84
        $transfers->updateStore($this->find($transfers->id)->toArray());
85
    }
86
87
    /**
88
     * @param Domain $transfers
89
     */
90
    public function destroy(Domain $transfers)
91
    {
92
        self::assertNotEmpty($transfers->id);
93
94
        $transfers->updateStore($this->doRequest('DELETE', '/transfers/'.$transfers->id)->toArray());
95
    }
96
}
97