Issues (15)

src/RestApi/RestApiClient.php (2 issues)

Labels
Severity
1
<?php
2
3
namespace JoshuaChinemezu\SmsGlobal\RestApi;
4
5
use Illuminate\Support\Facades\Config;
6
use JoshuaChinemezu\SmsGlobal\RestApi\Request\RestApiRequest;
7
/*
8
 * This file is part of the SmsGlobal Laravel package.
9
 *
10
 * (c) Joshua Chinemezu <[email protected]>
11
 *
12
 * For the full copyright and license information, please view the LICENSE
13
 * file that was distributed with this source code.
14
 */
15
16
class RestApiClient
17
{
18
    protected $apiKey;
19
    protected $secretKey;
20
    protected $debug;
21
    protected $hashAlgo;
22
    protected $request;
23
24
25
    public function __construct()
26
    {
27
        $this->setApiKey();
28
        $this->setSecretKey();
29
        $this->setDebugMode();
30
        $this->setHashAlgo();
31
        $this->setRequest();
32
    }
33
34
    /**
35
     * Get api key from SmsGlobal config file
36
     */
37
    public function setApiKey()
38
    {
39
        $this->apiKey = Config::get('smsglobal.apiKey');
40
    }
41
42
    /**
43
     * Get secret key from SmsGlobal config file
44
     */
45
    public function setSecretKey()
46
    {
47
        $this->secretKey = Config::get('smsglobal.secretKey');
48
    }
49
50
    /**
51
     * Get debug mode from SmsGlobal config file
52
     */
53
    public function setDebugMode()
54
    {
55
        $this->debug = Config::get('smsglobal.debug');
56
    }
57
58
    /**
59
     * Get debug mode from SmsGlobal config file
60
     */
61
    public function setHashAlgo()
62
    {
63
        $this->hashAlgo = Config::get('smsglobal.hashAlgo');
64
    }
65
66
    /**
67
     * Get debug mode from SmsGlobal config file
68
     */
69
    public function setRequest()
70
    {
71
        $this->request = new RestApiRequest($this->apiKey, $this->secretKey, $this->hashAlgo);
72
    }
73
74
    /**
75
     * Get the auto top-up information associated to the authenticated account.
76
     */
77
    public function getAutoTopUpInfo()
78
    {
79
        return $this->request->get('auto-topup');
80
    }
81
82
    /**
83
     * Delete a contact
84
     * @param integer $id
85
     * @return json
0 ignored issues
show
The type JoshuaChinemezu\SmsGlobal\RestApi\json was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
86
     */
87
    public function deleteContact($id)
88
    {
89
        return $this->request->delete("contact/{$id}");
90
    }
91
92
    /**
93
     * Get the contact as identified by the given id.
94
     * @param integer $id
95
     * @return json
96
     */
97
    public function getContactByID($id)
98
    {
99
        return $this->request->get("contact/{$id}");
100
    }
101
102
    /**
103
     * Update the contact as identified by the given id. You can only update the
104
     * default fields associated with each contact.
105
     * @param integer $id
106
     * @return json
107
     */
108
    public function updateContactByID($id)
109
    {
110
        return $this->request->put("contact/{$id}");
111
    }
112
113
    /**
114
     * Get a list of all contact groups.
115
     * @param array $queryOptions
116
     * @return json
117
     */
118
    public function getAllContactGroups($queryOptions = [])
119
    {
120
        return $this->request->get('group', $queryOptions);
121
    }
122
123
    /**
124
     * Create a new contact group.
125
     * @param array $formData
126
     * @return json
127
     */
128
    public function createContactGroup($formData)
129
    {
130
        return $this->request->post('group', $formData);
131
    }
132
133
    /**
134
     * Create a contact.
135
     * @param integer $groupId
136
     * @param array $formData
137
     * @return json
138
     */
139
    public function createContact($groupId, $formData)
140
    {
141
        return $this->request->post("group/{$groupId}/contact", $formData);
142
    }
143
144
    /**
145
     * Get a list of all contacts in a group.
146
     * @param integer $groupId
147
     * @param array $filters
148
     * @return json
149
     */
150
    public function getContactsByGroupID($groupId, $filters)
151
    {
152
        return $this->request->get("group/{$groupId}/contacts", $filters);
153
    }
154
155
    /**
156
     * Delete a contact group
157
     * @param integer $id
158
     * @return json
159
     */
160
    public function deleteContactGroup($id)
161
    {
162
        return $this->request->delete("group/{$id}");
163
    }
164
165
    /**
166
     * Get the contact group as identified by the given id.
167
     * @param integer $id
168
     * @return json
169
     */
170
    public function getContactGroupByID($id)
171
    {
172
        return $this->request->get("group/{$id}");
173
    }
174
175
    /**
176
     * Update fields of a group as identified by the given id
177
     * @param integer $id
178
     * @param array $params
179
     * @return json
180
     */
181
    public function updateGroupFieldByID($id, $params)
182
    {
183
        return $this->request->patch("group/{$id}", $params);
184
    }
185
186
    /**
187
     * View list of dedicated numbers
188
     * @return json
189
     */
190
    public function getAllDedicatedNumbers()
191
    {
192
        return $this->request->get('dedicated-number');
193
    }
194
195
    /**
196
     * View list of opted out numbers
197
     * @param array $filters
198
     * @return json
199
     */
200
    public function getAllOptedOutNumbers($filters)
201
    {
202
        return $this->request->get('opt-outs', $filters);
203
    }
204
205
    /**
206
     * Opt out mobile numbers
207
     * @param array $mobileNumbers
208
     * @return json
209
     */
210
    public function optOutMobileNumbers($mobileNumbers)
211
    {
212
        return $this->request->post('opt-outs', $mobileNumbers);
213
    }
214
215
    /**
216
     * Validate mobile numbers for opt out
217
     * @param array $mobileNumbers
218
     * @return json
219
     */
220
    public function validateOptOutMobileNumbers($mobileNumbers)
221
    {
222
        return $this->request->post('opt-outs/validate', $mobileNumbers);
223
    }
224
225
    /**
226
     * Opt in a mobile number
227
     * @param integer $mobileNumber
228
     * @return json
229
     */
230
    public function optInMobileNumber($mobileNumber)
231
    {
232
        return $this->request->delete("opt-outs/{$mobileNumber}");
233
    }
234
235
    /**
236
     * View list of shared pools
237
     * @return json
238
     */
239
    public function getAllSharedPools()
240
    {
241
        return $this->request->get('sharedpool');
242
    }
243
244
    /**
245
     * View details of a shared pool
246
     * @param integer $id
247
     * @return json
248
     */
249
    public function getSharedPoolByID($id)
250
    {
251
        return $this->request->get("sharedpool/{$id}");
252
    }
253
254
    /**
255
     * View list of outgoing messages
256
     * @param arrray $filters
0 ignored issues
show
The type JoshuaChinemezu\SmsGlobal\RestApi\arrray was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
257
     * @return json
258
     */
259
    public function getAllOutGoingMessage($filters)
260
    {
261
        return $this->request->get('sms', $filters);
262
    }
263
264
    /**
265
     * Send SMS
266
     * @param array $optionData
267
     * @return json
268
     */
269
    public function sendMessage($optionData)
270
    {
271
        return $this->request->post('sms', $optionData);
272
    }
273
274
    /**
275
     * Delete outgoing message
276
     * @param integer $id
277
     * @return json
278
     */
279
    public function deleteOutGoingMessage($id)
280
    {
281
        return $this->request->delete("sms/{$id}");
282
    }
283
284
    /**
285
     * View details of an outgoing message
286
     * @param integer $id
287
     * @return json
288
     */
289
    public function getOutGoingMessageByID($id)
290
    {
291
        return $this->request->get("sms/{$id}");
292
    }
293
294
    /**
295
     * View list of incoming messages
296
     * @param arrray $filters
297
     * @return json
298
     */
299
    public function getAllIncomingMessage($filters)
300
    {
301
        return $this->request->get('sms-incoming', $filters);
302
    }
303
304
    /**
305
     * Delete incoming message
306
     * @param integer $id
307
     * @return json
308
     */
309
    public function deleteIncomingMessage($id)
310
    {
311
        return $this->request->delete("sms-incoming/{$id}");
312
    }
313
314
    /**
315
     * View details of an incoming message
316
     * @param integer $id
317
     * @return json
318
     */
319
    public function getIncomingMessageByID($id)
320
    {
321
        return $this->request->get("sms-incoming/{$id}");
322
    }
323
324
    /**
325
     * Get the authenticated account's billing details.
326
     * @return json
327
     */
328
    public function getBillingDetails()
329
    {
330
        return $this->request->get("user/billing-details");
331
    }
332
333
    /**
334
     * Update the authenticated account's billing details.
335
     * @param array $params
336
     * @return json
337
     */
338
    public function updateBillingDetails($params)
339
    {
340
        return $this->request->put("user/billing-details", $params);
341
    }
342
343
    /**
344
     * Get the authenticated account's contact details.
345
     * @return json
346
     */
347
    public function getContactDetails()
348
    {
349
        return $this->request->get("user/contact-details");
350
    }
351
352
    /**
353
     * Update the authenticated account's contact details.
354
     * @param array $params
355
     * @return json
356
     */
357
    public function updateContactDetails($params)
358
    {
359
        return $this->request->put("user/billing-details", $params);
360
    }
361
362
    /**
363
     * View the account balance
364
     * @return json
365
     */
366
    public function getBalance()
367
    {
368
        return $this->request->get("user/credit-details");
369
    }
370
371
    /**
372
     * Get the low balance alerts information associated to the authenticated
373
     * account.
374
     * @return json
375
     */
376
    public function getLowBalanceAlert()
377
    {
378
        return $this->request->get("user/low-balance-alerts");
379
    }
380
381
    /**
382
     * Update the authenticated account's low balance alerts information.
383
     * @param array $params
384
     * @return json
385
     */
386
    public function updateLowAlertBalance($params)
387
    {
388
        return $this->request->put("user/low-balance-alerts", $params);
389
    }
390
391
    /**
392
     * Create sub account
393
     * @param array $params
394
     * @return json
395
     */
396
    public function createSubAccount($params)
397
    {
398
        return $this->request->post("user/sub-account", $params);
399
    }
400
401
    /**
402
     * Get the authenticated account's verified numbers.
403
     * @return json
404
     */
405
    public function getVerifiedNumbers()
406
    {
407
        return $this->request->get("user/verified-numbers");
408
    }
409
}
410