1 | <?php |
||
2 | |||
3 | namespace kamerk22\AmazonGiftCode; |
||
4 | |||
5 | use kamerk22\AmazonGiftCode\AWS\AWS; |
||
6 | use kamerk22\AmazonGiftCode\Config\Config; |
||
7 | use kamerk22\AmazonGiftCode\Exceptions\AmazonErrors; |
||
8 | |||
9 | class AmazonGiftCode |
||
10 | { |
||
11 | |||
12 | private $_config; |
||
13 | |||
14 | /** |
||
15 | * AmazonGiftCode constructor. |
||
16 | * |
||
17 | * @param null $key |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
18 | * @param null $secret |
||
0 ignored issues
–
show
|
|||
19 | * @param null $partner |
||
0 ignored issues
–
show
|
|||
20 | * @param null $endpoint |
||
0 ignored issues
–
show
|
|||
21 | * @param null $currency |
||
0 ignored issues
–
show
|
|||
22 | */ |
||
23 | public function __construct($key = null, $secret = null, $partner = null, $endpoint = null, $currency = null) |
||
24 | { |
||
25 | $this->_config = new Config($key, $secret, $partner, $endpoint, $currency); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @param Float $value |
||
30 | * @param string $creationRequestId |
||
31 | * @return Response\CreateResponse |
||
32 | * |
||
33 | * @throws AmazonErrors |
||
34 | */ |
||
35 | public function buyGiftCard(Float $value, string $creationRequestId = null): Response\CreateResponse |
||
36 | { |
||
37 | return (new AWS($this->_config))->getCode($value, $creationRequestId); |
||
38 | } |
||
39 | |||
40 | |||
41 | /** |
||
42 | * @param string $creationRequestId |
||
43 | * @param string $gcId |
||
44 | * @return Response\CancelResponse |
||
45 | */ |
||
46 | public function cancelGiftCard(string $creationRequestId, string $gcId): Response\CancelResponse |
||
47 | { |
||
48 | return (new AWS($this->_config))->cancelCode($creationRequestId, $gcId); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @return Response\CreateBalanceResponse |
||
53 | * |
||
54 | * @throws AmazonErrors |
||
55 | */ |
||
56 | public function getAvailableFunds(): Response\CreateBalanceResponse |
||
57 | { |
||
58 | return (new AWS($this->_config))->getBalance(); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * AmazonGiftCode make own client. |
||
63 | * |
||
64 | * @param null $key |
||
0 ignored issues
–
show
|
|||
65 | * @param null $secret |
||
0 ignored issues
–
show
|
|||
66 | * @param null $partner |
||
0 ignored issues
–
show
|
|||
67 | * @param null $endpoint |
||
0 ignored issues
–
show
|
|||
68 | * @param null $currency |
||
0 ignored issues
–
show
|
|||
69 | * @return AmazonGiftCode |
||
70 | */ |
||
71 | public static function make($key = null, $secret = null, $partner = null, $endpoint = null, $currency = null): AmazonGiftCode |
||
72 | { |
||
73 | return new static($key, $secret, $partner, $endpoint, $currency); |
||
74 | } |
||
75 | |||
76 | } |
||
77 |