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