=begin
#Pinterest REST API

#Pinterest's REST API

The version of the OpenAPI document: 5.3.0
Contact: pinterest-api@pinterest.com
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 5.4.0

=end

require 'date'
require 'time'

module PinterestSdkClient
  class ItemAttributes
    # Allows advertisers to specify a separate URL that can be used to track traffic coming from Pinterest shopping ads. Must send full URL including tracking—do not send tracking parameters only. At this time we do not support impression tracking. Must begin with http:// or https://.
    attr_accessor :ad_link

    # The links to additional images for your product. Up to five additional images can be used to show a product from different angles or to show different stages. Separate each additional image with a comma. We recommend enclosing the whole string with quotes. Must begin with http:// or https://
    attr_accessor :additional_image_link

    # Set this attribute to TRUE if you're submitting items that are considered “adult”. These will not be shown on Pinterest.
    attr_accessor :adult

    # The age group to apply a demographic range to the product. Must be one of the following values: ‘newborn’, ‘infant’, ‘toddler’, ‘kids’, ‘adult’.
    attr_accessor :age_group

    # The availability of the product. Must be one of the following values: ‘in stock’, ‘out of stock’, ‘preorder’.
    attr_accessor :availability

    # Average reviews for the item. Can be a number from 1-5.
    attr_accessor :average_review_rating

    # The brand of the product.
    attr_accessor :brand

    # The primary color of the product.
    attr_accessor :color

    # The condition of the product. Must be one of the following values: ‘new’, ‘used’, ‘refurbished’.
    attr_accessor :condition

    # Custom grouping of products.
    attr_accessor :custom_label_0

    # Custom grouping of products.
    attr_accessor :custom_label_1

    # Custom grouping of products.
    attr_accessor :custom_label_2

    # Custom grouping of products.
    attr_accessor :custom_label_3

    # Custom grouping of products.
    attr_accessor :custom_label_4

    # The description of the product.
    attr_accessor :description

    # The item is free to ship.
    attr_accessor :free_shipping_label

    # The minimum order purchase necessary for the customer to get free shipping. Only relevant if free shipping is offered.
    attr_accessor :free_shipping_limit

    # The gender associated with the product. Must be one of the following values: ‘male’, ‘female’, ‘unisex’.
    attr_accessor :gender

    # The categorization of the product based on the standardized Google Product Taxonomy. This is a set taxonomy. Both the text values and numeric codes are accepted.
    attr_accessor :google_product_category

    # The unique universal product identifier.
    attr_accessor :gtin

    # The user-created unique ID that represents the product. Only Unicode characters are accepted.
    attr_accessor :id

    # The link to the main product images. Images should be at least 75x75 pixels to avoid errors. Use the additional_image_link field to add more images of your product. The URL of your image_link must be accessible by the Pinterest user-agent, and send the accurate images. Please make sure there are no template or placeholder images at the link. Must start with http:// or https://
    attr_accessor :image_link

    # The parent ID of the product.
    attr_accessor :item_group_id

    # The millisecond timestamp when the item was lastly modified by the merchant.
    attr_accessor :last_updated_time

    # The landing page for the product.
    attr_accessor :link

    # The material used to make the product.
    attr_accessor :material

    # The minimum advertised price of the product. It supports the following formats, \"19.99 USD\", \"19.99USD\" and \"19.99\". If the currency is not included, we default to US dollars.
    attr_accessor :min_ad_price

    # The mobile-optimized version of your landing page. Must begin with http:// or https://.
    attr_accessor :mobile_link

    # Manufacturer Part Number are alpha-numeric codes created by the manufacturer of a product to uniquely identify it among all products from the same manufacturer.
    attr_accessor :mpn

    # The number of ratings for the item.
    attr_accessor :number_of_ratings

    # The number of reviews available for the item.
    attr_accessor :number_of_reviews

    # The description of the pattern used for the product.
    attr_accessor :pattern

    # The price of the product. It supports the following formats, \"24.99 USD\", \"24.99USD\" and \"24.99\". If the currency is not included, we default to US dollars.
    attr_accessor :price

    # The categorization of your product based on your custom product taxonomy. Subcategories must be sent separated by “ > “. The > must be wrapped by spaces. We do not recognize any other delimiters such as comma or pipe.
    attr_accessor :product_type

    # The discounted price of the product. The sale_price must be lower than the price. It supports the following formats, \"14.99 USD\", \"14.99USD\" and \"14.99\". If the currency is not included, we default to US dollars.
    attr_accessor :sale_price

    # Shipping consists of one group of up to four elements, country, region, service (all optional) and price (required). All colons, even for blank values, are required.
    attr_accessor :shipping

    # The height of the package needed to ship the product. Ensure there is a space between the numeric string and the metric.
    attr_accessor :shipping_height

    # The weight of the product. Ensure there is a space between the numeric string and the metric.
    attr_accessor :shipping_weight

    # The width of the package needed to ship the product. Ensure there is a space between the numeric string and the metric.
    attr_accessor :shipping_width

    # The size of the product.
    attr_accessor :size

    # Indicates the country’s sizing system in which you are submitting your product.
    attr_accessor :size_system

    # Additional description for the size. Must be one of the following values: ‘regular’, ‘petite’, ‘plus’, ‘big_and_tall’, ‘maternity’.
    attr_accessor :size_type

    # Tax consists of one group of up to four elements, country, region, rate (all required) and tax_ship (optional). All colons, even for blank values, are required.
    attr_accessor :tax

    # The name of the product.
    attr_accessor :title

    # Attribute mapping from ruby-style variable name to JSON key.
    def self.attribute_map
      {
        :'ad_link' => :'ad_link',
        :'additional_image_link' => :'additional_image_link',
        :'adult' => :'adult',
        :'age_group' => :'age_group',
        :'availability' => :'availability',
        :'average_review_rating' => :'average_review_rating',
        :'brand' => :'brand',
        :'color' => :'color',
        :'condition' => :'condition',
        :'custom_label_0' => :'custom_label_0',
        :'custom_label_1' => :'custom_label_1',
        :'custom_label_2' => :'custom_label_2',
        :'custom_label_3' => :'custom_label_3',
        :'custom_label_4' => :'custom_label_4',
        :'description' => :'description',
        :'free_shipping_label' => :'free_shipping_label',
        :'free_shipping_limit' => :'free_shipping_limit',
        :'gender' => :'gender',
        :'google_product_category' => :'google_product_category',
        :'gtin' => :'gtin',
        :'id' => :'id',
        :'image_link' => :'image_link',
        :'item_group_id' => :'item_group_id',
        :'last_updated_time' => :'last_updated_time',
        :'link' => :'link',
        :'material' => :'material',
        :'min_ad_price' => :'min_ad_price',
        :'mobile_link' => :'mobile_link',
        :'mpn' => :'mpn',
        :'number_of_ratings' => :'number_of_ratings',
        :'number_of_reviews' => :'number_of_reviews',
        :'pattern' => :'pattern',
        :'price' => :'price',
        :'product_type' => :'product_type',
        :'sale_price' => :'sale_price',
        :'shipping' => :'shipping',
        :'shipping_height' => :'shipping_height',
        :'shipping_weight' => :'shipping_weight',
        :'shipping_width' => :'shipping_width',
        :'size' => :'size',
        :'size_system' => :'size_system',
        :'size_type' => :'size_type',
        :'tax' => :'tax',
        :'title' => :'title'
      }
    end

    # Returns all the JSON keys this model knows about
    def self.acceptable_attributes
      attribute_map.values
    end

    # Attribute type mapping.
    def self.openapi_types
      {
        :'ad_link' => :'String',
        :'additional_image_link' => :'Array<String>',
        :'adult' => :'Boolean',
        :'age_group' => :'String',
        :'availability' => :'String',
        :'average_review_rating' => :'Float',
        :'brand' => :'String',
        :'color' => :'String',
        :'condition' => :'String',
        :'custom_label_0' => :'String',
        :'custom_label_1' => :'String',
        :'custom_label_2' => :'String',
        :'custom_label_3' => :'String',
        :'custom_label_4' => :'String',
        :'description' => :'String',
        :'free_shipping_label' => :'Boolean',
        :'free_shipping_limit' => :'String',
        :'gender' => :'String',
        :'google_product_category' => :'String',
        :'gtin' => :'Integer',
        :'id' => :'String',
        :'image_link' => :'Array<String>',
        :'item_group_id' => :'String',
        :'last_updated_time' => :'Integer',
        :'link' => :'String',
        :'material' => :'String',
        :'min_ad_price' => :'String',
        :'mobile_link' => :'String',
        :'mpn' => :'String',
        :'number_of_ratings' => :'Integer',
        :'number_of_reviews' => :'Integer',
        :'pattern' => :'String',
        :'price' => :'String',
        :'product_type' => :'String',
        :'sale_price' => :'String',
        :'shipping' => :'String',
        :'shipping_height' => :'String',
        :'shipping_weight' => :'String',
        :'shipping_width' => :'String',
        :'size' => :'String',
        :'size_system' => :'String',
        :'size_type' => :'String',
        :'tax' => :'String',
        :'title' => :'String'
      }
    end

    # List of attributes with nullable: true
    def self.openapi_nullable
      Set.new([
      ])
    end

    # Initializes the object
    # @param [Hash] attributes Model attributes in the form of hash
    def initialize(attributes = {})
      if (!attributes.is_a?(Hash))
        fail ArgumentError, "The input argument (attributes) must be a hash in `PinterestSdkClient::ItemAttributes` initialize method"
      end

      # check to see if the attribute exists and convert string to symbol for hash key
      attributes = attributes.each_with_object({}) { |(k, v), h|
        if (!self.class.attribute_map.key?(k.to_sym))
          fail ArgumentError, "`#{k}` is not a valid attribute in `PinterestSdkClient::ItemAttributes`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
        end
        h[k.to_sym] = v
      }

      if attributes.key?(:'ad_link')
        self.ad_link = attributes[:'ad_link']
      end

      if attributes.key?(:'additional_image_link')
        if (value = attributes[:'additional_image_link']).is_a?(Array)
          self.additional_image_link = value
        end
      end

      if attributes.key?(:'adult')
        self.adult = attributes[:'adult']
      end

      if attributes.key?(:'age_group')
        self.age_group = attributes[:'age_group']
      end

      if attributes.key?(:'availability')
        self.availability = attributes[:'availability']
      end

      if attributes.key?(:'average_review_rating')
        self.average_review_rating = attributes[:'average_review_rating']
      end

      if attributes.key?(:'brand')
        self.brand = attributes[:'brand']
      end

      if attributes.key?(:'color')
        self.color = attributes[:'color']
      end

      if attributes.key?(:'condition')
        self.condition = attributes[:'condition']
      end

      if attributes.key?(:'custom_label_0')
        self.custom_label_0 = attributes[:'custom_label_0']
      end

      if attributes.key?(:'custom_label_1')
        self.custom_label_1 = attributes[:'custom_label_1']
      end

      if attributes.key?(:'custom_label_2')
        self.custom_label_2 = attributes[:'custom_label_2']
      end

      if attributes.key?(:'custom_label_3')
        self.custom_label_3 = attributes[:'custom_label_3']
      end

      if attributes.key?(:'custom_label_4')
        self.custom_label_4 = attributes[:'custom_label_4']
      end

      if attributes.key?(:'description')
        self.description = attributes[:'description']
      end

      if attributes.key?(:'free_shipping_label')
        self.free_shipping_label = attributes[:'free_shipping_label']
      end

      if attributes.key?(:'free_shipping_limit')
        self.free_shipping_limit = attributes[:'free_shipping_limit']
      end

      if attributes.key?(:'gender')
        self.gender = attributes[:'gender']
      end

      if attributes.key?(:'google_product_category')
        self.google_product_category = attributes[:'google_product_category']
      end

      if attributes.key?(:'gtin')
        self.gtin = attributes[:'gtin']
      end

      if attributes.key?(:'id')
        self.id = attributes[:'id']
      end

      if attributes.key?(:'image_link')
        if (value = attributes[:'image_link']).is_a?(Array)
          self.image_link = value
        end
      end

      if attributes.key?(:'item_group_id')
        self.item_group_id = attributes[:'item_group_id']
      end

      if attributes.key?(:'last_updated_time')
        self.last_updated_time = attributes[:'last_updated_time']
      end

      if attributes.key?(:'link')
        self.link = attributes[:'link']
      end

      if attributes.key?(:'material')
        self.material = attributes[:'material']
      end

      if attributes.key?(:'min_ad_price')
        self.min_ad_price = attributes[:'min_ad_price']
      end

      if attributes.key?(:'mobile_link')
        self.mobile_link = attributes[:'mobile_link']
      end

      if attributes.key?(:'mpn')
        self.mpn = attributes[:'mpn']
      end

      if attributes.key?(:'number_of_ratings')
        self.number_of_ratings = attributes[:'number_of_ratings']
      end

      if attributes.key?(:'number_of_reviews')
        self.number_of_reviews = attributes[:'number_of_reviews']
      end

      if attributes.key?(:'pattern')
        self.pattern = attributes[:'pattern']
      end

      if attributes.key?(:'price')
        self.price = attributes[:'price']
      end

      if attributes.key?(:'product_type')
        self.product_type = attributes[:'product_type']
      end

      if attributes.key?(:'sale_price')
        self.sale_price = attributes[:'sale_price']
      end

      if attributes.key?(:'shipping')
        self.shipping = attributes[:'shipping']
      end

      if attributes.key?(:'shipping_height')
        self.shipping_height = attributes[:'shipping_height']
      end

      if attributes.key?(:'shipping_weight')
        self.shipping_weight = attributes[:'shipping_weight']
      end

      if attributes.key?(:'shipping_width')
        self.shipping_width = attributes[:'shipping_width']
      end

      if attributes.key?(:'size')
        self.size = attributes[:'size']
      end

      if attributes.key?(:'size_system')
        self.size_system = attributes[:'size_system']
      end

      if attributes.key?(:'size_type')
        self.size_type = attributes[:'size_type']
      end

      if attributes.key?(:'tax')
        self.tax = attributes[:'tax']
      end

      if attributes.key?(:'title')
        self.title = attributes[:'title']
      end
    end

    # Show invalid properties with the reasons. Usually used together with valid?
    # @return Array for valid properties with the reasons
    def list_invalid_properties
      invalid_properties = Array.new
      if !@custom_label_0.nil? && @custom_label_0.to_s.length > 1000
        invalid_properties.push('invalid value for "custom_label_0", the character length must be smaller than or equal to 1000.')
      end

      if !@custom_label_1.nil? && @custom_label_1.to_s.length > 1000
        invalid_properties.push('invalid value for "custom_label_1", the character length must be smaller than or equal to 1000.')
      end

      if !@custom_label_2.nil? && @custom_label_2.to_s.length > 1000
        invalid_properties.push('invalid value for "custom_label_2", the character length must be smaller than or equal to 1000.')
      end

      if !@custom_label_3.nil? && @custom_label_3.to_s.length > 1000
        invalid_properties.push('invalid value for "custom_label_3", the character length must be smaller than or equal to 1000.')
      end

      if !@custom_label_4.nil? && @custom_label_4.to_s.length > 1000
        invalid_properties.push('invalid value for "custom_label_4", the character length must be smaller than or equal to 1000.')
      end

      if !@description.nil? && @description.to_s.length > 10000
        invalid_properties.push('invalid value for "description", the character length must be smaller than or equal to 10000.')
      end

      if !@id.nil? && @id.to_s.length > 127
        invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 127.')
      end

      if !@image_link.nil? && @image_link.length < 1
        invalid_properties.push('invalid value for "image_link", number of items must be greater than or equal to 1.')
      end

      if !@item_group_id.nil? && @item_group_id.to_s.length > 127
        invalid_properties.push('invalid value for "item_group_id", the character length must be smaller than or equal to 127.')
      end

      if !@link.nil? && @link.to_s.length > 511
        invalid_properties.push('invalid value for "link", the character length must be smaller than or equal to 511.')
      end

      if !@product_type.nil? && @product_type.to_s.length > 1000
        invalid_properties.push('invalid value for "product_type", the character length must be smaller than or equal to 1000.')
      end

      if !@title.nil? && @title.to_s.length > 500
        invalid_properties.push('invalid value for "title", the character length must be smaller than or equal to 500.')
      end

      invalid_properties
    end

    # Check to see if the all the properties in the model are valid
    # @return true if the model is valid
    def valid?
      return false if !@custom_label_0.nil? && @custom_label_0.to_s.length > 1000
      return false if !@custom_label_1.nil? && @custom_label_1.to_s.length > 1000
      return false if !@custom_label_2.nil? && @custom_label_2.to_s.length > 1000
      return false if !@custom_label_3.nil? && @custom_label_3.to_s.length > 1000
      return false if !@custom_label_4.nil? && @custom_label_4.to_s.length > 1000
      return false if !@description.nil? && @description.to_s.length > 10000
      return false if !@id.nil? && @id.to_s.length > 127
      return false if !@image_link.nil? && @image_link.length < 1
      return false if !@item_group_id.nil? && @item_group_id.to_s.length > 127
      return false if !@link.nil? && @link.to_s.length > 511
      return false if !@product_type.nil? && @product_type.to_s.length > 1000
      return false if !@title.nil? && @title.to_s.length > 500
      true
    end

    # Custom attribute writer method with validation
    # @param [Object] custom_label_0 Value to be assigned
    def custom_label_0=(custom_label_0)
      if !custom_label_0.nil? && custom_label_0.to_s.length > 1000
        fail ArgumentError, 'invalid value for "custom_label_0", the character length must be smaller than or equal to 1000.'
      end

      @custom_label_0 = custom_label_0
    end

    # Custom attribute writer method with validation
    # @param [Object] custom_label_1 Value to be assigned
    def custom_label_1=(custom_label_1)
      if !custom_label_1.nil? && custom_label_1.to_s.length > 1000
        fail ArgumentError, 'invalid value for "custom_label_1", the character length must be smaller than or equal to 1000.'
      end

      @custom_label_1 = custom_label_1
    end

    # Custom attribute writer method with validation
    # @param [Object] custom_label_2 Value to be assigned
    def custom_label_2=(custom_label_2)
      if !custom_label_2.nil? && custom_label_2.to_s.length > 1000
        fail ArgumentError, 'invalid value for "custom_label_2", the character length must be smaller than or equal to 1000.'
      end

      @custom_label_2 = custom_label_2
    end

    # Custom attribute writer method with validation
    # @param [Object] custom_label_3 Value to be assigned
    def custom_label_3=(custom_label_3)
      if !custom_label_3.nil? && custom_label_3.to_s.length > 1000
        fail ArgumentError, 'invalid value for "custom_label_3", the character length must be smaller than or equal to 1000.'
      end

      @custom_label_3 = custom_label_3
    end

    # Custom attribute writer method with validation
    # @param [Object] custom_label_4 Value to be assigned
    def custom_label_4=(custom_label_4)
      if !custom_label_4.nil? && custom_label_4.to_s.length > 1000
        fail ArgumentError, 'invalid value for "custom_label_4", the character length must be smaller than or equal to 1000.'
      end

      @custom_label_4 = custom_label_4
    end

    # Custom attribute writer method with validation
    # @param [Object] description Value to be assigned
    def description=(description)
      if !description.nil? && description.to_s.length > 10000
        fail ArgumentError, 'invalid value for "description", the character length must be smaller than or equal to 10000.'
      end

      @description = description
    end

    # Custom attribute writer method with validation
    # @param [Object] id Value to be assigned
    def id=(id)
      if !id.nil? && id.to_s.length > 127
        fail ArgumentError, 'invalid value for "id", the character length must be smaller than or equal to 127.'
      end

      @id = id
    end

    # Custom attribute writer method with validation
    # @param [Object] image_link Value to be assigned
    def image_link=(image_link)
      if !image_link.nil? && image_link.length < 1
        fail ArgumentError, 'invalid value for "image_link", number of items must be greater than or equal to 1.'
      end

      @image_link = image_link
    end

    # Custom attribute writer method with validation
    # @param [Object] item_group_id Value to be assigned
    def item_group_id=(item_group_id)
      if !item_group_id.nil? && item_group_id.to_s.length > 127
        fail ArgumentError, 'invalid value for "item_group_id", the character length must be smaller than or equal to 127.'
      end

      @item_group_id = item_group_id
    end

    # Custom attribute writer method with validation
    # @param [Object] link Value to be assigned
    def link=(link)
      if !link.nil? && link.to_s.length > 511
        fail ArgumentError, 'invalid value for "link", the character length must be smaller than or equal to 511.'
      end

      @link = link
    end

    # Custom attribute writer method with validation
    # @param [Object] product_type Value to be assigned
    def product_type=(product_type)
      if !product_type.nil? && product_type.to_s.length > 1000
        fail ArgumentError, 'invalid value for "product_type", the character length must be smaller than or equal to 1000.'
      end

      @product_type = product_type
    end

    # Custom attribute writer method with validation
    # @param [Object] title Value to be assigned
    def title=(title)
      if !title.nil? && title.to_s.length > 500
        fail ArgumentError, 'invalid value for "title", the character length must be smaller than or equal to 500.'
      end

      @title = title
    end

    # Checks equality by comparing each attribute.
    # @param [Object] Object to be compared
    def ==(o)
      return true if self.equal?(o)
      self.class == o.class &&
          ad_link == o.ad_link &&
          additional_image_link == o.additional_image_link &&
          adult == o.adult &&
          age_group == o.age_group &&
          availability == o.availability &&
          average_review_rating == o.average_review_rating &&
          brand == o.brand &&
          color == o.color &&
          condition == o.condition &&
          custom_label_0 == o.custom_label_0 &&
          custom_label_1 == o.custom_label_1 &&
          custom_label_2 == o.custom_label_2 &&
          custom_label_3 == o.custom_label_3 &&
          custom_label_4 == o.custom_label_4 &&
          description == o.description &&
          free_shipping_label == o.free_shipping_label &&
          free_shipping_limit == o.free_shipping_limit &&
          gender == o.gender &&
          google_product_category == o.google_product_category &&
          gtin == o.gtin &&
          id == o.id &&
          image_link == o.image_link &&
          item_group_id == o.item_group_id &&
          last_updated_time == o.last_updated_time &&
          link == o.link &&
          material == o.material &&
          min_ad_price == o.min_ad_price &&
          mobile_link == o.mobile_link &&
          mpn == o.mpn &&
          number_of_ratings == o.number_of_ratings &&
          number_of_reviews == o.number_of_reviews &&
          pattern == o.pattern &&
          price == o.price &&
          product_type == o.product_type &&
          sale_price == o.sale_price &&
          shipping == o.shipping &&
          shipping_height == o.shipping_height &&
          shipping_weight == o.shipping_weight &&
          shipping_width == o.shipping_width &&
          size == o.size &&
          size_system == o.size_system &&
          size_type == o.size_type &&
          tax == o.tax &&
          title == o.title
    end

    # @see the `==` method
    # @param [Object] Object to be compared
    def eql?(o)
      self == o
    end

    # Calculates hash code according to all attributes.
    # @return [Integer] Hash code
    def hash
      [ad_link, additional_image_link, adult, age_group, availability, average_review_rating, brand, color, condition, custom_label_0, custom_label_1, custom_label_2, custom_label_3, custom_label_4, description, free_shipping_label, free_shipping_limit, gender, google_product_category, gtin, id, image_link, item_group_id, last_updated_time, link, material, min_ad_price, mobile_link, mpn, number_of_ratings, number_of_reviews, pattern, price, product_type, sale_price, shipping, shipping_height, shipping_weight, shipping_width, size, size_system, size_type, tax, title].hash
    end

    # Builds the object from hash
    # @param [Hash] attributes Model attributes in the form of hash
    # @return [Object] Returns the model itself
    def self.build_from_hash(attributes)
      new.build_from_hash(attributes)
    end

    # Builds the object from hash
    # @param [Hash] attributes Model attributes in the form of hash
    # @return [Object] Returns the model itself
    def build_from_hash(attributes)
      return nil unless attributes.is_a?(Hash)
      self.class.openapi_types.each_pair do |key, type|
        if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
          self.send("#{key}=", nil)
        elsif type =~ /\AArray<(.*)>/i
          # check to ensure the input is an array given that the attribute
          # is documented as an array but the input is not
          if attributes[self.class.attribute_map[key]].is_a?(Array)
            self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
          end
        elsif !attributes[self.class.attribute_map[key]].nil?
          self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
        end
      end

      self
    end

    # Deserializes the data based on type
    # @param string type Data type
    # @param string value Value to be deserialized
    # @return [Object] Deserialized data
    def _deserialize(type, value)
      case type.to_sym
      when :Time
        Time.parse(value)
      when :Date
        Date.parse(value)
      when :String
        value.to_s
      when :Integer
        value.to_i
      when :Float
        value.to_f
      when :Boolean
        if value.to_s =~ /\A(true|t|yes|y|1)\z/i
          true
        else
          false
        end
      when :Object
        # generic object (usually a Hash), return directly
        value
      when /\AArray<(?<inner_type>.+)>\z/
        inner_type = Regexp.last_match[:inner_type]
        value.map { |v| _deserialize(inner_type, v) }
      when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
        k_type = Regexp.last_match[:k_type]
        v_type = Regexp.last_match[:v_type]
        {}.tap do |hash|
          value.each do |k, v|
            hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
          end
        end
      else # model
        # models (e.g. Pet) or oneOf
        klass = PinterestSdkClient.const_get(type)
        klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
      end
    end

    # Returns the string representation of the object
    # @return [String] String presentation of the object
    def to_s
      to_hash.to_s
    end

    # to_body is an alias to to_hash (backward compatibility)
    # @return [Hash] Returns the object in the form of hash
    def to_body
      to_hash
    end

    # Returns the object in the form of hash
    # @return [Hash] Returns the object in the form of hash
    def to_hash
      hash = {}
      self.class.attribute_map.each_pair do |attr, param|
        value = self.send(attr)
        if value.nil?
          is_nullable = self.class.openapi_nullable.include?(attr)
          next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
        end

        hash[param] = _to_hash(value)
      end
      hash
    end

    # Outputs non-array value in the form of hash
    # For object, use to_hash. Otherwise, just return the value
    # @param [Object] value Any valid value
    # @return [Hash] Returns the value in the form of hash
    def _to_hash(value)
      if value.is_a?(Array)
        value.compact.map { |v| _to_hash(v) }
      elsif value.is_a?(Hash)
        {}.tap do |hash|
          value.each { |k, v| hash[k] = _to_hash(v) }
        end
      elsif value.respond_to? :to_hash
        value.to_hash
      else
        value
      end
    end

  end

end