Skip to content

Commit

Permalink
Merge pull request #84 from Peardian/newapi
Browse files Browse the repository at this point in the history
Recommendations and Subscriptions
  • Loading branch information
Peardian authored Jun 9, 2016
2 parents 48005a4 + f1578a9 commit ec1ceaa
Show file tree
Hide file tree
Showing 24 changed files with 3,729 additions and 0 deletions.
8 changes: 8 additions & 0 deletions environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
$AMAZON_VERSION_ORDERS = '2013-09-01';
$AMAZON_VERSION_OUTBOUND = '2010-10-01';
$AMAZON_VERSION_PRODUCTS = '2011-10-01';
$AMAZON_VERSION_RECOMMEND = '2013-04-01';
$AMAZON_VERSION_REPORTS = '2009-01-01';
$AMAZON_VERSION_SELLERS = '2011-07-01';
$AMAZON_VERSION_SUBSCRIBE = '2013-07-01';

//Amazon Throttle Values in seconds
//Fetching Orders
Expand Down Expand Up @@ -92,5 +94,11 @@
//Merchant Fulfillments
$THROTTLE_LIMIT_MERCHANT = 10;
$THROTTLE_TIME_MERCHANT = 1;
//Subscriptions
$THROTTLE_LIMIT_SUBSCRIBE = 25;
$THROTTLE_TIME_SUBSCRIBE = 1;
//Recommendations
$THROTTLE_LIMIT_RECOMMEND = 8;
$THROTTLE_TIME_RECOMMEND = 2;

?>
86 changes: 86 additions & 0 deletions includes/classes/AmazonRecommendationCore.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?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.
*/

/**
* Core class for Amazon Recommendations API.
*
* This is the core class for all objects in the Amazon Recommendations section.
* It contains a method that all Amazon Recommendations Core objects use.
*/
abstract class AmazonRecommendationCore extends AmazonCore{

/**
* AmazonRecommendationCore constructor sets up key information used in all Amazon Recommendations Core requests
*
* This constructor is called when initializing all objects in the Amazon Recommendations Core.
* The parameters are passed by the child objects' constructors, which are
* in turn passed to the AmazonCore constructor. See it for more information
* on these parameters and common methods.
* @param string $s [optional] <p>Name for the store you want to use.
* This parameter is optional if only one store is defined in the config file.</p>
* @param boolean $mock [optional] <p>This is a flag for enabling Mock Mode.
* This defaults to <b>FALSE</b>.</p>
* @param array|string $m [optional] <p>The files (or file) to use in Mock Mode.</p>
* @param string $config [optional] <p>An alternate config file to set. Used for testing.</p>
*/
public function __construct($s = null, $mock = false, $m = null, $config = null){
parent::__construct($s, $mock, $m, $config);
include($this->env);
if (file_exists($this->config)){
include($this->config);
} else {
throw new Exception('Config file does not exist!');
}

if (isset($AMAZON_VERSION_RECOMMEND)){
$this->urlbranch = 'Recommendations/' . $AMAZON_VERSION_RECOMMEND;
$this->options['Version'] = $AMAZON_VERSION_RECOMMEND;
}

if(isset($THROTTLE_LIMIT_RECOMMEND)) {
$this->throttleLimit = $THROTTLE_LIMIT_RECOMMEND;
}
if(isset($THROTTLE_TIME_RECOMMEND)) {
$this->throttleTime = $THROTTLE_TIME_RECOMMEND;
}

if (isset($store[$this->storeName]['marketplaceId'])){
$this->setMarketplace($store[$this->storeName]['marketplaceId']);
} else {
$this->log("Marketplace ID is missing", 'Urgent');
}
}

/**
* Sets the marketplace associated with the recommendations. (Optional)
*
* The current store's configured marketplace is used by default.
* @param string $m <p>Marketplace ID</p>
* @return boolean <b>FALSE</b> if improper input
*/
public function setMarketplace($m){
if (is_string($m)){
$this->options['MarketplaceId'] = $m;
} else {
return false;
}
}

}

Loading

0 comments on commit ec1ceaa

Please sign in to comment.