Skip to content

Commit ec1ceaa

Browse files
authored
Merge pull request CPIGroup#84 from Peardian/newapi
Recommendations and Subscriptions
2 parents 48005a4 + f1578a9 commit ec1ceaa

24 files changed

+3729
-0
lines changed

environment.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434
$AMAZON_VERSION_ORDERS = '2013-09-01';
3535
$AMAZON_VERSION_OUTBOUND = '2010-10-01';
3636
$AMAZON_VERSION_PRODUCTS = '2011-10-01';
37+
$AMAZON_VERSION_RECOMMEND = '2013-04-01';
3738
$AMAZON_VERSION_REPORTS = '2009-01-01';
3839
$AMAZON_VERSION_SELLERS = '2011-07-01';
40+
$AMAZON_VERSION_SUBSCRIBE = '2013-07-01';
3941

4042
//Amazon Throttle Values in seconds
4143
//Fetching Orders
@@ -92,5 +94,11 @@
9294
//Merchant Fulfillments
9395
$THROTTLE_LIMIT_MERCHANT = 10;
9496
$THROTTLE_TIME_MERCHANT = 1;
97+
//Subscriptions
98+
$THROTTLE_LIMIT_SUBSCRIBE = 25;
99+
$THROTTLE_TIME_SUBSCRIBE = 1;
100+
//Recommendations
101+
$THROTTLE_LIMIT_RECOMMEND = 8;
102+
$THROTTLE_TIME_RECOMMEND = 2;
95103

96104
?>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?php
2+
3+
/**
4+
* Copyright 2013 CPI Group, LLC
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
*
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
20+
/**
21+
* Core class for Amazon Recommendations API.
22+
*
23+
* This is the core class for all objects in the Amazon Recommendations section.
24+
* It contains a method that all Amazon Recommendations Core objects use.
25+
*/
26+
abstract class AmazonRecommendationCore extends AmazonCore{
27+
28+
/**
29+
* AmazonRecommendationCore constructor sets up key information used in all Amazon Recommendations Core requests
30+
*
31+
* This constructor is called when initializing all objects in the Amazon Recommendations Core.
32+
* The parameters are passed by the child objects' constructors, which are
33+
* in turn passed to the AmazonCore constructor. See it for more information
34+
* on these parameters and common methods.
35+
* @param string $s [optional] <p>Name for the store you want to use.
36+
* This parameter is optional if only one store is defined in the config file.</p>
37+
* @param boolean $mock [optional] <p>This is a flag for enabling Mock Mode.
38+
* This defaults to <b>FALSE</b>.</p>
39+
* @param array|string $m [optional] <p>The files (or file) to use in Mock Mode.</p>
40+
* @param string $config [optional] <p>An alternate config file to set. Used for testing.</p>
41+
*/
42+
public function __construct($s = null, $mock = false, $m = null, $config = null){
43+
parent::__construct($s, $mock, $m, $config);
44+
include($this->env);
45+
if (file_exists($this->config)){
46+
include($this->config);
47+
} else {
48+
throw new Exception('Config file does not exist!');
49+
}
50+
51+
if (isset($AMAZON_VERSION_RECOMMEND)){
52+
$this->urlbranch = 'Recommendations/' . $AMAZON_VERSION_RECOMMEND;
53+
$this->options['Version'] = $AMAZON_VERSION_RECOMMEND;
54+
}
55+
56+
if(isset($THROTTLE_LIMIT_RECOMMEND)) {
57+
$this->throttleLimit = $THROTTLE_LIMIT_RECOMMEND;
58+
}
59+
if(isset($THROTTLE_TIME_RECOMMEND)) {
60+
$this->throttleTime = $THROTTLE_TIME_RECOMMEND;
61+
}
62+
63+
if (isset($store[$this->storeName]['marketplaceId'])){
64+
$this->setMarketplace($store[$this->storeName]['marketplaceId']);
65+
} else {
66+
$this->log("Marketplace ID is missing", 'Urgent');
67+
}
68+
}
69+
70+
/**
71+
* Sets the marketplace associated with the recommendations. (Optional)
72+
*
73+
* The current store's configured marketplace is used by default.
74+
* @param string $m <p>Marketplace ID</p>
75+
* @return boolean <b>FALSE</b> if improper input
76+
*/
77+
public function setMarketplace($m){
78+
if (is_string($m)){
79+
$this->options['MarketplaceId'] = $m;
80+
} else {
81+
return false;
82+
}
83+
}
84+
85+
}
86+

0 commit comments

Comments
 (0)