caponica / AmazonMwsComplete

Name-spaced wrappers for the full set of Amazon MWS client libraries
56 stars 53 forks source link

OrdersList API alway returning null values for "x-mws-quota-max", "x-mws-quota-remaining" and "x-mws-quota-resetsOn" in ResponseHeaderMetadata #14

Closed test2mailer closed 6 years ago

test2mailer commented 7 years ago

Hii Friend, I am integrating this package for ordersList API but it is alway returning null values for "x-mws-quota-max", "x-mws-quota-remaining" and "x-mws-quota-resetsOn" in ResponseHeaderMetadata.

here are request codes:

$todayDate =Carbon::today();
$mwsClientPoolUsa = new MwsClientPool();
        $mwsClientPoolUsa->setConfig([
        'amazon_site'         => MwsClientPoolConfig::SITE_USA,
        'access_key'          => env('AWS_ACCESS_KEY_ID'),
        'secret_key'          => env('AWS_SECRET_ACCESS_KEY'),
        'application_name'    => env('APPLICATION_NAME'),
        'application_version' => env('APPLICATION_VERSION'),
        'seller_id'           => env('SELLER_ID'),
        'marketplace_id'      => env('MARKETPLACE_ID')      
        ]);
$orderClientPack    = $mwsClientPoolUsa->getOrderClientPack(); 
$mwsResponse = $orderClientPack->callListOrdersByLastUpdatedDate($todayDate,[],['MWSAuthToken'=> env('MWS_AUTH_TOKEN')]);
dd($mwsResponse);

and here are response:

MarketplaceWebServiceOrders_Model_ListOrdersResponse {#306 ▼
  #_fields: array:3 [▼
    "ListOrdersResult" => array:2 [▶]
    "ResponseMetadata" => array:2 [▼
      "FieldValue" => MarketplaceWebServiceOrders_Model_ResponseMetadata {#309 ▶}
      "FieldType" => "MarketplaceWebServiceOrders_Model_ResponseMetadata"
    ]
    "ResponseHeaderMetadata" => array:2 [▼
      "FieldValue" => MarketplaceWebServiceOrders_Model_ResponseHeaderMetadata {#301 ▼
        -metadata: array:6 [▼
          "x-mws-request-id" => "xxxx-xxxx-xxxx-xxxx-xxxxxxxxx"
          "x-mws-response-context" => "T71b8VB2qL4JJSpv1dLxs4doOHt7OUbak7YHfgftggt5Zmic7Nwg5g67jhf46H98F8e1K28+MUA="
          "x-mws-timestamp" => "2017-10-25T06:32:58.535Z"
          "x-mws-quota-max" => null
          "x-mws-quota-remaining" => null
          "x-mws-quota-resetsOn" => null
        ]
      }
      "FieldType" => "MarketplaceWebServiceOrders_Model_ResponseHeaderMetadata"
    ]
  ]
}

and also can you please guide me how to manage throttling flow.

-- Thanks

caponica commented 7 years ago

I'm not sure if this is the problem, but you're calling the method with odd parameters.

E.g. it should be something like $orderClientPack->callListOrdersByLastUpdatedDate($yesterdayDate);

caponica commented 7 years ago

And the code should manage the throttling for you already - it knows the expected gaps between requests so puts in pauses if you try to make to many calls. If a "request throttled" response comes back from Amazon then it will wait double the normal time and try that call again (once) before throwing an Exception.

bretto36 commented 7 years ago

Is this MWSAuthToken part valid? I can't see that function parameters to send the MWSAuthToken along, the callListOrdersByLastUpdatedDate only takes 2 parameters

$mwsResponse = $orderClientPack->callListOrdersByLastUpdatedDate($todayDate,[],['MWSAuthToken'=> env('MWS_AUTH_TOKEN')]);

caponica commented 6 years ago

AuthToken support has been added in #799fe0b - please let me know if this is working for you as required. I don't use AuthToken myself so it's hard to test!