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\Recipient as Domain; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Prawit <[email protected]> |
22
|
|
|
* |
23
|
|
|
* @see https://www.omise.co/recipients-api |
24
|
|
|
*/ |
25
|
|
|
final class Recipient 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', '/recipients', $parameters); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param Domain $recipient |
39
|
|
|
*/ |
40
|
1 |
|
public function create(Domain $recipient) |
41
|
|
|
{ |
42
|
1 |
|
$recipient->updateStore($this->doRequest('POST', '/recipients', $recipient->getCreateData())->toArray()); |
43
|
1 |
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param Domain $recipient |
47
|
|
|
*/ |
48
|
1 |
|
public function update(Domain $recipient) |
49
|
|
|
{ |
50
|
1 |
|
self::assertNotEmpty($recipient->id); |
51
|
|
|
|
52
|
1 |
|
$recipient->updateStore($this->doRequest('PATCH', '/recipients/' . $recipient->id, $recipient->getUpdateData())->toArray()); |
53
|
1 |
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param string $id |
57
|
|
|
* |
58
|
|
|
* @return Domain |
59
|
|
|
*/ |
60
|
4 |
|
public function find($id) |
61
|
|
|
{ |
62
|
4 |
|
self::assertNotEmpty($id); |
63
|
|
|
|
64
|
4 |
|
return $this->doRequest('GET', '/recipients/' . $id); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param Domain $recipient |
69
|
|
|
*/ |
70
|
1 |
|
public function refresh(Domain $recipient) |
71
|
|
|
{ |
72
|
1 |
|
$recipient->updateStore($this->find($recipient->id)->toArray()); |
73
|
1 |
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param Domain $recipient |
77
|
|
|
*/ |
78
|
1 |
|
public function destroy(Domain $recipient) |
79
|
|
|
{ |
80
|
1 |
|
self::assertNotEmpty($recipient->id); |
81
|
|
|
|
82
|
1 |
|
$recipient->updateStore($this->doRequest('DELETE', '/recipients/' . $recipient->id)->toArray()); |
83
|
1 |
|
} |
84
|
|
|
} |
85
|
|
|
|