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 |
|
|
|
|
18
|
|
|
* @param null $secret |
|
|
|
|
19
|
|
|
* @param null $partner |
|
|
|
|
20
|
|
|
* @param null $endpoint |
|
|
|
|
21
|
|
|
* @param null $currency |
|
|
|
|
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
|
|
|
* @return Response\CreateResponse |
31
|
|
|
* |
32
|
|
|
* @throws AmazonErrors |
33
|
|
|
*/ |
34
|
|
|
public function buyGiftCard(Float $value): Response\CreateResponse |
35
|
|
|
{ |
36
|
|
|
return (new AWS($this->_config))->getCode($value); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param string $creationRequestId |
42
|
|
|
* @param string $gcId |
43
|
|
|
* @return Response\CancelResponse |
44
|
|
|
*/ |
45
|
|
|
public function cancelGiftCard(string $creationRequestId, string $gcId): Response\CancelResponse |
46
|
|
|
{ |
47
|
|
|
return (new AWS($this->_config))->cancelCode($creationRequestId, $gcId); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return Response\CreateBalanceResponse |
52
|
|
|
* |
53
|
|
|
* @throws AmazonErrors |
54
|
|
|
*/ |
55
|
|
|
public function getAvailableFunds(): Response\CreateBalanceResponse |
56
|
|
|
{ |
57
|
|
|
return (new AWS($this->_config))->getBalance(); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* AmazonGiftCode make own client. |
62
|
|
|
* |
63
|
|
|
* @param null $key |
|
|
|
|
64
|
|
|
* @param null $secret |
|
|
|
|
65
|
|
|
* @param null $partner |
|
|
|
|
66
|
|
|
* @param null $endpoint |
|
|
|
|
67
|
|
|
* @param null $currency |
|
|
|
|
68
|
|
|
* @return AmazonGiftCode |
69
|
|
|
*/ |
70
|
|
|
public static function make($key = null, $secret = null, $partner = null, $endpoint = null, $currency = null): AmazonGiftCode |
71
|
|
|
{ |
72
|
|
|
return new static($key, $secret, $partner, $endpoint, $currency); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
} |