Skip to content

Commit

Permalink
Merge pull request #18 from Peardian/environment
Browse files Browse the repository at this point in the history
Moved Amazon API variabls to separate file
  • Loading branch information
carl689 committed Mar 24, 2014
2 parents 09be5f8 + db32cb6 commit df80acc
Show file tree
Hide file tree
Showing 30 changed files with 362 additions and 360 deletions.
70 changes: 0 additions & 70 deletions amazon-config.default.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,6 @@
//Current setting is United States
$AMAZON_SERVICE_URL = 'https://mws.amazonservices.com/';

//for User-Agent header(?)
$AMAZON_APPLICATION = 'phpAmazonMWS';
$AMAZON_APPVERSION = '1.0';


//Version numbers for cores
$AMAZON_VERSION_FEEDS = '2009-01-01';
$AMAZON_VERSION_INBOUND = '2010-10-01';
$AMAZON_VERSION_INVENTORY = '2010-10-01';
$AMAZON_VERSION_ORDERS = '2011-01-01';
$AMAZON_VERSION_OUTBOUND = '2010-10-01';
$AMAZON_VERSION_PRODUCTS = '2011-10-01';
$AMAZON_VERSION_REPORTS = '2009-01-01';
$AMAZON_VERSION_SELLERS = '2011-07-01';


//Location of log file to use
$logpath = __DIR__.'/log.txt';

Expand All @@ -51,58 +35,4 @@
//Turn off normal logging
$muteLog = false;

//Amazon Throttle Values in seconds
//Do not modify unless Amazon changes the values
//Fetching Orders
$THROTTLE_LIMIT_ORDER = 6;
$THROTTLE_TIME_ORDER = 60;
//Fetching Order Lists
$THROTTLE_LIMIT_ORDERLIST = 6;
$THROTTLE_TIME_ORDERLIST = 60;
//Fetching Items
$THROTTLE_LIMIT_ITEM = 30;
$THROTTLE_TIME_ITEM = 2;
//Fetching Service Status
$THROTTLE_LIMIT_STATUS = 2;
$THROTTLE_TIME_STATUS = 300;
//Fetching Sellers Participation
$THROTTLE_LIMIT_SELLERS = 15;
$THROTTLE_TIME_SELLERS = 60;
//Anything in Inbound/Inventory/Outbound
$THROTTLE_LIMIT_INVENTORY = 30;
$THROTTLE_TIME_INVENTORY = 2;
//Products
$THROTTLE_LIMIT_PRODUCT = 20;
$THROTTLE_TIME_PRODUCTLIST = 5;
$THROTTLE_TIME_PRODUCTMATCH = 1;
$THROTTLE_TIME_PRODUCTID = 4;
$THROTTLE_TIME_PRODUCTPRICE = 2;
//Requesting a Report
$THROTTLE_LIMIT_REPORTREQUEST = 15;
$THROTTLE_TIME_REPORTREQUEST = 60;
//Fetching a Report Request List
$THROTTLE_LIMIT_REPORTREQUESTLIST = 10;
$THROTTLE_TIME_REPORTREQUESTLIST = 45;
//Using a token with a report request
$THROTTLE_LIMIT_REPORTTOKEN = 30;
$THROTTLE_TIME_REPORTTOKEN = 2;
//Fetching a Report List
$THROTTLE_LIMIT_REPORTLIST = 10;
$THROTTLE_TIME_REPORTLIST = 60;
//Fetching a Report
$THROTTLE_LIMIT_REPORT = 15;
$THROTTLE_TIME_REPORT = 60;
//Fetching a Report Request List
$THROTTLE_LIMIT_REPORTSCHEDULE = 10;
$THROTTLE_TIME_REPORTSCHEDULE = 45;
//Submitting a Feed
$THROTTLE_LIMIT_FEEDSUBMIT = 15;
$THROTTLE_TIME_FEEDSUBMIT = 120;
//Getting a Feed
$THROTTLE_LIMIT_FEEDLIST = 10;
$THROTTLE_TIME_FEEDLIST = 45;
//Getting a Feed
$THROTTLE_LIMIT_FEEDRESULT = 15;
$THROTTLE_TIME_FEEDRESULT = 60;

?>
92 changes: 92 additions & 0 deletions environment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php
/**
* Copyright 2013 CPI Group, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
*
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* These variables pertain to the inner workings of the Amazon API.
* The values come from Amazon and should not be modified.
* Otherwise, the library may not be able to connect to Amazon.
*/

//for User-Agent header(?)
$AMAZON_APPLICATION = 'phpAmazonMWS';
$AMAZON_APPVERSION = '1.0';

//Version numbers for cores
$AMAZON_VERSION_FEEDS = '2009-01-01';
$AMAZON_VERSION_INBOUND = '2010-10-01';
$AMAZON_VERSION_INVENTORY = '2010-10-01';
$AMAZON_VERSION_ORDERS = '2011-01-01';
$AMAZON_VERSION_OUTBOUND = '2010-10-01';
$AMAZON_VERSION_PRODUCTS = '2011-10-01';
$AMAZON_VERSION_REPORTS = '2009-01-01';
$AMAZON_VERSION_SELLERS = '2011-07-01';

//Amazon Throttle Values in seconds
//Fetching Orders
$THROTTLE_LIMIT_ORDER = 6;
$THROTTLE_TIME_ORDER = 60;
//Fetching Order Lists
$THROTTLE_LIMIT_ORDERLIST = 6;
$THROTTLE_TIME_ORDERLIST = 60;
//Fetching Items
$THROTTLE_LIMIT_ITEM = 30;
$THROTTLE_TIME_ITEM = 2;
//Fetching Service Status
$THROTTLE_LIMIT_STATUS = 2;
$THROTTLE_TIME_STATUS = 300;
//Fetching Sellers Participation
$THROTTLE_LIMIT_SELLERS = 15;
$THROTTLE_TIME_SELLERS = 60;
//Anything in Inbound/Inventory/Outbound
$THROTTLE_LIMIT_INVENTORY = 30;
$THROTTLE_TIME_INVENTORY = 2;
//Products
$THROTTLE_LIMIT_PRODUCT = 20;
$THROTTLE_TIME_PRODUCTLIST = 5;
$THROTTLE_TIME_PRODUCTMATCH = 1;
$THROTTLE_TIME_PRODUCTID = 4;
$THROTTLE_TIME_PRODUCTPRICE = 2;
//Requesting a Report
$THROTTLE_LIMIT_REPORTREQUEST = 15;
$THROTTLE_TIME_REPORTREQUEST = 60;
//Fetching a Report Request List
$THROTTLE_LIMIT_REPORTREQUESTLIST = 10;
$THROTTLE_TIME_REPORTREQUESTLIST = 45;
//Using a token with a report request
$THROTTLE_LIMIT_REPORTTOKEN = 30;
$THROTTLE_TIME_REPORTTOKEN = 2;
//Fetching a Report List
$THROTTLE_LIMIT_REPORTLIST = 10;
$THROTTLE_TIME_REPORTLIST = 60;
//Fetching a Report
$THROTTLE_LIMIT_REPORT = 15;
$THROTTLE_TIME_REPORT = 60;
//Fetching a Report Request List
$THROTTLE_LIMIT_REPORTSCHEDULE = 10;
$THROTTLE_TIME_REPORTSCHEDULE = 45;
//Submitting a Feed
$THROTTLE_LIMIT_FEEDSUBMIT = 15;
$THROTTLE_TIME_FEEDSUBMIT = 120;
//Getting a Feed
$THROTTLE_LIMIT_FEEDLIST = 10;
$THROTTLE_TIME_FEEDLIST = 45;
//Getting a Feed
$THROTTLE_LIMIT_FEEDRESULT = 15;
$THROTTLE_TIME_FEEDRESULT = 60;

?>
2 changes: 2 additions & 0 deletions includes/classes/AmazonCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ abstract class AmazonCore{
protected $mockFiles;
protected $mockIndex = 0;
protected $logpath;
protected $env;

/**
* AmazonCore constructor sets up key information used in all Amazon requests.
Expand All @@ -130,6 +131,7 @@ protected function __construct($s, $mock=false, $m = null, $config = null){
$this->setStore($s);
$this->setMock($mock,$m);

$this->env=__DIR__.'/../../environment.php';
$this->options['SignatureVersion'] = 2;
$this->options['SignatureMethod'] = 'HmacSHA256';
}
Expand Down
23 changes: 9 additions & 14 deletions includes/classes/AmazonFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,16 @@ class AmazonFeed extends AmazonFeedsCore{
*/
public function __construct($s, $mock = false, $m = null, $config = null){
parent::__construct($s, $mock, $m, $config);
if (file_exists($this->config)){
include($this->config);
} else {
throw new Exception('Config file does not exist!');
}
include($this->env);

$this->options['Action'] = 'SubmitFeed';

if(isset($THROTTLE_LIMIT_FEEDSUBMIT))
$this->throttleLimit = $THROTTLE_LIMIT_FEEDSUBMIT;
if(isset($THROTTLE_TIME_FEEDSUBMIT))
$this->throttleTime = $THROTTLE_TIME_FEEDSUBMIT;
if(isset($THROTTLE_LIMIT_FEEDSUBMIT)) {
$this->throttleLimit = $THROTTLE_LIMIT_FEEDSUBMIT;
}
if(isset($THROTTLE_TIME_FEEDSUBMIT)) {
$this->throttleTime = $THROTTLE_TIME_FEEDSUBMIT;
}
$this->throttleGroup = 'SubmitFeed';
}

Expand Down Expand Up @@ -213,12 +211,9 @@ public function setPurge($s = 'true'){
} else if ($s == 'false' || (!$s && is_bool($s))){
$this->log("Purge mode deactivated.");
$this->options['PurgeAndReplace'] = 'false';
if (file_exists($this->config)){
include($this->config);
if(isset($THROTTLE_TIME_FEEDSUBMIT))
include($this->env);
if(isset($THROTTLE_TIME_FEEDSUBMIT)) {
$this->throttleTime = $THROTTLE_TIME_FEEDSUBMIT;
} else {
return false;
}
} else {
return false;
Expand Down
60 changes: 33 additions & 27 deletions includes/classes/AmazonFeedList.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,14 @@ class AmazonFeedList extends AmazonFeedsCore implements Iterator{
*/
public function __construct($s, $mock = false, $m = null, $config = null){
parent::__construct($s, $mock, $m, $config);
if (file_exists($this->config)){
include($this->config);
} else {
throw new Exception('Config file does not exist!');
}
include($this->env);

if(isset($THROTTLE_LIMIT_FEEDLIST))
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
if(isset($THROTTLE_TIME_FEEDLIST))
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
if(isset($THROTTLE_LIMIT_FEEDLIST)) {
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
}
if(isset($THROTTLE_TIME_FEEDLIST)) {
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
}
}

/**
Expand Down Expand Up @@ -308,13 +306,15 @@ public function fetchFeedSubmissions($r = true){
* parameters will be removed.
*/
protected function prepareToken(){
include($this->config);
include($this->env);
if ($this->tokenFlag && $this->tokenUseFlag){
$this->options['Action'] = 'GetFeedSubmissionListByNextToken';
if(isset($THROTTLE_LIMIT_REPORTTOKEN))
$this->throttleLimit = $THROTTLE_LIMIT_REPORTTOKEN;
if(isset($THROTTLE_TIME_REPORTTOKEN))
$this->throttleTime = $THROTTLE_TIME_REPORTTOKEN;
if(isset($THROTTLE_LIMIT_REPORTTOKEN)) {
$this->throttleLimit = $THROTTLE_LIMIT_REPORTTOKEN;
}
if(isset($THROTTLE_TIME_REPORTTOKEN)) {
$this->throttleTime = $THROTTLE_TIME_REPORTTOKEN;
}
$this->throttleGroup = 'GetFeedSubmissionListByNextToken';
$this->resetFeedTypes();
$this->resetFeedStatuses();
Expand All @@ -323,10 +323,12 @@ protected function prepareToken(){
unset($this->options['MaxCount']);
} else {
$this->options['Action'] = 'GetFeedSubmissionList';
if(isset($THROTTLE_LIMIT_FEEDLIST))
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
if(isset($THROTTLE_TIME_FEEDLIST))
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
if(isset($THROTTLE_LIMIT_FEEDLIST)) {
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
}
if(isset($THROTTLE_TIME_FEEDLIST)) {
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
}
$this->throttleGroup = 'GetFeedSubmissionList';
unset($this->options['NextToken']);
$this->feedList = array();
Expand Down Expand Up @@ -405,10 +407,12 @@ public function countFeeds(){
*/
protected function prepareCount(){
$this->options['Action'] = 'GetFeedSubmissionCount';
if(isset($THROTTLE_LIMIT_FEEDLIST))
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
if(isset($THROTTLE_TIME_FEEDLIST))
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
if(isset($THROTTLE_LIMIT_FEEDLIST)) {
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
}
if(isset($THROTTLE_TIME_FEEDLIST)) {
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
}
$this->throttleGroup = 'GetFeedSubmissionCount';
$this->resetFeedIds();
unset($this->options['MaxCount']);
Expand Down Expand Up @@ -457,12 +461,14 @@ public function cancelFeeds(){
* feed statuses, max count, and token.
*/
protected function prepareCancel(){
include($this->config);
include($this->env);
$this->options['Action'] = 'CancelFeedSubmissions';
if(isset($THROTTLE_LIMIT_FEEDLIST))
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
if(isset($THROTTLE_TIME_FEEDLIST))
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
if(isset($THROTTLE_LIMIT_FEEDLIST)) {
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
}
if(isset($THROTTLE_TIME_FEEDLIST)) {
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
}
$this->throttleGroup = 'CancelFeedSubmissions';
unset($this->options['MaxCount']);
unset($this->options['NextToken']);
Expand Down
16 changes: 7 additions & 9 deletions includes/classes/AmazonFeedResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,20 @@ class AmazonFeedResult extends AmazonFeedsCore{
*/
public function __construct($s, $id = null, $mock = false, $m = null, $config = null){
parent::__construct($s, $mock, $m, $config);
if (file_exists($this->config)){
include($this->config);
} else {
throw new Exception('Config file does not exist!');
}
include($this->env);

if($id){
$this->options['FeedSubmissionId'] = $id;
}

$this->options['Action'] = 'GetFeedSubmissionResult';

if(isset($THROTTLE_LIMIT_FEEDRESULT))
$this->throttleLimit = $THROTTLE_LIMIT_FEEDRESULT;
if(isset($THROTTLE_TIME_FEEDRESULT))
$this->throttleTime = $THROTTLE_TIME_FEEDRESULT;
if(isset($THROTTLE_LIMIT_FEEDRESULT)) {
$this->throttleLimit = $THROTTLE_LIMIT_FEEDRESULT;
}
if(isset($THROTTLE_TIME_FEEDRESULT)) {
$this->throttleTime = $THROTTLE_TIME_FEEDRESULT;
}
$this->throttleGroup = 'GetFeedSubmissionResult';
}

Expand Down
11 changes: 4 additions & 7 deletions includes/classes/AmazonFeedsCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,12 @@ abstract class AmazonFeedsCore extends AmazonCore{
*/
public function __construct($s, $mock = false, $m = null, $config = null){
parent::__construct($s, $mock, $m, $config);
if (file_exists($this->config)){
include($this->config);
} else {
throw new Exception('Config file does not exist!');
}
include($this->env);

$this->urlbranch = '';
if(isset($AMAZON_VERSION_FEEDS))
$this->options['Version'] = $AMAZON_VERSION_FEEDS;
if(isset($AMAZON_VERSION_FEEDS)) {
$this->options['Version'] = $AMAZON_VERSION_FEEDS;
}
}
}
?>
Loading

0 comments on commit df80acc

Please sign in to comment.