Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Repositories\Api;
- require_once app_path() . '/Libraries/amazon-mws-v20090101-php-2016-09-21/src/MarketplaceWebService/.mws_config.inc.php';
- require_once app_path() . '/Libraries/amazon-mws-v20090101-php-2016-09-21/src/MarketplaceWebService/Client.php';
- require_once app_path() . '/Libraries/amazon-mws-v20090101-php-2016-09-21/src/MarketplaceWebService/Model/RequestReportRequest.php';
- require_once app_path() . '/Libraries/amazon-mws-v20090101-php-2016-09-21/src/MarketplaceWebService/Interface.php';
- require_once app_path() . '/Libraries/amazon-mws-v20090101-php-2016-09-21/src/MarketplaceWebService/Exception.php';
- require_once app_path() . '/Libraries/amazon-mws-v20090101-php-2016-09-21/src/MarketplaceWebService/Model.php';
- use AmazonAdvertisingApi\Client;
- class TestRepository
- {
- private $config;
- private $client;
- private $reportType;
- private $parameters;
- function __construct()
- {
- /*
- * 1.
- */
- $this->config = [
- 'ServiceURL' => config('amazon.mws_marketplace_url.na'),
- 'ProxyHost' => null,
- 'ProxyPort' => -1,
- 'MaxErrorRetry' => 3,
- ];
- $this->client = new \MarketplaceWebService_Client(
- config('amazon.aws_access_key_id'),
- config('amazon.aws_secret_access_key'),
- $this->config,
- config('amazon.app_name'),
- config('amazon.app_version')
- );
- $this->reportType = '_GET_FBA_ESTIMATED_FBA_FEES_TXT_DATA_';
- $this->parameters = [
- 'Merchant' => config('amazon.merchant_id'),
- 'MarketplaceIdList' => ['Id' => [config('amazon.mws_marketplace_id.us')]],
- 'ReportType' => $this->reportType,
- 'ReportOptions' => 'ShowSalesChannel=true',
- 'MWSAuthToken' => config('amazon.mws_auth_token'), // Optional,
- 'StartDate' => '2017-12-21 00:00:00', //Optional
- 'EndDate' => '2017-12-21 23:59:59', //Optional
- ];
- }
- public function getTest()
- {
- return $this->getMwsRequestReport($this->client, $this->parameters);
- }
- /*
- * 1. RequestReport
- *
- */
- function getMwsRequestReport(\MarketplaceWebService_Interface $client, $parameters) {
- $reportRequestInfo = null;
- $responseMetadata = null;
- return response()->json([get_object_vars($client)]);
- die();
- try {
- $request = new \MarketplaceWebService_Model_RequestReportRequest($parameters);
- $response = $client->requestReport($request);
- if ($response->isSetRequestReportResult()) {
- $requestReportResult = $response->getRequestReportResult();
- if ($requestReportResult->isSetReportRequestInfo()) {
- $reportRequestInfo = $requestReportResult->getReportRequestInfo();
- // if ($reportRequestInfo->isSetReportRequestId())
- // {
- // echo(" " . $reportRequestInfo->getReportRequestId() . "\n");
- // }
- }
- }
- if ($response->isSetResponseMetadata()) {
- $responseMetadata = $response->getResponseMetadata();
- // if ($responseMetadata->isSetRequestId())
- // {
- // echo(" " . $responseMetadata->getRequestId() . "\n");
- // }
- }
- } catch (MarketplaceWebService_Exception $ex) {
- echo("Caught Exception: " . $ex->getMessage() . "\n");
- echo("Response Status Code: " . $ex->getStatusCode() . "\n");
- echo("Error Code: " . $ex->getErrorCode() . "\n");
- echo("Error Type: " . $ex->getErrorType() . "\n");
- echo("Request ID: " . $ex->getRequestId() . "\n");
- echo("XML: " . $ex->getXML() . "\n");
- echo("ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . "\n");
- }
- return [
- 'ReportRequestInfo' => $reportRequestInfo,
- 'ResponseMetadata' => $responseMetadata
- ];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment