1 | <?php |
||
8 | class ZonerSmsGateway |
||
9 | { |
||
10 | /** URL of the Zoner SMS-API service. */ |
||
11 | const ENDPOINT_URL = 'https://sms.zoner.fi/sms.php'; |
||
12 | |||
13 | /** @var HttpClient HTTP Client */ |
||
14 | protected $http; |
||
15 | |||
16 | /** @var string|null Zoner SMS-API username. */ |
||
17 | protected $username = null; |
||
18 | |||
19 | /** @var string|null Zoner SMS-API password. */ |
||
20 | protected $password = null; |
||
21 | |||
22 | /** @var string|null Default sender number or text. */ |
||
23 | protected $sender = null; |
||
24 | |||
25 | /** |
||
26 | * @param string|null $username |
||
27 | * @param string|null $password |
||
28 | * @param string|null $sender sender number or name |
||
29 | * @param HttpClient|null $httpClient |
||
30 | */ |
||
31 | 10 | public function __construct($username, $password, $sender = null, HttpClient $httpClient = null) |
|
39 | |||
40 | /** |
||
41 | * Gets the HttpClient. |
||
42 | * |
||
43 | * @return HttpClient |
||
44 | */ |
||
45 | 9 | protected function httpClient() |
|
49 | |||
50 | /** |
||
51 | * Sends a message via the gateway. |
||
52 | * |
||
53 | * @param string $receiver phone number where to send (for example "35840123456") |
||
54 | * @param string $message message to send (UTF-8, but this function converts it to ISO-8859-15) |
||
55 | * @param string|null $sender sender phone number (for example "35840123456") |
||
56 | * or string (max 11 chars, a-ZA-Z0-9) |
||
57 | * |
||
58 | * @return string tracking number |
||
59 | * |
||
60 | * @throws ZonerSmsGatewayException if sending failed. |
||
61 | */ |
||
62 | 9 | public function sendMessage($receiver, $message, $sender = null) |
|
108 | |||
109 | /** |
||
110 | * Returns the amount of credits left in the service, or whatever the service replies. |
||
111 | * |
||
112 | * @throws ZonerSmsGatewayException if request failed. |
||
113 | */ |
||
114 | public function getCredits() |
||
130 | } |
||
131 |