1 | <?php |
||
18 | class SMS |
||
19 | { |
||
20 | /** |
||
21 | * Version number of the SMS API. |
||
22 | * |
||
23 | * @var string |
||
24 | */ |
||
25 | const VERSION = '1.0'; |
||
26 | |||
27 | /** |
||
28 | * user ID registered in Bongatech. |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $user_id; |
||
33 | |||
34 | /** |
||
35 | * password for Bongatech. |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | protected $password; |
||
40 | |||
41 | /** |
||
42 | * token is generated by md5(password). |
||
43 | * |
||
44 | * @var string |
||
45 | */ |
||
46 | protected $token; |
||
47 | |||
48 | /** |
||
49 | * timestamp is the current datetime. |
||
50 | * |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $timestamp; |
||
54 | |||
55 | /** |
||
56 | * type of SMS to sent. |
||
57 | * |
||
58 | * @var int message |
||
59 | */ |
||
60 | protected $message_type; |
||
61 | |||
62 | /** |
||
63 | * batch type of the SMS being sent. |
||
64 | * |
||
65 | * @var int batch |
||
66 | */ |
||
67 | protected $batch_type; |
||
68 | |||
69 | /** |
||
70 | * the alphanumeric of the sender. |
||
71 | * |
||
72 | * @var string |
||
73 | */ |
||
74 | protected $sender_id; |
||
75 | |||
76 | /** |
||
77 | * the url on which delivery reports will be sent. |
||
78 | * |
||
79 | * @var string callback_url. |
||
80 | */ |
||
81 | protected $callback_url; |
||
82 | |||
83 | |||
84 | /** |
||
85 | * recipient/recipients of the SMS being sent. |
||
86 | * @var string/array. |
||
87 | */ |
||
88 | protected $recipients; |
||
89 | |||
90 | /** |
||
91 | * the message being sent (array of messages in case message is different for each user. |
||
92 | * |
||
93 | * @var string/array. |
||
94 | */ |
||
95 | protected $message; |
||
96 | |||
97 | /** |
||
98 | * Bongatech end point |
||
99 | * |
||
100 | * @var string end point. |
||
101 | */ |
||
102 | protected $endpoint = 'http://197.248.2.55/smsapi_test/submit.php'; |
||
103 | |||
104 | /** |
||
105 | * SMS constructor. |
||
106 | * @param string $user_id |
||
107 | * @param string $password |
||
108 | * @param string $sender_id |
||
109 | * @param string $callback_url |
||
110 | */ |
||
111 | public function __construct($user_id, $password, $sender_id, $callback_url) |
||
118 | |||
119 | /** |
||
120 | * set the token |
||
121 | */ |
||
122 | private function setToken() |
||
127 | |||
128 | /** |
||
129 | * set the timestamp |
||
130 | */ |
||
131 | private function setTimestamp() |
||
136 | |||
137 | /** |
||
138 | * invoke if SMS being sent is of type subscribable. |
||
139 | * |
||
140 | * @return $this |
||
141 | */ |
||
142 | public function subscribable() |
||
148 | |||
149 | /** |
||
150 | * invoke if SMS being sent is of type on demand. |
||
151 | * |
||
152 | * @return $this |
||
153 | */ |
||
154 | public function onDemand() |
||
160 | |||
161 | /** |
||
162 | * invoke if SMS being sent is of type bulk SMS. This will be the common one. |
||
163 | * @return $this |
||
164 | */ |
||
165 | public function bulk() |
||
172 | |||
173 | /** |
||
174 | * invoke if SMS is being sent to a single recipient. |
||
175 | * |
||
176 | * @return $this |
||
177 | */ |
||
178 | public function noBatch() |
||
185 | |||
186 | /** |
||
187 | * invoke if SMS is being sent to a different recipients. |
||
188 | * |
||
189 | * @return $this |
||
190 | */ |
||
191 | public function sameMessage() |
||
198 | |||
199 | /** |
||
200 | * invoke if each recipient will receive a different message. |
||
201 | * |
||
202 | * @return $this |
||
203 | */ |
||
204 | public function differentMessages() |
||
211 | |||
212 | /** |
||
213 | * |
||
214 | */ |
||
215 | public function send() |
||
229 | |||
230 | /** |
||
231 | * send a message to a single recipient. |
||
232 | * |
||
233 | * @param Request $request |
||
234 | */ |
||
235 | private function sendForNoBatch(Request $request) |
||
238 | |||
239 | /** |
||
240 | * send same message to different recipients. |
||
241 | * |
||
242 | * @param Request $request |
||
243 | */ |
||
244 | private function sendForSameMessage(Request $request) |
||
247 | |||
248 | /** |
||
249 | * send different message to different recipients |
||
250 | * |
||
251 | * @param Request $request |
||
252 | */ |
||
253 | private function sendForDifferentMessages(Request $request) |
||
256 | |||
257 | |||
258 | } |
||
259 |