@@ -93,10 +93,10 @@ const setPathName = (config, values) => {
93
93
offset ) {
94
94
let _value = values [ string ]
95
95
return isTypeOf (
96
- _value ,
97
- config . route_params [ string ]
96
+ config . route_params [ string ] ,
97
+ _value
98
98
)
99
- ? _value
99
+ ? config . route_params [ string ]
100
100
: null
101
101
} )
102
102
}
@@ -313,8 +313,7 @@ class InfoBip extends Mockable {
313
313
314
314
let reqVerb = config . method . toLowerCase ( )
315
315
316
- return this . _mock !== null ? this . _mock [ 'sendSMSBinary' ] . bind ( this , params ) : got [ reqVerb ] . bind (
317
- got ,
316
+ return this . _mock !== null ? this . _mock [ 'sendSMSBinary' ] . bind ( this , params ) : got [ reqVerb ] (
318
317
`${ this . baseUrl } ${ pathname } ` ,
319
318
this . httpConfig
320
319
)
@@ -324,9 +323,9 @@ class InfoBip extends Mockable {
324
323
let config = {
325
324
send_json : true ,
326
325
method : 'POST' ,
327
- path : '/sms/2/text/advanced ' ,
328
- route_params : null ,
329
- params : { messages$ : Array , bulkId : String }
326
+ path : '/sms/2/text/{:type} ' ,
327
+ route_params : { type : typeof params . messages === 'undefined' ? 'single' : 'advanced' } ,
328
+ params : { messages : Array , bulkId : String , from : String , to : String , text : String , type : String }
330
329
}
331
330
332
331
if ( config . route_params !== null ||
@@ -339,22 +338,24 @@ class InfoBip extends Mockable {
339
338
let payload = setInputValues ( config , params )
340
339
let pathname = setPathName ( config , params )
341
340
342
- for ( let messageIndex in params . messages ) {
343
- if ( params . messages . hasOwnProperty ( messageIndex ) ) {
344
- let message = params . messages [ messageIndex ] || [ ]
345
- let destinations = message . destinations || [ ]
341
+ if ( params . messages ) {
342
+ for ( let messageIndex in params . messages ) {
343
+ if ( params . messages . hasOwnProperty ( messageIndex ) ) {
344
+ let message = params . messages [ messageIndex ] || [ ]
345
+ let destinations = message . destinations || [ ]
346
346
347
- if ( ! isTypeOf ( message . from , [ 'string' ] ) ||
348
- ! isTypeOf ( message . text , [ 'string' ] ) ) {
349
- throw new TypeError ( 'infobip api: request payload for [from, text]; sendSMS() not of correct type' )
350
- }
347
+ if ( ! isTypeOf ( message . from , [ 'string' ] ) ||
348
+ ! isTypeOf ( message . text , [ 'string' ] ) ) {
349
+ throw new TypeError ( 'infobip api: request payload for [from, text]; sendSMS() not of correct type' )
350
+ }
351
351
352
- for ( let destinationIndex in destinations ) {
353
- if ( destinations . hasOwnProperty ( destinationIndex ) ) {
354
- let destination = destinations [ destinationIndex ] || { }
352
+ for ( let destinationIndex in destinations ) {
353
+ if ( destinations . hasOwnProperty ( destinationIndex ) ) {
354
+ let destination = destinations [ destinationIndex ] || { }
355
355
356
- if ( ! isTypeOf ( destination . to , [ 'array' , 'string' ] ) ) {
357
- throw new TypeError ( 'infobip api: request payload for [to]; SMS not of correct type' )
356
+ if ( ! isTypeOf ( destination . to , [ 'array' , 'string' ] ) ) {
357
+ throw new TypeError ( 'infobip api: request payload for [to]; SMS not of correct type' )
358
+ }
358
359
}
359
360
}
360
361
}
@@ -379,8 +380,7 @@ class InfoBip extends Mockable {
379
380
380
381
let reqVerb = config . method . toLowerCase ( )
381
382
382
- return this . _mock !== null ? this . _mock [ 'sendSMS' ] . bind ( this , params ) : got [ reqVerb ] . bind (
383
- got ,
383
+ return this . _mock !== null ? this . _mock [ 'sendSMS' ] . bind ( this , params ) : got [ reqVerb ] (
384
384
`${ this . baseUrl } ${ pathname } ` ,
385
385
this . httpConfig
386
386
)
0 commit comments