Skip to content

Commit df80acc

Browse files
committed
Merge pull request #18 from Peardian/environment
Moved Amazon API variabls to separate file
2 parents 09be5f8 + db32cb6 commit df80acc

30 files changed

+362
-360
lines changed

amazon-config.default.php

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,6 @@
2626
//Current setting is United States
2727
$AMAZON_SERVICE_URL = 'https://mws.amazonservices.com/';
2828

29-
//for User-Agent header(?)
30-
$AMAZON_APPLICATION = 'phpAmazonMWS';
31-
$AMAZON_APPVERSION = '1.0';
32-
33-
34-
//Version numbers for cores
35-
$AMAZON_VERSION_FEEDS = '2009-01-01';
36-
$AMAZON_VERSION_INBOUND = '2010-10-01';
37-
$AMAZON_VERSION_INVENTORY = '2010-10-01';
38-
$AMAZON_VERSION_ORDERS = '2011-01-01';
39-
$AMAZON_VERSION_OUTBOUND = '2010-10-01';
40-
$AMAZON_VERSION_PRODUCTS = '2011-10-01';
41-
$AMAZON_VERSION_REPORTS = '2009-01-01';
42-
$AMAZON_VERSION_SELLERS = '2011-07-01';
43-
44-
4529
//Location of log file to use
4630
$logpath = __DIR__.'/log.txt';
4731

@@ -51,58 +35,4 @@
5135
//Turn off normal logging
5236
$muteLog = false;
5337

54-
//Amazon Throttle Values in seconds
55-
//Do not modify unless Amazon changes the values
56-
//Fetching Orders
57-
$THROTTLE_LIMIT_ORDER = 6;
58-
$THROTTLE_TIME_ORDER = 60;
59-
//Fetching Order Lists
60-
$THROTTLE_LIMIT_ORDERLIST = 6;
61-
$THROTTLE_TIME_ORDERLIST = 60;
62-
//Fetching Items
63-
$THROTTLE_LIMIT_ITEM = 30;
64-
$THROTTLE_TIME_ITEM = 2;
65-
//Fetching Service Status
66-
$THROTTLE_LIMIT_STATUS = 2;
67-
$THROTTLE_TIME_STATUS = 300;
68-
//Fetching Sellers Participation
69-
$THROTTLE_LIMIT_SELLERS = 15;
70-
$THROTTLE_TIME_SELLERS = 60;
71-
//Anything in Inbound/Inventory/Outbound
72-
$THROTTLE_LIMIT_INVENTORY = 30;
73-
$THROTTLE_TIME_INVENTORY = 2;
74-
//Products
75-
$THROTTLE_LIMIT_PRODUCT = 20;
76-
$THROTTLE_TIME_PRODUCTLIST = 5;
77-
$THROTTLE_TIME_PRODUCTMATCH = 1;
78-
$THROTTLE_TIME_PRODUCTID = 4;
79-
$THROTTLE_TIME_PRODUCTPRICE = 2;
80-
//Requesting a Report
81-
$THROTTLE_LIMIT_REPORTREQUEST = 15;
82-
$THROTTLE_TIME_REPORTREQUEST = 60;
83-
//Fetching a Report Request List
84-
$THROTTLE_LIMIT_REPORTREQUESTLIST = 10;
85-
$THROTTLE_TIME_REPORTREQUESTLIST = 45;
86-
//Using a token with a report request
87-
$THROTTLE_LIMIT_REPORTTOKEN = 30;
88-
$THROTTLE_TIME_REPORTTOKEN = 2;
89-
//Fetching a Report List
90-
$THROTTLE_LIMIT_REPORTLIST = 10;
91-
$THROTTLE_TIME_REPORTLIST = 60;
92-
//Fetching a Report
93-
$THROTTLE_LIMIT_REPORT = 15;
94-
$THROTTLE_TIME_REPORT = 60;
95-
//Fetching a Report Request List
96-
$THROTTLE_LIMIT_REPORTSCHEDULE = 10;
97-
$THROTTLE_TIME_REPORTSCHEDULE = 45;
98-
//Submitting a Feed
99-
$THROTTLE_LIMIT_FEEDSUBMIT = 15;
100-
$THROTTLE_TIME_FEEDSUBMIT = 120;
101-
//Getting a Feed
102-
$THROTTLE_LIMIT_FEEDLIST = 10;
103-
$THROTTLE_TIME_FEEDLIST = 45;
104-
//Getting a Feed
105-
$THROTTLE_LIMIT_FEEDRESULT = 15;
106-
$THROTTLE_TIME_FEEDRESULT = 60;
107-
10838
?>

environment.php

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?php
2+
/**
3+
* Copyright 2013 CPI Group, LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
*
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
/**
20+
* These variables pertain to the inner workings of the Amazon API.
21+
* The values come from Amazon and should not be modified.
22+
* Otherwise, the library may not be able to connect to Amazon.
23+
*/
24+
25+
//for User-Agent header(?)
26+
$AMAZON_APPLICATION = 'phpAmazonMWS';
27+
$AMAZON_APPVERSION = '1.0';
28+
29+
//Version numbers for cores
30+
$AMAZON_VERSION_FEEDS = '2009-01-01';
31+
$AMAZON_VERSION_INBOUND = '2010-10-01';
32+
$AMAZON_VERSION_INVENTORY = '2010-10-01';
33+
$AMAZON_VERSION_ORDERS = '2011-01-01';
34+
$AMAZON_VERSION_OUTBOUND = '2010-10-01';
35+
$AMAZON_VERSION_PRODUCTS = '2011-10-01';
36+
$AMAZON_VERSION_REPORTS = '2009-01-01';
37+
$AMAZON_VERSION_SELLERS = '2011-07-01';
38+
39+
//Amazon Throttle Values in seconds
40+
//Fetching Orders
41+
$THROTTLE_LIMIT_ORDER = 6;
42+
$THROTTLE_TIME_ORDER = 60;
43+
//Fetching Order Lists
44+
$THROTTLE_LIMIT_ORDERLIST = 6;
45+
$THROTTLE_TIME_ORDERLIST = 60;
46+
//Fetching Items
47+
$THROTTLE_LIMIT_ITEM = 30;
48+
$THROTTLE_TIME_ITEM = 2;
49+
//Fetching Service Status
50+
$THROTTLE_LIMIT_STATUS = 2;
51+
$THROTTLE_TIME_STATUS = 300;
52+
//Fetching Sellers Participation
53+
$THROTTLE_LIMIT_SELLERS = 15;
54+
$THROTTLE_TIME_SELLERS = 60;
55+
//Anything in Inbound/Inventory/Outbound
56+
$THROTTLE_LIMIT_INVENTORY = 30;
57+
$THROTTLE_TIME_INVENTORY = 2;
58+
//Products
59+
$THROTTLE_LIMIT_PRODUCT = 20;
60+
$THROTTLE_TIME_PRODUCTLIST = 5;
61+
$THROTTLE_TIME_PRODUCTMATCH = 1;
62+
$THROTTLE_TIME_PRODUCTID = 4;
63+
$THROTTLE_TIME_PRODUCTPRICE = 2;
64+
//Requesting a Report
65+
$THROTTLE_LIMIT_REPORTREQUEST = 15;
66+
$THROTTLE_TIME_REPORTREQUEST = 60;
67+
//Fetching a Report Request List
68+
$THROTTLE_LIMIT_REPORTREQUESTLIST = 10;
69+
$THROTTLE_TIME_REPORTREQUESTLIST = 45;
70+
//Using a token with a report request
71+
$THROTTLE_LIMIT_REPORTTOKEN = 30;
72+
$THROTTLE_TIME_REPORTTOKEN = 2;
73+
//Fetching a Report List
74+
$THROTTLE_LIMIT_REPORTLIST = 10;
75+
$THROTTLE_TIME_REPORTLIST = 60;
76+
//Fetching a Report
77+
$THROTTLE_LIMIT_REPORT = 15;
78+
$THROTTLE_TIME_REPORT = 60;
79+
//Fetching a Report Request List
80+
$THROTTLE_LIMIT_REPORTSCHEDULE = 10;
81+
$THROTTLE_TIME_REPORTSCHEDULE = 45;
82+
//Submitting a Feed
83+
$THROTTLE_LIMIT_FEEDSUBMIT = 15;
84+
$THROTTLE_TIME_FEEDSUBMIT = 120;
85+
//Getting a Feed
86+
$THROTTLE_LIMIT_FEEDLIST = 10;
87+
$THROTTLE_TIME_FEEDLIST = 45;
88+
//Getting a Feed
89+
$THROTTLE_LIMIT_FEEDRESULT = 15;
90+
$THROTTLE_TIME_FEEDRESULT = 60;
91+
92+
?>

includes/classes/AmazonCore.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ abstract class AmazonCore{
104104
protected $mockFiles;
105105
protected $mockIndex = 0;
106106
protected $logpath;
107+
protected $env;
107108

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

134+
$this->env=__DIR__.'/../../environment.php';
133135
$this->options['SignatureVersion'] = 2;
134136
$this->options['SignatureMethod'] = 'HmacSHA256';
135137
}

includes/classes/AmazonFeed.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,16 @@ class AmazonFeed extends AmazonFeedsCore{
4343
*/
4444
public function __construct($s, $mock = false, $m = null, $config = null){
4545
parent::__construct($s, $mock, $m, $config);
46-
if (file_exists($this->config)){
47-
include($this->config);
48-
} else {
49-
throw new Exception('Config file does not exist!');
50-
}
46+
include($this->env);
5147

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

54-
if(isset($THROTTLE_LIMIT_FEEDSUBMIT))
55-
$this->throttleLimit = $THROTTLE_LIMIT_FEEDSUBMIT;
56-
if(isset($THROTTLE_TIME_FEEDSUBMIT))
57-
$this->throttleTime = $THROTTLE_TIME_FEEDSUBMIT;
50+
if(isset($THROTTLE_LIMIT_FEEDSUBMIT)) {
51+
$this->throttleLimit = $THROTTLE_LIMIT_FEEDSUBMIT;
52+
}
53+
if(isset($THROTTLE_TIME_FEEDSUBMIT)) {
54+
$this->throttleTime = $THROTTLE_TIME_FEEDSUBMIT;
55+
}
5856
$this->throttleGroup = 'SubmitFeed';
5957
}
6058

@@ -213,12 +211,9 @@ public function setPurge($s = 'true'){
213211
} else if ($s == 'false' || (!$s && is_bool($s))){
214212
$this->log("Purge mode deactivated.");
215213
$this->options['PurgeAndReplace'] = 'false';
216-
if (file_exists($this->config)){
217-
include($this->config);
218-
if(isset($THROTTLE_TIME_FEEDSUBMIT))
214+
include($this->env);
215+
if(isset($THROTTLE_TIME_FEEDSUBMIT)) {
219216
$this->throttleTime = $THROTTLE_TIME_FEEDSUBMIT;
220-
} else {
221-
return false;
222217
}
223218
} else {
224219
return false;

includes/classes/AmazonFeedList.php

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,14 @@ class AmazonFeedList extends AmazonFeedsCore implements Iterator{
4848
*/
4949
public function __construct($s, $mock = false, $m = null, $config = null){
5050
parent::__construct($s, $mock, $m, $config);
51-
if (file_exists($this->config)){
52-
include($this->config);
53-
} else {
54-
throw new Exception('Config file does not exist!');
55-
}
51+
include($this->env);
5652

57-
if(isset($THROTTLE_LIMIT_FEEDLIST))
58-
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
59-
if(isset($THROTTLE_TIME_FEEDLIST))
60-
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
53+
if(isset($THROTTLE_LIMIT_FEEDLIST)) {
54+
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
55+
}
56+
if(isset($THROTTLE_TIME_FEEDLIST)) {
57+
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
58+
}
6159
}
6260

6361
/**
@@ -308,13 +306,15 @@ public function fetchFeedSubmissions($r = true){
308306
* parameters will be removed.
309307
*/
310308
protected function prepareToken(){
311-
include($this->config);
309+
include($this->env);
312310
if ($this->tokenFlag && $this->tokenUseFlag){
313311
$this->options['Action'] = 'GetFeedSubmissionListByNextToken';
314-
if(isset($THROTTLE_LIMIT_REPORTTOKEN))
315-
$this->throttleLimit = $THROTTLE_LIMIT_REPORTTOKEN;
316-
if(isset($THROTTLE_TIME_REPORTTOKEN))
317-
$this->throttleTime = $THROTTLE_TIME_REPORTTOKEN;
312+
if(isset($THROTTLE_LIMIT_REPORTTOKEN)) {
313+
$this->throttleLimit = $THROTTLE_LIMIT_REPORTTOKEN;
314+
}
315+
if(isset($THROTTLE_TIME_REPORTTOKEN)) {
316+
$this->throttleTime = $THROTTLE_TIME_REPORTTOKEN;
317+
}
318318
$this->throttleGroup = 'GetFeedSubmissionListByNextToken';
319319
$this->resetFeedTypes();
320320
$this->resetFeedStatuses();
@@ -323,10 +323,12 @@ protected function prepareToken(){
323323
unset($this->options['MaxCount']);
324324
} else {
325325
$this->options['Action'] = 'GetFeedSubmissionList';
326-
if(isset($THROTTLE_LIMIT_FEEDLIST))
327-
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
328-
if(isset($THROTTLE_TIME_FEEDLIST))
329-
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
326+
if(isset($THROTTLE_LIMIT_FEEDLIST)) {
327+
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
328+
}
329+
if(isset($THROTTLE_TIME_FEEDLIST)) {
330+
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
331+
}
330332
$this->throttleGroup = 'GetFeedSubmissionList';
331333
unset($this->options['NextToken']);
332334
$this->feedList = array();
@@ -405,10 +407,12 @@ public function countFeeds(){
405407
*/
406408
protected function prepareCount(){
407409
$this->options['Action'] = 'GetFeedSubmissionCount';
408-
if(isset($THROTTLE_LIMIT_FEEDLIST))
409-
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
410-
if(isset($THROTTLE_TIME_FEEDLIST))
411-
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
410+
if(isset($THROTTLE_LIMIT_FEEDLIST)) {
411+
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
412+
}
413+
if(isset($THROTTLE_TIME_FEEDLIST)) {
414+
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
415+
}
412416
$this->throttleGroup = 'GetFeedSubmissionCount';
413417
$this->resetFeedIds();
414418
unset($this->options['MaxCount']);
@@ -457,12 +461,14 @@ public function cancelFeeds(){
457461
* feed statuses, max count, and token.
458462
*/
459463
protected function prepareCancel(){
460-
include($this->config);
464+
include($this->env);
461465
$this->options['Action'] = 'CancelFeedSubmissions';
462-
if(isset($THROTTLE_LIMIT_FEEDLIST))
463-
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
464-
if(isset($THROTTLE_TIME_FEEDLIST))
465-
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
466+
if(isset($THROTTLE_LIMIT_FEEDLIST)) {
467+
$this->throttleLimit = $THROTTLE_LIMIT_FEEDLIST;
468+
}
469+
if(isset($THROTTLE_TIME_FEEDLIST)) {
470+
$this->throttleTime = $THROTTLE_TIME_FEEDLIST;
471+
}
466472
$this->throttleGroup = 'CancelFeedSubmissions';
467473
unset($this->options['MaxCount']);
468474
unset($this->options['NextToken']);

includes/classes/AmazonFeedResult.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,20 @@ class AmazonFeedResult extends AmazonFeedsCore{
4444
*/
4545
public function __construct($s, $id = null, $mock = false, $m = null, $config = null){
4646
parent::__construct($s, $mock, $m, $config);
47-
if (file_exists($this->config)){
48-
include($this->config);
49-
} else {
50-
throw new Exception('Config file does not exist!');
51-
}
47+
include($this->env);
5248

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

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

59-
if(isset($THROTTLE_LIMIT_FEEDRESULT))
60-
$this->throttleLimit = $THROTTLE_LIMIT_FEEDRESULT;
61-
if(isset($THROTTLE_TIME_FEEDRESULT))
62-
$this->throttleTime = $THROTTLE_TIME_FEEDRESULT;
55+
if(isset($THROTTLE_LIMIT_FEEDRESULT)) {
56+
$this->throttleLimit = $THROTTLE_LIMIT_FEEDRESULT;
57+
}
58+
if(isset($THROTTLE_TIME_FEEDRESULT)) {
59+
$this->throttleTime = $THROTTLE_TIME_FEEDRESULT;
60+
}
6361
$this->throttleGroup = 'GetFeedSubmissionResult';
6462
}
6563

includes/classes/AmazonFeedsCore.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,12 @@ abstract class AmazonFeedsCore extends AmazonCore{
3838
*/
3939
public function __construct($s, $mock = false, $m = null, $config = null){
4040
parent::__construct($s, $mock, $m, $config);
41-
if (file_exists($this->config)){
42-
include($this->config);
43-
} else {
44-
throw new Exception('Config file does not exist!');
45-
}
41+
include($this->env);
4642

4743
$this->urlbranch = '';
48-
if(isset($AMAZON_VERSION_FEEDS))
49-
$this->options['Version'] = $AMAZON_VERSION_FEEDS;
44+
if(isset($AMAZON_VERSION_FEEDS)) {
45+
$this->options['Version'] = $AMAZON_VERSION_FEEDS;
46+
}
5047
}
5148
}
5249
?>

0 commit comments

Comments
 (0)