@@ -192,7 +192,7 @@ class WPAppNetworkManager {
192192 Future <WPUserInfoResponse > wpGetUserInfo (String userToken) async {
193193 // send http request
194194 final json = await _http (
195- method: "GET " ,
195+ method: "POST " ,
196196 url: _urlForRouteType (WPRouteType .UserInfo ),
197197 userToken: userToken,
198198 );
@@ -267,7 +267,7 @@ class WPAppNetworkManager {
267267 Future <WCCustomerInfoResponse > wcCustomerInfo (String userToken) async {
268268 // send http request
269269 final json = await _http (
270- method: "GET " ,
270+ method: "POST " ,
271271 url: _urlForRouteType (WPRouteType .WCCustomerInfo ),
272272 userToken: userToken,
273273 );
@@ -376,22 +376,23 @@ class WPAppNetworkManager {
376376 Future <dynamic > _http (
377377 {@required String method,
378378 @required String url,
379- dynamic body,
379+ Map < String , dynamic > body,
380380 String userToken}) async {
381381 var response;
382382 if (method == "GET" ) {
383383 response = await http.get (
384384 url,
385- headers: (userToken == null ? null : _authHeader (userToken)),
386385 );
387386 } else if (method == "POST" ) {
388387 Map <String , String > headers = {
389388 HttpHeaders .contentTypeHeader: "application/json" ,
390389 };
390+ if (body == null ) {
391+ body = {};
392+ }
391393 if (userToken != null ) {
392- headers .addAll (_authHeader ( userToken) );
394+ body .addAll ({ "token" : userToken} );
393395 }
394-
395396 response = await http.post (
396397 url,
397398 body: jsonEncode (body),
@@ -426,14 +427,6 @@ class WPAppNetworkManager {
426427 if (WPJsonAPI .instance.shouldDebug ()) log (strOutput);
427428 }
428429
429- /// Sets the authorization header for a request using the
430- /// [userToken] has the API bearer token.
431- ///
432- /// Returns a map of the authorizationHeader.
433- Map <String , String > _authHeader (userToken) {
434- return {HttpHeaders .authorizationHeader: "Bearer " + userToken};
435- }
436-
437430 /// Checks if a response payload has a bad status (=> 500).
438431 ///
439432 /// Returns [bool] true if status is => 500.
@@ -471,7 +464,7 @@ class WPAppNetworkManager {
471464 /// Returns [String] url path for request.
472465 String _getRouteUrlForType (
473466 WPRouteType wpRouteType, {
474- String apiVersion = 'v1 ' ,
467+ String apiVersion = 'v2 ' ,
475468 }) {
476469 switch (wpRouteType) {
477470 // AUTH API
0 commit comments