|
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
|
|
|
|