23
23
/**
24
24
* @todo Add a general description for this controller.
25
25
*/
26
- class APIController extends BaseController
26
+ class MFAController extends BaseController
27
27
{
28
28
public function __construct ($ config , $ httpCallBack = null )
29
29
{
30
30
parent ::__construct ($ config , $ httpCallBack );
31
31
}
32
32
33
33
/**
34
- * Two-Factor authentication with Bandwidth Voice services
34
+ * Allows a user to send a MFA code through a phone call
35
35
*
36
36
* @param string $accountId Bandwidth Account ID with Voice service enabled
37
37
* @param Models\TwoFactorCodeRequestSchema $body TODO: type description here
@@ -89,7 +89,28 @@ public function createVoiceTwoFactor(
89
89
90
90
//Error handling using HTTP status codes
91
91
if ($ response ->code == 400 ) {
92
- throw new Exceptions \InvalidRequestException ('client request error ' , $ _httpContext );
92
+ throw new Exceptions \ErrorWithRequestException (
93
+ 'If there is any issue with values passed in by the user ' ,
94
+ $ _httpContext
95
+ );
96
+ }
97
+
98
+ if ($ response ->code == 401 ) {
99
+ throw new Exceptions \UnauthorizedRequestException (
100
+ 'Authentication is either incorrect or not present ' ,
101
+ $ _httpContext
102
+ );
103
+ }
104
+
105
+ if ($ response ->code == 403 ) {
106
+ throw new Exceptions \ForbiddenRequestException (
107
+ 'The user is not authorized to access this resource ' ,
108
+ $ _httpContext
109
+ );
110
+ }
111
+
112
+ if ($ response ->code == 500 ) {
113
+ throw new Exceptions \ErrorWithRequestException ('An internal server error occurred ' , $ _httpContext );
93
114
}
94
115
95
116
//handle errors defined at the API level
@@ -103,7 +124,7 @@ public function createVoiceTwoFactor(
103
124
}
104
125
105
126
/**
106
- * Two-Factor authentication with Bandwidth messaging services
127
+ * Allows a user to send a MFA code through a text message (SMS)
107
128
*
108
129
* @param string $accountId Bandwidth Account ID with Messaging service enabled
109
130
* @param Models\TwoFactorCodeRequestSchema $body TODO: type description here
@@ -161,7 +182,28 @@ public function createMessagingTwoFactor(
161
182
162
183
//Error handling using HTTP status codes
163
184
if ($ response ->code == 400 ) {
164
- throw new Exceptions \InvalidRequestException ('client request error ' , $ _httpContext );
185
+ throw new Exceptions \ErrorWithRequestException (
186
+ 'If there is any issue with values passed in by the user ' ,
187
+ $ _httpContext
188
+ );
189
+ }
190
+
191
+ if ($ response ->code == 401 ) {
192
+ throw new Exceptions \UnauthorizedRequestException (
193
+ 'Authentication is either incorrect or not present ' ,
194
+ $ _httpContext
195
+ );
196
+ }
197
+
198
+ if ($ response ->code == 403 ) {
199
+ throw new Exceptions \ForbiddenRequestException (
200
+ 'The user is not authorized to access this resource ' ,
201
+ $ _httpContext
202
+ );
203
+ }
204
+
205
+ if ($ response ->code == 500 ) {
206
+ throw new Exceptions \ErrorWithRequestException ('An internal server error occurred ' , $ _httpContext );
165
207
}
166
208
167
209
//handle errors defined at the API level
@@ -175,7 +217,7 @@ public function createMessagingTwoFactor(
175
217
}
176
218
177
219
/**
178
- * Verify a previously sent two-factor authentication code
220
+ * Allows a user to verify an MFA code
179
221
*
180
222
* @param string $accountId Bandwidth Account ID with Two-Factor enabled
181
223
* @param Models\TwoFactorVerifyRequestSchema $body TODO: type description here
@@ -233,7 +275,35 @@ public function createVerifyTwoFactor(
233
275
234
276
//Error handling using HTTP status codes
235
277
if ($ response ->code == 400 ) {
236
- throw new Exceptions \InvalidRequestException ('client request error ' , $ _httpContext );
278
+ throw new Exceptions \ErrorWithRequestException (
279
+ 'If there is any issue with values passed in by the user ' ,
280
+ $ _httpContext
281
+ );
282
+ }
283
+
284
+ if ($ response ->code == 401 ) {
285
+ throw new Exceptions \UnauthorizedRequestException (
286
+ 'Authentication is either incorrect or not present ' ,
287
+ $ _httpContext
288
+ );
289
+ }
290
+
291
+ if ($ response ->code == 403 ) {
292
+ throw new Exceptions \ForbiddenRequestException (
293
+ 'The user is not authorized to access this resource ' ,
294
+ $ _httpContext
295
+ );
296
+ }
297
+
298
+ if ($ response ->code == 429 ) {
299
+ throw new Exceptions \ErrorWithRequestException (
300
+ 'The user has made too many bad requests and is temporarily locked out ' ,
301
+ $ _httpContext
302
+ );
303
+ }
304
+
305
+ if ($ response ->code == 500 ) {
306
+ throw new Exceptions \ErrorWithRequestException ('An internal server error occurred ' , $ _httpContext );
237
307
}
238
308
239
309
//handle errors defined at the API level
0 commit comments