Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/Price.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/descriptions/price.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php return [
'baseUrl' => 'https://marketplace.walmartapis.com',
'apiVersion' => 'v2',
'apiVersion' => 'v3',
'operations' => [
'Update' => [
'httpMethod' => 'PUT',
Expand Down
2 changes: 1 addition & 1 deletion src/mock/feeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
</ns2:FeedAcknowledgement>'
],

'POST /v2/feeds?feedType=price' => [
'POST /v3/feeds?feedType=price' => [
'status' => 200,
'headers' => [],
'body' => '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
Expand Down
2 changes: 1 addition & 1 deletion src/mock/prices.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
return [
'PUT /v2/prices?sku=1131270&currency=USD&price=55' => [
'PUT /v3/prices?sku=1131270&currency=USD&price=55' => [
'status' => 200,
'headers' => [],
'body' => '<?xml version="1.0" encoding="UTF-8"?>
Expand Down
21 changes: 1 addition & 20 deletions tests/PriceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down