1 | <?php |
||
21 | 1 | class Sender extends BaseSender implements ISender |
|
22 | { |
||
23 | CONST URL = 'https://as.eurosms.com/api/v2/Sender'; |
||
24 | |||
25 | /** @var string */ |
||
26 | private $id; |
||
27 | |||
28 | /** @var string */ |
||
29 | private $key; |
||
30 | |||
31 | |||
32 | public function __construct(array $config = NULL) |
||
33 | { |
||
34 | 1 | if (is_array($config) && !empty($config)) |
|
35 | 1 | $this->config($config); |
|
36 | 1 | } |
|
37 | |||
38 | /** |
||
39 | * @param array $config |
||
40 | * @return self |
||
41 | */ |
||
42 | public function config($config) |
||
50 | |||
51 | /** |
||
52 | * @throws RM\SMSender\Exception |
||
53 | * @return bool|string ID of Message |
||
54 | */ |
||
55 | public function send(IMessage $message) |
||
80 | |||
81 | public function getSignature(IMessage $message) : string |
||
85 | |||
86 | public function isSuccess(string $response) |
||
90 | |||
91 | /** |
||
92 | * @param string $id |
||
93 | * @param string $key |
||
94 | * @throws ConfigurationException |
||
95 | * @return bool |
||
96 | */ |
||
97 | private function checkConfig($id, $key) |
||
98 | { |
||
99 | 1 | if (!Strings::match($id, '~^\d-[0-9a-zA-Z]{6}$~')) |
|
100 | 1 | throw new ConfigurationException('Parameter "id" must be in format "\d-[0-9a-zA-Z]{6}".'); |
|
101 | 1 | if (strlen($key) !== 8 && strlen($key) !== 9) |
|
102 | 1 | throw new ConfigurationException('Parameter "key" must have 8 or 9 characters. It has ' . strlen($key) . ' characters.'); |
|
103 | 1 | return TRUE; |
|
104 | } |
||
105 | |||
106 | /** |
||
107 | * @throws MissingParameterException |
||
108 | */ |
||
109 | private function check(IMessage $message) : bool |
||
119 | } |
||
120 |