Transfer::find()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 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
declare(strict_types=1);
13
14
namespace PhpMob\Omise\Api;
15
16
use PhpMob\Omise\Api;
17
use PhpMob\Omise\Domain\Pagination;
18
use PhpMob\Omise\Domain\Transfer as Domain;
19
20
/**
21
 * @author Prawit <[email protected]>
22
 *
23
 * @see https://www.omise.co/transfer-api
24
 */
25
final class Transfer extends Api
26
{
27
    /**
28
     * @param array $parameters
29
     *
30
     * @return Pagination
31
     */
32 1
    public function all(array $parameters = [])
33
    {
34 1
        return $this->doRequest('GET', '/transfers', $parameters);
35
    }
36
37
    /**
38
     * @param Domain $transfers
39
     */
40 2
    public function create(Domain $transfers)
41
    {
42 2
        $data = $transfers->getCreateData();
43
44 2
        $transfers->updateStore($this->doRequest('POST', '/transfers', $data)->toArray());
45 2
    }
46
47
    /**
48
     * @param Domain $transfers
49
     */
50 1
    public function createWithRecipient(Domain $transfers)
51
    {
52 1
        $data = $transfers->getCreateData();
53
54 1
        self::assertNotEmpty(@$data['recipient'], 'Recipient Id can not be empty.');
55
56 1
        $this->create($transfers);
57 1
    }
58
59
    /**
60
     * @param Domain $transfers
61
     */
62
    public function update(Domain $transfers)
63
    {
64
        self::assertNotEmpty($transfers->id);
65
66
        $transfers->updateStore($this->doRequest('PATCH', '/transfers/' . $transfers->id, $transfers->getUpdateData())->toArray());
67
    }
68
69
    /**
70
     * @param string $id
71
     *
72
     * @return Domain
73
     */
74 3
    public function find($id)
75
    {
76 3
        self::assertNotEmpty($id);
77
78 2
        return $this->doRequest('GET', '/transfers/' . $id);
79
    }
80
81
    /**
82
     * @param Domain $transfers
83
     */
84 1
    public function refresh(Domain $transfers)
85
    {
86 1
        $transfers->updateStore($this->find($transfers->id)->toArray());
87 1
    }
88
89
    /**
90
     * @param Domain $transfers
91
     */
92
    public function destroy(Domain $transfers)
93
    {
94
        self::assertNotEmpty($transfers->id);
95
96
        $transfers->updateStore($this->doRequest('DELETE', '/transfers/' . $transfers->id)->toArray());
97
    }
98
}
99