Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

Laravel 5 and fixes #4

Open
wants to merge 14 commits into
base: stable
Choose a base branch
from
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
composer.phar
composer.lock
.DS_Store
.idea
amazon-config.php
test.php
log.txt
Expand Down
5 changes: 3 additions & 2 deletions amazon-config.default.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
$store['YourAmazonStore']['marketplaceId'] = ''; //Marketplace ID for this store
$store['YourAmazonStore']['keyId'] = ''; //Access Key ID
$store['YourAmazonStore']['secretKey'] = ''; //Secret Access Key for this store
$store['YourAmazonStore']['amazonServiceUrl'] = 'https://mws-eu.amazonservices.com/'; // Service Url for this store

//Service URL Base
//Current setting is United States
// Service URL Base (Default if not set by store)
// Current setting is United States
$AMAZON_SERVICE_URL = 'https://mws.amazonservices.com/';

//Location of log file to use
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"require": {
"php": ">=5.4.0",
"ext-curl": "*",
"illuminate/support": "4.2.*"
"illuminate/support": "5.*"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
Expand Down
4 changes: 2 additions & 2 deletions includes/classes/AmazonFulfillmentOrderCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function setAddress($a){
$this->options['DestinationAddress.DistrictOrCounty'] = null;
}
$this->options['DestinationAddress.City'] = $a['City'];
$this->options['DestinationAddress.StateOrProvidenceCode'] = $a['StateOrProvidenceCode'];
$this->options['DestinationAddress.StateOrProvinceCode'] = $a['StateOrProvinceCode'];
$this->options['DestinationAddress.CountryCode'] = $a['CountryCode'];
$this->options['DestinationAddress.PostalCode'] = $a['PostalCode'];
if (array_key_exists('PhoneNumber', $a)){
Expand All @@ -201,7 +201,7 @@ protected function resetAddress(){
unset($this->options['DestinationAddress.Line3']);
unset($this->options['DestinationAddress.DistrictOrCounty']);
unset($this->options['DestinationAddress.City']);
unset($this->options['DestinationAddress.StateOrProvidenceCode']);
unset($this->options['DestinationAddress.StateOrProvinceCode']);
unset($this->options['DestinationAddress.CountryCode']);
unset($this->options['DestinationAddress.PostalCode']);
unset($this->options['DestinationAddress.PhoneNumber']);
Expand Down
4 changes: 2 additions & 2 deletions includes/classes/AmazonFulfillmentPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function setAddress($a){
$this->options['Address.DistrictOrCounty'] = null;
}
$this->options['Address.City'] = $a['City'];
$this->options['Address.StateOrProvidenceCode'] = $a['StateOrProvidenceCode'];
$this->options['Address.StateOrProvinceCode'] = $a['StateOrProvinceCode'];
$this->options['Address.CountryCode'] = $a['CountryCode'];
$this->options['Address.PostalCode'] = $a['PostalCode'];
if (array_key_exists('PhoneNumber', $a)){
Expand All @@ -112,7 +112,7 @@ protected function resetAddress(){
unset($this->options['Address.Line3']);
unset($this->options['Address.DistrictOrCounty']);
unset($this->options['Address.City']);
unset($this->options['Address.StateOrProvidenceCode']);
unset($this->options['Address.StateOrProvinceCode']);
unset($this->options['Address.CountryCode']);
unset($this->options['Address.PostalCode']);
unset($this->options['Address.PhoneNumber']);
Expand Down
4 changes: 2 additions & 2 deletions includes/classes/AmazonReportRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ public function resetTimeLimits(){
*/
public function setShowSalesChannel($s){
if ($s == 'true' || (is_bool($s) && $s == true)){
$this->options['ReportOptions=ShowSalesChannel'] = 'true';
$this->options['ShowSalesChannel'] = 'true';
} else if ($s == 'false' || (is_bool($s) && $s == false)){
$this->options['ReportOptions=ShowSalesChannel'] = 'false';
$this->options['ShowSalesChannel'] = 'false';
} else {
return false;
}
Expand Down
21 changes: 14 additions & 7 deletions src/Creacoon/AmazonMws/AmazonCore.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php namespace Creacoon\AmazonMws;

use Config, Log;
use DateTime;
use Exception;

/**
* Copyright 2013 CPI Group, LLC
Expand Down Expand Up @@ -355,12 +357,12 @@ protected function checkResponse($r){
// * @throws Exception If the file cannot be found or read.

public function setConfig(){
$AMAZON_SERVICE_URL = Config::get('amazon-mws::AMAZON_SERVICE_URL');
$AMAZON_SERVICE_URL = Config::get('amazon-mws.AMAZON_SERVICE_URL');

if (isset($AMAZON_SERVICE_URL)){
$this->urlbase = $AMAZON_SERVICE_URL;
} else {
throw new Exception("Config file does not exist or cannot be read! ($path)");
throw new Exception("Config file does not exist or cannot be read!");
}
}

Expand All @@ -382,7 +384,7 @@ public function setStore($s){
// throw new \Exception("Config file does not exist!");
// }

$store = Config::get('amazon-mws::store');
$store = Config::get('amazon-mws.store');

if(array_key_exists($s, $store)){
$this->storeName = $s;
Expand All @@ -399,6 +401,11 @@ public function setStore($s){
if(!array_key_exists('secretKey', $store[$s])){
$this->log("Secret Key is missing!",'Warning');
}
// Overwrite Amazon service url if specified
if(array_key_exists('amazonServiceUrl', $store[$s])){
$AMAZON_SERVICE_URL = $store[$s]['amazonServiceUrl'];
$this->urlbase = $AMAZON_SERVICE_URL;
}

} else {
throw new \Exception("Store $s does not exist!");
Expand Down Expand Up @@ -434,7 +441,7 @@ protected function log($msg, $level = 'Info'){
if ($msg != false) {
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);

$muteLog = Config::get('amazon-mws::muteLog');
$muteLog = Config::get('amazon-mws.muteLog');

switch ($level){
case('Info'): $loglevel = 'info'; break;
Expand Down Expand Up @@ -508,7 +515,7 @@ protected function genTime($time=false){
$time = strtotime($time);

}
return date('Y-m-d\TH:i:sO',$time-120);
return date(DateTime::ISO8601,$time-120);

}

Expand All @@ -528,12 +535,12 @@ protected function genQuery(){
// throw new Exception("Config file does not exist!");
// }

$store = Config::get('amazon-mws::store');
$store = Config::get('amazon-mws.store');

if (array_key_exists($this->storeName, $store) && array_key_exists('secretKey', $store[$this->storeName])){
$secretKey = $store[$this->storeName]['secretKey'];
} else {
throw new \Exception("Secret Key is missing!");
throw new Exception("Secret Key is missing!");
}

unset($this->options['Signature']);
Expand Down
2 changes: 1 addition & 1 deletion src/Creacoon/AmazonMws/AmazonFeed.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php namespace Creacoon\AmazonMws;
/**
* Copyright 2013 CPI Group, LLC
*
Expand Down
3 changes: 2 additions & 1 deletion src/Creacoon/AmazonMws/AmazonFeedList.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php namespace Creacoon\AmazonMws;
/**
* Copyright 2013 CPI Group, LLC
*
Expand All @@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use Iterator;

/**
* Receives a list of feeds from Amazon.
Expand Down
3 changes: 2 additions & 1 deletion src/Creacoon/AmazonMws/AmazonFeedResult.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php namespace Creacoon\AmazonMws;
/**
* Copyright 2013 CPI Group, LLC
*
Expand All @@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use Exception;

/**
* Retrieves feeds from Amazon.
Expand Down
2 changes: 1 addition & 1 deletion src/Creacoon/AmazonMws/AmazonFeedsCore.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php namespace Creacoon\AmazonMws;
/**
* Copyright 2013 CPI Group, LLC
*
Expand Down
2 changes: 1 addition & 1 deletion src/Creacoon/AmazonMws/AmazonFulfillmentOrder.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php namespace Creacoon\AmazonMws;
/**
* Copyright 2013 CPI Group, LLC
*
Expand Down
35 changes: 31 additions & 4 deletions src/Creacoon/AmazonMws/AmazonFulfillmentOrderCreator.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php namespace Creacoon\AmazonMws;
/**
* Copyright 2013 CPI Group, LLC
*
Expand Down Expand Up @@ -56,6 +56,7 @@ public function __construct($s, $mock = false, $m = null, $config = null) {
public function setFulfillmentOrderId($s){
if (is_string($s)){
$this->options['SellerFulfillmentOrderId'] = $s;
return true;
} else {
return false;
}
Expand All @@ -73,11 +74,30 @@ public function setFulfillmentOrderId($s){
public function setDisplayableOrderId($s){
if (is_string($s)){
$this->options['DisplayableOrderId'] = $s;
return true;
} else {
return false;
}
}


/**
* Sets the displayed order comment. (Optional)
*
* Order-specific text that appears in customer-facing materials such as the outbound shipment packing slip.
* Maximum: 1000 characters
*
* @param $s
* @return bool
*/
public function setDisplayableOrderComment($s){
if (is_string($s)){
$this->options['DisplayableOrderComment'] = $s;
return true;
} else {
return false;
}
}

/**
* Sets the displayed timestamp. (Required)
*
Expand All @@ -91,6 +111,7 @@ public function setDate($s){
if (is_string($s)){
$time = $this->genTime($s);
$this->options['DisplayableOrderDateTime'] = $time;
return true;
} else {
return false;
}
Expand All @@ -107,6 +128,7 @@ public function setDate($s){
public function setComment($s){
if (is_string($s)){
$this->options['DisplayableOrderComment'] = $s;
return true;
} else {
return false;
}
Expand All @@ -124,6 +146,7 @@ public function setShippingSpeed($s){
if (is_string($s)){
if ($s == 'Standard' || $s == 'Expedited' || $s == 'Priority'){
$this->options['ShippingSpeedCategory'] = $s;
return true;
} else {
$this->log("Tried to set shipping status to invalid value",'Warning');
return false;
Expand Down Expand Up @@ -178,14 +201,15 @@ public function setAddress($a){
$this->options['DestinationAddress.DistrictOrCounty'] = null;
}
$this->options['DestinationAddress.City'] = $a['City'];
$this->options['DestinationAddress.StateOrProvidenceCode'] = $a['StateOrProvidenceCode'];
$this->options['DestinationAddress.StateOrProvinceCode'] = $a['StateOrProvinceCode'];
$this->options['DestinationAddress.CountryCode'] = $a['CountryCode'];
$this->options['DestinationAddress.PostalCode'] = $a['PostalCode'];
if (array_key_exists('PhoneNumber', $a)){
$this->options['DestinationAddress.PhoneNumber'] = $a['PhoneNumber'];
} else {
$this->options['DestinationAddress.PhoneNumber'] = null;
}
return true;
}

/**
Expand All @@ -201,7 +225,7 @@ protected function resetAddress(){
unset($this->options['DestinationAddress.Line3']);
unset($this->options['DestinationAddress.DistrictOrCounty']);
unset($this->options['DestinationAddress.City']);
unset($this->options['DestinationAddress.StateOrProvidenceCode']);
unset($this->options['DestinationAddress.StateOrProvinceCode']);
unset($this->options['DestinationAddress.CountryCode']);
unset($this->options['DestinationAddress.PostalCode']);
unset($this->options['DestinationAddress.PhoneNumber']);
Expand All @@ -225,6 +249,7 @@ public function setFulfillmentPolicy($s){
if (is_string($s)){
if ($s == 'FillOrKill' || $s == 'FillAll' || $s == 'FillAllAvailable'){
$this->options['FulfillmentPolicy'] = $s;
return true;
} else {
$this->log("Tried to set fulfillment policy to invalid value",'Warning');
return false;
Expand All @@ -251,6 +276,7 @@ public function setFulfillmentMethod($s){
if (is_string($s)){
if ($s == 'Consumer' || $s == 'Removal'){
$this->options['FulfillmentMethod'] = $s;
return true;
} else {
$this->log("Tried to set fulfillment method to invalid value",'Warning');
return false;
Expand Down Expand Up @@ -358,6 +384,7 @@ public function setItems($a){
return false;
}
}
return true;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Creacoon/AmazonMws/AmazonFulfillmentOrderList.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php namespace Creacoon\AmazonMws;
/**
* Copyright 2013 CPI Group, LLC
*
Expand All @@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use Iterator;

/**
* Fetches a list of fulfillment orders from Amazon.
Expand Down
6 changes: 3 additions & 3 deletions src/Creacoon/AmazonMws/AmazonFulfillmentPreview.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php namespace Creacoon\AmazonMws;
/**
* Copyright 2013 CPI Group, LLC
*
Expand Down Expand Up @@ -89,7 +89,7 @@ public function setAddress($a){
$this->options['Address.DistrictOrCounty'] = null;
}
$this->options['Address.City'] = $a['City'];
$this->options['Address.StateOrProvidenceCode'] = $a['StateOrProvidenceCode'];
$this->options['Address.StateOrProvinceCode'] = $a['StateOrProvinceCode'];
$this->options['Address.CountryCode'] = $a['CountryCode'];
$this->options['Address.PostalCode'] = $a['PostalCode'];
if (array_key_exists('PhoneNumber', $a)){
Expand All @@ -112,7 +112,7 @@ protected function resetAddress(){
unset($this->options['Address.Line3']);
unset($this->options['Address.DistrictOrCounty']);
unset($this->options['Address.City']);
unset($this->options['Address.StateOrProvidenceCode']);
unset($this->options['Address.StateOrProvinceCode']);
unset($this->options['Address.CountryCode']);
unset($this->options['Address.PostalCode']);
unset($this->options['Address.PhoneNumber']);
Expand Down
2 changes: 1 addition & 1 deletion src/Creacoon/AmazonMws/AmazonInboundCore.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php namespace Creacoon\AmazonMws;
/**
* Copyright 2013 CPI Group, LLC
*
Expand Down
2 changes: 1 addition & 1 deletion src/Creacoon/AmazonMws/AmazonInventoryCore.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php namespace Creacoon\AmazonMws;
/**
* Copyright 2013 CPI Group, LLC
*
Expand Down
3 changes: 2 additions & 1 deletion src/Creacoon/AmazonMws/AmazonInventoryList.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php namespace Creacoon\AmazonMws;
/**
* Copyright 2013 CPI Group, LLC
*
Expand All @@ -15,6 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use Iterator;

/**
* Fetches list of inventory supplies from Amazon.
Expand Down
Loading