|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of the Jusibe PHP library. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Prosper Otemuyiwa <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Unicodeveloper\Jusibe; |
|
12
|
|
|
|
|
13
|
|
|
use StdClass; |
|
14
|
|
|
use Dotenv\Dotenv; |
|
15
|
|
|
use GuzzleHttp\Client; |
|
16
|
|
|
use Unicodeveloper\Jusibe\Exceptions\IsEmpty; |
|
17
|
|
|
|
|
18
|
|
|
trait Helper { |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Load Dotenv to grant getenv() access to environment variables in .env file. |
|
22
|
|
|
*/ |
|
23
|
|
|
public function loadEnv() |
|
24
|
|
|
{ |
|
25
|
|
|
if (! getenv('APP_ENV')) { |
|
26
|
|
|
$dotenv = new Dotenv(__DIR__.'/../'); |
|
27
|
|
|
$dotenv->load(); |
|
28
|
|
|
} |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Get Valid Message ID |
|
33
|
|
|
* @return string |
|
34
|
|
|
*/ |
|
35
|
|
|
public function getValidMessageID() |
|
36
|
|
|
{ |
|
37
|
|
|
return getenv('VALID_MESSAGE_ID'); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Get Invalid Message ID |
|
42
|
|
|
* @return string |
|
43
|
|
|
*/ |
|
44
|
|
|
public function getInvalidMessageID() |
|
45
|
|
|
{ |
|
46
|
|
|
return getenv('INVALID_MESSAGE_ID'); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Get Valid Access Token |
|
51
|
|
|
* @return string |
|
52
|
|
|
*/ |
|
53
|
|
|
public function getValidAccessToken() |
|
54
|
|
|
{ |
|
55
|
|
|
return getenv('VALID_ACCESS_TOKEN'); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Stubbed checkDeliveryStatusResponse |
|
60
|
|
|
* @return object |
|
61
|
|
|
*/ |
|
62
|
|
|
public function checkDeliveryStatusResponse() |
|
63
|
|
|
{ |
|
64
|
|
|
$response = new StdClass; |
|
65
|
|
|
$response->message_id = $this->getValidMessageID(); |
|
66
|
|
|
$response->status = 'Delivered'; |
|
67
|
|
|
$response->date_sent = time(); |
|
68
|
|
|
$response->date_delivered = time(); |
|
69
|
|
|
|
|
70
|
|
|
return $response; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Stubbed sendSMSResponse |
|
75
|
|
|
* @return object |
|
76
|
|
|
*/ |
|
77
|
|
|
public function sendSMSResponse() |
|
78
|
|
|
{ |
|
79
|
|
|
$response = new StdClass; |
|
80
|
|
|
$response->status = 'Sent'; |
|
81
|
|
|
$response->message_id = $this->getValidMessageID(); |
|
82
|
|
|
$response->sms_credits_used = 1; |
|
83
|
|
|
|
|
84
|
|
|
return $response; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Stubbed checkAvailableCreditsResponse |
|
89
|
|
|
* @return object |
|
90
|
|
|
*/ |
|
91
|
|
|
public function checkAvailableCreditsResponse() |
|
92
|
|
|
{ |
|
93
|
|
|
$response = new StdClass; |
|
94
|
|
|
$response->sms_credits = 200; |
|
95
|
|
|
|
|
96
|
|
|
return $response; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Get Invalid Access Token |
|
101
|
|
|
* @return string |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getInvalidAccessToken() |
|
104
|
|
|
{ |
|
105
|
|
|
return getenv('INVALID_ACCESS_TOKEN'); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Get Valid Public Key |
|
110
|
|
|
* @return string |
|
111
|
|
|
*/ |
|
112
|
|
|
public function getValidPublicKey() |
|
113
|
|
|
{ |
|
114
|
|
|
return getenv('VALID_PUBLIC_KEY'); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Get Valid Public Key |
|
119
|
|
|
* @return string |
|
120
|
|
|
*/ |
|
121
|
|
|
public function getInvalidPublicKey() |
|
122
|
|
|
{ |
|
123
|
|
|
return getenv('INVALID_PUBLIC_KEY'); |
|
124
|
|
|
} |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
|
|
128
|
|
|
|