File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88class VerifyRequest extends Request
99{
1010 protected $ url = URLs::OTP_VERIFY_URL ;
11+
12+ protected $ content_type = \GuzzleHttp \RequestOptions::FORM_PARAMS ;
1113}
Original file line number Diff line number Diff line change 66use Craftsys \Msg91 \Exceptions \ValidationException ;
77use Craftsys \Msg91 \Contracts \Options ;
88use GuzzleHttp \Client as GuzzleHttpClient ;
9+ use GuzzleHttp \RequestOptions ;
910
1011abstract class Request
1112{
@@ -36,13 +37,19 @@ abstract class Request
3637 */
3738 protected $ url = "" ;
3839
40+ /**
41+ * Content type
42+ */
43+ protected $ content_type = RequestOptions::JSON ;
44+
3945 /**
4046 * Validation instance
4147 *
4248 * @var \Craftsys\Msg91\Requests\Validator
4349 */
4450 protected $ validator ;
4551
52+
4653 /**
4754 * Create a new request instance
4855 *
@@ -93,10 +100,9 @@ public function handle()
93100 $ method = strtolower ($ this ->method );
94101 try {
95102 $ resp = $ client ->{$ method }($ this ->url , [
96- \ GuzzleHttp \RequestOptions:: JSON => $ payload ,
103+ $ this -> content_type => $ payload ,
97104 "headers " => [
98105 'authkey ' => $ payload ['authkey ' ],
99- 'content-type ' => 'application/json '
100106 ]
101107 ]);
102108 return new Response ($ resp );
Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ public function test_verify_otp()
8484 // check the method
8585 $ this ->assertEquals ("POST " , $ transaction ['request ' ]->getMethod ());
8686 // check the request data
87- $ data = ( array ) json_decode ( $ transaction ['request ' ]->getBody ()->getContents ());
87+ parse_str ( $ transaction ['request ' ]->getBody ()->getContents (), $ data );
8888 $ this ->assertArrayHasKey ('mobile ' , $ data );
8989 $ this ->assertEquals ($ phone_number , $ data ['mobile ' ]);
9090 $ this ->assertArrayHasKey ('authkey ' , $ data );
You can’t perform that action at this time.
0 commit comments