<?php
/**
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen
 * Do not edit the class manually.
 */

namespace SquareConnect\Model;

use \ArrayAccess;
/**
 * CatalogPricingRule Class Doc Comment
 *
 * @category Class
 * @package  SquareConnect
 * @author   Square Inc.
 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache License v2
 * @link     https://squareup.com/developers
 * Note: This endpoint is in beta.
 */
class CatalogPricingRule implements ArrayAccess
{
    /**
      * Array of property to type mappings. Used for (de)serialization 
      * @var string[]
      */
    static $swaggerTypes = array(
        'name' => 'string',
        'time_period_ids' => 'string[]',
        'discount_id' => 'string',
        'match_products_id' => 'string',
        'apply_products_id' => 'string',
        'exclude_products_id' => 'string',
        'valid_from_date' => 'string',
        'valid_from_local_time' => 'string',
        'valid_until_date' => 'string',
        'valid_until_local_time' => 'string',
        'exclude_strategy' => 'string'
    );
  
    /** 
      * Array of attributes where the key is the local name, and the value is the original name
      * @var string[] 
      */
    static $attributeMap = array(
        'name' => 'name',
        'time_period_ids' => 'time_period_ids',
        'discount_id' => 'discount_id',
        'match_products_id' => 'match_products_id',
        'apply_products_id' => 'apply_products_id',
        'exclude_products_id' => 'exclude_products_id',
        'valid_from_date' => 'valid_from_date',
        'valid_from_local_time' => 'valid_from_local_time',
        'valid_until_date' => 'valid_until_date',
        'valid_until_local_time' => 'valid_until_local_time',
        'exclude_strategy' => 'exclude_strategy'
    );
  
    /**
      * Array of attributes to setter functions (for deserialization of responses)
      * @var string[]
      */
    static $setters = array(
        'name' => 'setName',
        'time_period_ids' => 'setTimePeriodIds',
        'discount_id' => 'setDiscountId',
        'match_products_id' => 'setMatchProductsId',
        'apply_products_id' => 'setApplyProductsId',
        'exclude_products_id' => 'setExcludeProductsId',
        'valid_from_date' => 'setValidFromDate',
        'valid_from_local_time' => 'setValidFromLocalTime',
        'valid_until_date' => 'setValidUntilDate',
        'valid_until_local_time' => 'setValidUntilLocalTime',
        'exclude_strategy' => 'setExcludeStrategy'
    );
  
    /**
      * Array of attributes to getter functions (for serialization of requests)
      * @var string[]
      */
    static $getters = array(
        'name' => 'getName',
        'time_period_ids' => 'getTimePeriodIds',
        'discount_id' => 'getDiscountId',
        'match_products_id' => 'getMatchProductsId',
        'apply_products_id' => 'getApplyProductsId',
        'exclude_products_id' => 'getExcludeProductsId',
        'valid_from_date' => 'getValidFromDate',
        'valid_from_local_time' => 'getValidFromLocalTime',
        'valid_until_date' => 'getValidUntilDate',
        'valid_until_local_time' => 'getValidUntilLocalTime',
        'exclude_strategy' => 'getExcludeStrategy'
    );
  
    /**
      * $name User-defined name for the pricing rule. For example, \"Buy one get one free\" or \"10% off\".
      * @var string
      */
    protected $name;
    /**
      * $time_period_ids A list of unique IDs for the catalog time periods when this pricing rule is in effect. If left unset, the pricing rule is always in effect.
      * @var string[]
      */
    protected $time_period_ids;
    /**
      * $discount_id Unique ID for the `CatalogDiscount` to take off the price of all matched items.
      * @var string
      */
    protected $discount_id;
    /**
      * $match_products_id Unique ID for the `CatalogProductSet` that will be matched by this rule. A match rule matches within the entire cart. A match rule can match multiple times in the cart. If no `ProductSet` is present, the rule will match all products.
      * @var string
      */
    protected $match_products_id;
    /**
      * $apply_products_id __Deprecated__: Please use the `exclude_products_id` field to apply an exclude set instead. Exclude sets allow better control over quantity ranges and offer more flexibility for which matched items receive a discount.  `CatalogProductSet` to apply the pricing to. An apply rule matches within the subset of the cart that fits the match rules (the match set). An apply rule can only match once in the match set. If not supplied, the pricing will be applied to all products in the match set. Other products retain their base price, or a price generated by other rules.
      * @var string
      */
    protected $apply_products_id;
    /**
      * $exclude_products_id `CatalogProductSet` to exclude from the pricing rule. An exclude rule matches within the subset of the cart that fits the match rules (the match set). An exclude rule can only match once in the match set. If not supplied, the pricing will be applied to all products in the match set. Other products retain their base price, or a price generated by other rules.
      * @var string
      */
    protected $exclude_products_id;
    /**
      * $valid_from_date Represents the date the Pricing Rule is valid from. Represented in RFC3339 full-date format (YYYY-MM-DD).
      * @var string
      */
    protected $valid_from_date;
    /**
      * $valid_from_local_time Represents the local time the pricing rule should be valid from. Represented in RFC3339 partial-time format (HH:MM:SS). Partial seconds will be truncated.
      * @var string
      */
    protected $valid_from_local_time;
    /**
      * $valid_until_date Represents the date the Pricing Rule is valid until. Represented in RFC3339 full-date format (YYYY-MM-DD).
      * @var string
      */
    protected $valid_until_date;
    /**
      * $valid_until_local_time Represents the local time the pricing rule should be valid until. Represented in RFC3339 partial-time format (HH:MM:SS). Partial seconds will be truncated.
      * @var string
      */
    protected $valid_until_local_time;
    /**
      * $exclude_strategy If an `exclude_products_id` was given, controls which subset of matched products is excluded from any discounts.  Default value: `LEAST_EXPENSIVE` See [ExcludeStrategy](#type-excludestrategy) for possible values
      * @var string
      */
    protected $exclude_strategy;

    /**
     * Constructor
     * @param mixed[] $data Associated array of property value initializing the model
     */
    public function __construct(array $data = null)
    {
        if ($data != null) {
            if (isset($data["name"])) {
              $this->name = $data["name"];
            } else {
              $this->name = null;
            }
            if (isset($data["time_period_ids"])) {
              $this->time_period_ids = $data["time_period_ids"];
            } else {
              $this->time_period_ids = null;
            }
            if (isset($data["discount_id"])) {
              $this->discount_id = $data["discount_id"];
            } else {
              $this->discount_id = null;
            }
            if (isset($data["match_products_id"])) {
              $this->match_products_id = $data["match_products_id"];
            } else {
              $this->match_products_id = null;
            }
            if (isset($data["apply_products_id"])) {
              $this->apply_products_id = $data["apply_products_id"];
            } else {
              $this->apply_products_id = null;
            }
            if (isset($data["exclude_products_id"])) {
              $this->exclude_products_id = $data["exclude_products_id"];
            } else {
              $this->exclude_products_id = null;
            }
            if (isset($data["valid_from_date"])) {
              $this->valid_from_date = $data["valid_from_date"];
            } else {
              $this->valid_from_date = null;
            }
            if (isset($data["valid_from_local_time"])) {
              $this->valid_from_local_time = $data["valid_from_local_time"];
            } else {
              $this->valid_from_local_time = null;
            }
            if (isset($data["valid_until_date"])) {
              $this->valid_until_date = $data["valid_until_date"];
            } else {
              $this->valid_until_date = null;
            }
            if (isset($data["valid_until_local_time"])) {
              $this->valid_until_local_time = $data["valid_until_local_time"];
            } else {
              $this->valid_until_local_time = null;
            }
            if (isset($data["exclude_strategy"])) {
              $this->exclude_strategy = $data["exclude_strategy"];
            } else {
              $this->exclude_strategy = null;
            }
        }
    }
    /**
     * Gets name
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }
  
    /**
     * Sets name
     * @param string $name User-defined name for the pricing rule. For example, \"Buy one get one free\" or \"10% off\".
     * @return $this
     */
    public function setName($name)
    {
        $this->name = $name;
        return $this;
    }
    /**
     * Gets time_period_ids
     * @return string[]
     */
    public function getTimePeriodIds()
    {
        return $this->time_period_ids;
    }
  
    /**
     * Sets time_period_ids
     * @param string[] $time_period_ids A list of unique IDs for the catalog time periods when this pricing rule is in effect. If left unset, the pricing rule is always in effect.
     * @return $this
     */
    public function setTimePeriodIds($time_period_ids)
    {
        $this->time_period_ids = $time_period_ids;
        return $this;
    }
    /**
     * Gets discount_id
     * @return string
     */
    public function getDiscountId()
    {
        return $this->discount_id;
    }
  
    /**
     * Sets discount_id
     * @param string $discount_id Unique ID for the `CatalogDiscount` to take off the price of all matched items.
     * @return $this
     */
    public function setDiscountId($discount_id)
    {
        $this->discount_id = $discount_id;
        return $this;
    }
    /**
     * Gets match_products_id
     * @return string
     */
    public function getMatchProductsId()
    {
        return $this->match_products_id;
    }
  
    /**
     * Sets match_products_id
     * @param string $match_products_id Unique ID for the `CatalogProductSet` that will be matched by this rule. A match rule matches within the entire cart. A match rule can match multiple times in the cart. If no `ProductSet` is present, the rule will match all products.
     * @return $this
     */
    public function setMatchProductsId($match_products_id)
    {
        $this->match_products_id = $match_products_id;
        return $this;
    }
    /**
     * Gets apply_products_id
     * @return string
     */
    public function getApplyProductsId()
    {
        return $this->apply_products_id;
    }
  
    /**
     * Sets apply_products_id
     * @param string $apply_products_id __Deprecated__: Please use the `exclude_products_id` field to apply an exclude set instead. Exclude sets allow better control over quantity ranges and offer more flexibility for which matched items receive a discount.  `CatalogProductSet` to apply the pricing to. An apply rule matches within the subset of the cart that fits the match rules (the match set). An apply rule can only match once in the match set. If not supplied, the pricing will be applied to all products in the match set. Other products retain their base price, or a price generated by other rules.
     * @return $this
     */
    public function setApplyProductsId($apply_products_id)
    {
        $this->apply_products_id = $apply_products_id;
        return $this;
    }
    /**
     * Gets exclude_products_id
     * @return string
     */
    public function getExcludeProductsId()
    {
        return $this->exclude_products_id;
    }
  
    /**
     * Sets exclude_products_id
     * @param string $exclude_products_id `CatalogProductSet` to exclude from the pricing rule. An exclude rule matches within the subset of the cart that fits the match rules (the match set). An exclude rule can only match once in the match set. If not supplied, the pricing will be applied to all products in the match set. Other products retain their base price, or a price generated by other rules.
     * @return $this
     */
    public function setExcludeProductsId($exclude_products_id)
    {
        $this->exclude_products_id = $exclude_products_id;
        return $this;
    }
    /**
     * Gets valid_from_date
     * @return string
     */
    public function getValidFromDate()
    {
        return $this->valid_from_date;
    }
  
    /**
     * Sets valid_from_date
     * @param string $valid_from_date Represents the date the Pricing Rule is valid from. Represented in RFC3339 full-date format (YYYY-MM-DD).
     * @return $this
     */
    public function setValidFromDate($valid_from_date)
    {
        $this->valid_from_date = $valid_from_date;
        return $this;
    }
    /**
     * Gets valid_from_local_time
     * @return string
     */
    public function getValidFromLocalTime()
    {
        return $this->valid_from_local_time;
    }
  
    /**
     * Sets valid_from_local_time
     * @param string $valid_from_local_time Represents the local time the pricing rule should be valid from. Represented in RFC3339 partial-time format (HH:MM:SS). Partial seconds will be truncated.
     * @return $this
     */
    public function setValidFromLocalTime($valid_from_local_time)
    {
        $this->valid_from_local_time = $valid_from_local_time;
        return $this;
    }
    /**
     * Gets valid_until_date
     * @return string
     */
    public function getValidUntilDate()
    {
        return $this->valid_until_date;
    }
  
    /**
     * Sets valid_until_date
     * @param string $valid_until_date Represents the date the Pricing Rule is valid until. Represented in RFC3339 full-date format (YYYY-MM-DD).
     * @return $this
     */
    public function setValidUntilDate($valid_until_date)
    {
        $this->valid_until_date = $valid_until_date;
        return $this;
    }
    /**
     * Gets valid_until_local_time
     * @return string
     */
    public function getValidUntilLocalTime()
    {
        return $this->valid_until_local_time;
    }
  
    /**
     * Sets valid_until_local_time
     * @param string $valid_until_local_time Represents the local time the pricing rule should be valid until. Represented in RFC3339 partial-time format (HH:MM:SS). Partial seconds will be truncated.
     * @return $this
     */
    public function setValidUntilLocalTime($valid_until_local_time)
    {
        $this->valid_until_local_time = $valid_until_local_time;
        return $this;
    }
    /**
     * Gets exclude_strategy
     * @return string
     */
    public function getExcludeStrategy()
    {
        return $this->exclude_strategy;
    }
  
    /**
     * Sets exclude_strategy
     * @param string $exclude_strategy If an `exclude_products_id` was given, controls which subset of matched products is excluded from any discounts.  Default value: `LEAST_EXPENSIVE` See [ExcludeStrategy](#type-excludestrategy) for possible values
     * @return $this
     */
    public function setExcludeStrategy($exclude_strategy)
    {
        $this->exclude_strategy = $exclude_strategy;
        return $this;
    }
    /**
     * Returns true if offset exists. False otherwise.
     * @param  integer $offset Offset 
     * @return boolean
     */
    public function offsetExists($offset)
    {
        return isset($this->$offset);
    }
  
    /**
     * Gets offset.
     * @param  integer $offset Offset 
     * @return mixed 
     */
    public function offsetGet($offset)
    {
        return $this->$offset;
    }
  
    /**
     * Sets value based on offset.
     * @param  integer $offset Offset 
     * @param  mixed   $value  Value to be set
     * @return void
     */
    public function offsetSet($offset, $value)
    {
        $this->$offset = $value;
    }
  
    /**
     * Unsets offset.
     * @param  integer $offset Offset 
     * @return void
     */
    public function offsetUnset($offset)
    {
        unset($this->$offset);
    }
  
    /**
     * Gets the string presentation of the object
     * @return string
     */
    public function __toString()
    {
        if (defined('JSON_PRETTY_PRINT')) {
            return json_encode(\SquareConnect\ObjectSerializer::sanitizeForSerialization($this), JSON_PRETTY_PRINT);
        } else {
            return json_encode(\SquareConnect\ObjectSerializer::sanitizeForSerialization($this));
        }
    }
}
