=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 # Creation fields class AdResponseAllOf # ID of the ad group that contains the ad. attr_accessor :ad_group_id # Deep link URL for Android devices. Not currently available. Using this field will generate an error. attr_accessor :android_deep_link # Comma-separated deep links for the carousel pin on Android. attr_accessor :carousel_android_deep_links # Comma-separated destination URLs for the carousel pin to promote. attr_accessor :carousel_destination_urls # Comma-separated deep links for the carousel pin on iOS. attr_accessor :carousel_ios_deep_links # Tracking url for the ad clicks. attr_accessor :click_tracking_url # Ad creative type enum attr_accessor :creative_type # Destination URL. attr_accessor :destination_url # Deep link URL for iOS devices. Not currently available. Using this field will generate an error. attr_accessor :ios_deep_link # Is original pin deleted? attr_accessor :is_pin_deleted # Is pin repinnable? attr_accessor :is_removable # Name of the ad - 255 chars max. attr_accessor :name # Pin ID. attr_accessor :pin_id attr_accessor :status attr_accessor :tracking_urls # Tracking URL for ad impressions. attr_accessor :view_tracking_url class EnumAttributeValidator attr_reader :datatype attr_reader :allowable_values def initialize(datatype, allowable_values) @allowable_values = allowable_values.map do |value| case datatype.to_s when /Integer/i value.to_i when /Float/i value.to_f else value end end end def valid?(value) !value || allowable_values.include?(value) end end # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'ad_group_id' => :'ad_group_id', :'android_deep_link' => :'android_deep_link', :'carousel_android_deep_links' => :'carousel_android_deep_links', :'carousel_destination_urls' => :'carousel_destination_urls', :'carousel_ios_deep_links' => :'carousel_ios_deep_links', :'click_tracking_url' => :'click_tracking_url', :'creative_type' => :'creative_type', :'destination_url' => :'destination_url', :'ios_deep_link' => :'ios_deep_link', :'is_pin_deleted' => :'is_pin_deleted', :'is_removable' => :'is_removable', :'name' => :'name', :'pin_id' => :'pin_id', :'status' => :'status', :'tracking_urls' => :'tracking_urls', :'view_tracking_url' => :'view_tracking_url' } 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_group_id' => :'String', :'android_deep_link' => :'String', :'carousel_android_deep_links' => :'Array', :'carousel_destination_urls' => :'Array', :'carousel_ios_deep_links' => :'Array', :'click_tracking_url' => :'String', :'creative_type' => :'String', :'destination_url' => :'String', :'ios_deep_link' => :'String', :'is_pin_deleted' => :'Boolean', :'is_removable' => :'Boolean', :'name' => :'String', :'pin_id' => :'String', :'status' => :'EntityStatus', :'tracking_urls' => :'TrackingUrls', :'view_tracking_url' => :'String' } end # List of attributes with nullable: true def self.openapi_nullable Set.new([ :'android_deep_link', :'carousel_android_deep_links', :'carousel_destination_urls', :'carousel_ios_deep_links', :'click_tracking_url', :'destination_url', :'ios_deep_link', :'name', :'tracking_urls', :'view_tracking_url' ]) 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::AdResponseAllOf` 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::AdResponseAllOf`. 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_group_id') self.ad_group_id = attributes[:'ad_group_id'] end if attributes.key?(:'android_deep_link') self.android_deep_link = attributes[:'android_deep_link'] end if attributes.key?(:'carousel_android_deep_links') if (value = attributes[:'carousel_android_deep_links']).is_a?(Array) self.carousel_android_deep_links = value end end if attributes.key?(:'carousel_destination_urls') if (value = attributes[:'carousel_destination_urls']).is_a?(Array) self.carousel_destination_urls = value end end if attributes.key?(:'carousel_ios_deep_links') if (value = attributes[:'carousel_ios_deep_links']).is_a?(Array) self.carousel_ios_deep_links = value end end if attributes.key?(:'click_tracking_url') self.click_tracking_url = attributes[:'click_tracking_url'] end if attributes.key?(:'creative_type') self.creative_type = attributes[:'creative_type'] end if attributes.key?(:'destination_url') self.destination_url = attributes[:'destination_url'] end if attributes.key?(:'ios_deep_link') self.ios_deep_link = attributes[:'ios_deep_link'] end if attributes.key?(:'is_pin_deleted') self.is_pin_deleted = attributes[:'is_pin_deleted'] end if attributes.key?(:'is_removable') self.is_removable = attributes[:'is_removable'] end if attributes.key?(:'name') self.name = attributes[:'name'] end if attributes.key?(:'pin_id') self.pin_id = attributes[:'pin_id'] end if attributes.key?(:'status') self.status = attributes[:'status'] end if attributes.key?(:'tracking_urls') if (value = attributes[:'tracking_urls']).is_a?(Hash) self.tracking_urls = value end self.tracking_urls = attributes[:'tracking_urls'] end if attributes.key?(:'view_tracking_url') self.view_tracking_url = attributes[:'view_tracking_url'] 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 pattern = Regexp.new(/^\d+$/) if !@ad_group_id.nil? && @ad_group_id !~ pattern invalid_properties.push("invalid value for \"ad_group_id\", must conform to the pattern #{pattern}.") end pattern = Regexp.new(/^\d+$/) if !@pin_id.nil? && @pin_id !~ pattern invalid_properties.push("invalid value for \"pin_id\", must conform to the pattern #{pattern}.") 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 !@ad_group_id.nil? && @ad_group_id !~ Regexp.new(/^\d+$/) creative_type_validator = EnumAttributeValidator.new('String', ["REGULAR", "VIDEO", "SHOPPING", "CAROUSEL", "MAX_VIDEO", "SHOP_THE_PIN", "STORY"]) return false unless creative_type_validator.valid?(@creative_type) return false if !@pin_id.nil? && @pin_id !~ Regexp.new(/^\d+$/) true end # Custom attribute writer method with validation # @param [Object] ad_group_id Value to be assigned def ad_group_id=(ad_group_id) pattern = Regexp.new(/^\d+$/) if !ad_group_id.nil? && ad_group_id !~ pattern fail ArgumentError, "invalid value for \"ad_group_id\", must conform to the pattern #{pattern}." end @ad_group_id = ad_group_id end # Custom attribute writer method checking allowed values (enum). # @param [Object] creative_type Object to be assigned def creative_type=(creative_type) validator = EnumAttributeValidator.new('String', ["REGULAR", "VIDEO", "SHOPPING", "CAROUSEL", "MAX_VIDEO", "SHOP_THE_PIN", "STORY"]) unless validator.valid?(creative_type) fail ArgumentError, "invalid value for \"creative_type\", must be one of #{validator.allowable_values}." end @creative_type = creative_type end # Custom attribute writer method with validation # @param [Object] pin_id Value to be assigned def pin_id=(pin_id) pattern = Regexp.new(/^\d+$/) if !pin_id.nil? && pin_id !~ pattern fail ArgumentError, "invalid value for \"pin_id\", must conform to the pattern #{pattern}." end @pin_id = pin_id 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_group_id == o.ad_group_id && android_deep_link == o.android_deep_link && carousel_android_deep_links == o.carousel_android_deep_links && carousel_destination_urls == o.carousel_destination_urls && carousel_ios_deep_links == o.carousel_ios_deep_links && click_tracking_url == o.click_tracking_url && creative_type == o.creative_type && destination_url == o.destination_url && ios_deep_link == o.ios_deep_link && is_pin_deleted == o.is_pin_deleted && is_removable == o.is_removable && name == o.name && pin_id == o.pin_id && status == o.status && tracking_urls == o.tracking_urls && view_tracking_url == o.view_tracking_url 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_group_id, android_deep_link, carousel_android_deep_links, carousel_destination_urls, carousel_ios_deep_links, click_tracking_url, creative_type, destination_url, ios_deep_link, is_pin_deleted, is_removable, name, pin_id, status, tracking_urls, view_tracking_url].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<(?.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?.+?), (?.+)>\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