|
| 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