1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* BongaTech SMS Client Library for PHP. |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (c) 2017 |
6
|
|
|
* @author Vincent Mosoti <[email protected]> |
7
|
|
|
* @licence https://github.com/VMosoti/bongatech-sms/blob/master/LICENSE |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace VMosoti\BongaTech; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class Response. |
14
|
|
|
*/ |
15
|
|
|
class Response |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* the response. |
19
|
|
|
* |
20
|
|
|
* @var array |
21
|
|
|
*/ |
22
|
|
|
public $response; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Response constructor. |
26
|
|
|
* |
27
|
|
|
* @param array response |
28
|
|
|
*/ |
29
|
|
|
public function __construct($response) |
30
|
|
|
{ |
31
|
|
|
$this->response = $response; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @return mixed |
36
|
|
|
*/ |
37
|
|
|
public function getCode() |
38
|
|
|
{ |
39
|
|
|
return !empty($this->response->ResponseCode) ? $this->response->ResponseCode : ''; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return mixed |
44
|
|
|
*/ |
45
|
|
|
public function getBalance() |
46
|
|
|
{ |
47
|
|
|
return !empty($this->response->Balance ? $this->response->Balance : ''); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return mixed |
52
|
|
|
*/ |
53
|
|
|
public function getDescription() |
54
|
|
|
{ |
55
|
|
|
return !empty($this->response->ResponseDescription) ? $this->response->ResponseDescription : ''; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @return mixed |
60
|
|
|
*/ |
61
|
|
|
public function getMSISDN() |
62
|
|
|
{ |
63
|
|
|
return !empty($this->response->MSISDN) ? $this->response->MSISDN : ''; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* there are some inconsistencies in the names of objects returned. |
68
|
|
|
* |
69
|
|
|
* @return mixed |
70
|
|
|
*/ |
71
|
|
|
public function getCorrelator() |
72
|
|
|
{ |
73
|
|
|
$correlator = ''; |
74
|
|
|
|
75
|
|
|
if (!empty($this->response->Correlator)) { |
76
|
|
|
$correlator = $this->response->Correlator; |
77
|
|
|
} elseif (!empty($this->response->correlator)) { |
78
|
|
|
$correlator = $this->response->correlator; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
return $correlator; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* there are some inconsistencies in the names of objects returned. |
86
|
|
|
* |
87
|
|
|
* @return mixed |
88
|
|
|
*/ |
89
|
|
|
public function getMessageID() |
90
|
|
|
{ |
91
|
|
|
$msgid = ''; |
92
|
|
|
|
93
|
|
|
if (!empty($this->response->MessageID)) { |
94
|
|
|
$msgid = $this->response->MessageID; |
95
|
|
|
} elseif (!empty($this->response->msg_id)) { |
96
|
|
|
$msgid = $this->response->msg_id; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
return $msgid; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return mixed |
104
|
|
|
*/ |
105
|
|
|
public function getSourceID() |
106
|
|
|
{ |
107
|
|
|
return !empty($this->response->source_id) ? $this->response->source_id : ''; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @return mixed |
112
|
|
|
*/ |
113
|
|
|
public function getReport() |
114
|
|
|
{ |
115
|
|
|
return !empty($this->response->dlr_report) ? $this->response->dlr_report : ''; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return boolean |
120
|
|
|
*/ |
121
|
|
|
public function isSuccess() |
122
|
|
|
{ |
123
|
|
|
return $this->getCode()=='1001'; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
} |
127
|
|
|
|