@@ -87,47 +87,47 @@ public function addListener($eventName, $listener)
8787 */
8888 public function get ($ path , array $ parameters = array (), array $ headers = array ())
8989 {
90- return $ this ->request ($ path , $ parameters , 'GET ' , $ headers );
90+ return $ this ->request ($ path , null , 'GET ' , $ headers, array ( ' query ' => $ parameters ) );
9191 }
9292
9393 /**
9494 * {@inheritDoc}
9595 */
96- public function post ($ path , array $ parameters = array () , array $ headers = array ())
96+ public function post ($ path , $ body = null , array $ headers = array ())
9797 {
98- return $ this ->request ($ path , $ parameters , 'POST ' , $ headers );
98+ return $ this ->request ($ path , $ body , 'POST ' , $ headers );
9999 }
100100
101101 /**
102102 * {@inheritDoc}
103103 */
104- public function patch ($ path , array $ parameters = array () , array $ headers = array ())
104+ public function patch ($ path , $ body = null , array $ headers = array ())
105105 {
106- return $ this ->request ($ path , $ parameters , 'PATCH ' , $ headers );
106+ return $ this ->request ($ path , $ body , 'PATCH ' , $ headers );
107107 }
108108
109109 /**
110110 * {@inheritDoc}
111111 */
112- public function delete ($ path , array $ parameters = array () , array $ headers = array ())
112+ public function delete ($ path , $ body = null , array $ headers = array ())
113113 {
114- return $ this ->request ($ path , $ parameters , 'DELETE ' , $ headers );
114+ return $ this ->request ($ path , $ body , 'DELETE ' , $ headers );
115115 }
116116
117117 /**
118118 * {@inheritDoc}
119119 */
120- public function put ($ path , array $ parameters = array () , array $ headers = array ())
120+ public function put ($ path , $ body , array $ headers = array ())
121121 {
122- return $ this ->request ($ path , $ parameters , 'PUT ' , $ headers );
122+ return $ this ->request ($ path , $ body , 'PUT ' , $ headers );
123123 }
124124
125125 /**
126126 * {@inheritDoc}
127127 */
128- public function request ($ path , array $ parameters = array () , $ httpMethod = 'GET ' , array $ headers = array ())
128+ public function request ($ path , $ body = null , $ httpMethod = 'GET ' , array $ headers = array (), array $ options = array ())
129129 {
130- $ request = $ this ->createRequest ($ httpMethod , $ path , $ parameters , $ headers );
130+ $ request = $ this ->createRequest ($ httpMethod , $ path , $ body , $ headers, $ options );
131131 $ request ->addHeaders ($ headers );
132132
133133 try {
@@ -170,23 +170,13 @@ public function getLastResponse()
170170 return $ this ->lastResponse ;
171171 }
172172
173- protected function createRequest ($ httpMethod , $ path , array $ parameters = array (), array $ headers = array ())
173+ protected function createRequest ($ httpMethod , $ path , $ body = null , array $ headers = array (), array $ options = array ())
174174 {
175- if ('GET ' !== $ httpMethod ) {
176- $ requestBody = count ($ parameters ) === 0
177- ? null : json_encode ($ parameters , empty ($ parameters ) ? JSON_FORCE_OBJECT : 0 )
178- ;
179- $ options = array ();
180- } else {
181- $ requestBody = null ;
182- $ options = array ('query ' => $ parameters );
183- }
184-
185175 return $ this ->client ->createRequest (
186176 $ httpMethod ,
187177 $ path ,
188178 array_merge ($ this ->headers , $ headers ),
189- $ requestBody ,
179+ $ body ,
190180 $ options
191181 );
192182 }
0 commit comments