From 1283f1d266f27f7c8a3e06b778cee14b6110599d Mon Sep 17 00:00:00 2001 From: Padmanathan Date: Tue, 23 May 2017 20:53:39 +0530 Subject: [PATCH] Update Price apiVersion V2 to V3 --- src/Price.php | 14 ++++++++++++-- src/descriptions/price.php | 2 +- src/mock/feeds.php | 2 +- src/mock/prices.php | 2 +- tests/PriceTest.php | 21 +-------------------- 5 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/Price.php b/src/Price.php index ecee650..e7427bb 100644 --- a/src/Price.php +++ b/src/Price.php @@ -18,9 +18,19 @@ class Price extends BaseClient public function __construct(array $config = [], $env = self::ENV_PROD) { // Apply some defaults. - $config += [ + $this->wmConsumerChannelType = $config['wmConsumerChannelType']; + + // Apply some defaults. + $config = array_merge_recursive($config, [ 'description_path' => __DIR__ . '/descriptions/price.php', - ]; + 'http_client_options' => [ + 'defaults' => [ + 'headers' => [ + 'WM_CONSUMER.CHANNEL.TYPE' => $this->wmConsumerChannelType, + ], + ], + ], + ]); // Create the client. parent::__construct( diff --git a/src/descriptions/price.php b/src/descriptions/price.php index 8497be5..cd71645 100644 --- a/src/descriptions/price.php +++ b/src/descriptions/price.php @@ -1,6 +1,6 @@ 'https://marketplace.walmartapis.com', - 'apiVersion' => 'v2', + 'apiVersion' => 'v3', 'operations' => [ 'Update' => [ 'httpMethod' => 'PUT', diff --git a/src/mock/feeds.php b/src/mock/feeds.php index 49081bb..bdd7fba 100644 --- a/src/mock/feeds.php +++ b/src/mock/feeds.php @@ -146,7 +146,7 @@ ' ], - 'POST /v2/feeds?feedType=price' => [ + 'POST /v3/feeds?feedType=price' => [ 'status' => 200, 'headers' => [], 'body' => ' diff --git a/src/mock/prices.php b/src/mock/prices.php index 503407c..7277fd6 100644 --- a/src/mock/prices.php +++ b/src/mock/prices.php @@ -1,6 +1,6 @@ [ + 'PUT /v3/prices?sku=1131270¤cy=USD&price=55' => [ 'status' => 200, 'headers' => [], 'body' => ' diff --git a/tests/PriceTest.php b/tests/PriceTest.php index fea40f5..bf2d2a6 100644 --- a/tests/PriceTest.php +++ b/tests/PriceTest.php @@ -29,31 +29,12 @@ public function __construct() ], 'consumerId' => Env::get('CONSUMER_ID', 'hw30cqp3-35fi-1bi0-3312-hw9fgm30d2p4'), 'privateKey' => Env::get('PRIVATE_KEY', 'MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKzXEfCYdnBNkKAwVbCpg/tR40WixoZtiuEviSEi4+LdnYAAPy57Qw6+9eqJGTh9iCB2wP/I8lWh5TZ49Hq/chjTCPeJiOqi6bvX1xzyBlSq2ElSY3iEVKeVoQG/5f9MYQLEj5/vfTWSNASsMwnNeBbbHcV1S1aY9tOsXCzRuxapAgMBAAECgYBjkM1j1OA9l2Ed9loWl8BQ8X5D6h4E6Gudhx2uugOe9904FGxRIW6iuvy869dchGv7j41ki+SV0dpRw+HKKCjYE6STKpe0YwIm/tml54aNDQ0vQvF8JWILca1a7v3Go6chf3Ib6JPs6KVsUuNo+Yd+jKR9GAKgnDeXS6NZlTBUAQJBANex815VAySumJ/n8xR+h/dZ2V5qGj6wu3Gsdw6eNYKQn3I8AGQw8N4yzDUoFnrQxqDmP3LOyr3/zgOMNTdszIECQQDNIxiZOVl3/Sjyxy9WHMk5qNfSf5iODynv1OlTG+eWao0Wj/NdfLb4pwxRsf4XZFZ1SQNkbNne7+tEO8FTG1YpAkAwNMY2g/ty3E6iFl3ea7UJlBwfnMkGz8rkye3F55f/+UCZcE2KFuIOVv4Kt03m3vg1h6AQkaUAN8acRl6yZ2+BAkEAke2eiRmYANiR8asqjGqr5x2qcm8ceiplXdwrI1kddQ5VUbCTonSewOIszEz/gWp6arLG/ADHOGWaCo8rptAyiQJACXd1ddXUAKs6x3l752tSH8dOde8nDBgF86NGvgUnBiAPPTmJHuhWrmOZmNaB68PsltEiiFwWByGFV+ld9VKmKg=='), + 'wmConsumerChannelType' => Env::get('WM_CONSUMER_CHANNEL_TYPE', 'ABC123'), ]; parent::__construct(); } - public function testUpdate() - { - $client = $this->getClient(); - try { - $update = $client->update([ - 'sku' => '1131270', - 'currency' => 'USD', - 'price' => '55', - ]); - $this->assertEquals(200, $update['statusCode']); - $this->assertEquals('WALMART_US', $update['mart']); - $this->debug($update); - } catch (CommandClientException $e) { - $error = $e->getResponse()->getHeader('X-Error'); - $this->fail($e->getMessage() . 'Error: ' . $error); - } catch (\Exception $e) { - $this->fail($e->getMessage()); - } - } - public function testBulk() { $client = $this->getClient();