=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 AdsAnalyticsCreateAsyncRequest # Metric report start date (UTC). Format: YYYY-MM-DD attr_accessor :start_date # Metric report end date (UTC). Format: YYYY-MM-DD attr_accessor :end_date # TOTAL - metrics are aggregated over the specified date range.
DAY - metrics are broken down daily.
HOUR - metrics are broken down hourly.
WEEKLY - metrics are broken down weekly.
MONTHLY - metrics are broken down monthly attr_accessor :granularity # Number of days to use as the conversion attribution window for a pin click action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. attr_accessor :click_window_days # Number of days to use as the conversion attribution window for an engagement action. Engagements include saves, closeups, link clicks, and carousel card swipes. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. attr_accessor :engagement_window_days # Number of days to use as the conversion attribution window for a view action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `1` day. attr_accessor :view_window_days # The date by which the conversion metrics returned from this endpoint will be reported. There are two dates associated with a conversion event: the date that the user interacted with the ad, and the date that the user completed a conversion event. attr_accessor :conversion_report_time # List of types of attribution for the conversion report attr_accessor :attribution_types # Metric and entity columns attr_accessor :columns # Level of the report attr_accessor :level # Specification for formatting report data attr_accessor :report_format # List of campaign ids attr_accessor :campaign_ids # List of status values for filtering attr_accessor :campaign_statuses # List of values for filtering attr_accessor :campaign_objective_types # List of ad group ids attr_accessor :ad_group_ids # List of values for filtering attr_accessor :ad_group_statuses # List of ad ids attr_accessor :ad_ids # List of values for filtering attr_accessor :ad_statuses # List of product group ids attr_accessor :product_group_ids # List of values for filtering attr_accessor :product_group_statuses # List of product item ids attr_accessor :product_item_ids # List of targeting types attr_accessor :targeting_types # List of metrics filters attr_accessor :metrics_filters # Attribute mapping from ruby-style variable name to JSON key. def self.attribute_map { :'start_date' => :'start_date', :'end_date' => :'end_date', :'granularity' => :'granularity', :'click_window_days' => :'click_window_days', :'engagement_window_days' => :'engagement_window_days', :'view_window_days' => :'view_window_days', :'conversion_report_time' => :'conversion_report_time', :'attribution_types' => :'attribution_types', :'columns' => :'columns', :'level' => :'level', :'report_format' => :'report_format', :'campaign_ids' => :'campaign_ids', :'campaign_statuses' => :'campaign_statuses', :'campaign_objective_types' => :'campaign_objective_types', :'ad_group_ids' => :'ad_group_ids', :'ad_group_statuses' => :'ad_group_statuses', :'ad_ids' => :'ad_ids', :'ad_statuses' => :'ad_statuses', :'product_group_ids' => :'product_group_ids', :'product_group_statuses' => :'product_group_statuses', :'product_item_ids' => :'product_item_ids', :'targeting_types' => :'targeting_types', :'metrics_filters' => :'metrics_filters' } 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 { :'start_date' => :'String', :'end_date' => :'String', :'granularity' => :'Granularity', :'click_window_days' => :'ConversionAttributionWindowDays', :'engagement_window_days' => :'ConversionAttributionWindowDays', :'view_window_days' => :'ConversionAttributionWindowDays', :'conversion_report_time' => :'ConversionReportTimeType', :'attribution_types' => :'Array', :'columns' => :'Array', :'level' => :'MetricsReportingLevel', :'report_format' => :'DataOutputFormat', :'campaign_ids' => :'Array', :'campaign_statuses' => :'Array', :'campaign_objective_types' => :'Array', :'ad_group_ids' => :'Array', :'ad_group_statuses' => :'Array', :'ad_ids' => :'Array', :'ad_statuses' => :'Array', :'product_group_ids' => :'Array', :'product_group_statuses' => :'Array', :'product_item_ids' => :'Array', :'targeting_types' => :'Array', :'metrics_filters' => :'Array' } end # List of attributes with nullable: true def self.openapi_nullable Set.new([ ]) end # List of class defined in allOf (OpenAPI v3) def self.openapi_all_of [ :'AdsAnalyticsCreateAsyncRequestAllOf', :'AdsAnalyticsCreateAsyncRequestAllOf1' ] 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::AdsAnalyticsCreateAsyncRequest` 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::AdsAnalyticsCreateAsyncRequest`. 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?(:'start_date') self.start_date = attributes[:'start_date'] end if attributes.key?(:'end_date') self.end_date = attributes[:'end_date'] end if attributes.key?(:'granularity') self.granularity = attributes[:'granularity'] end if attributes.key?(:'click_window_days') self.click_window_days = attributes[:'click_window_days'] else self.click_window_days = 30 end if attributes.key?(:'engagement_window_days') self.engagement_window_days = attributes[:'engagement_window_days'] else self.engagement_window_days = 30 end if attributes.key?(:'view_window_days') self.view_window_days = attributes[:'view_window_days'] else self.view_window_days = 1 end if attributes.key?(:'conversion_report_time') self.conversion_report_time = attributes[:'conversion_report_time'] else self.conversion_report_time = 'TIME_OF_AD_ACTION' end if attributes.key?(:'attribution_types') if (value = attributes[:'attribution_types']).is_a?(Array) self.attribution_types = value end end if attributes.key?(:'columns') if (value = attributes[:'columns']).is_a?(Array) self.columns = value end end if attributes.key?(:'level') self.level = attributes[:'level'] end if attributes.key?(:'report_format') self.report_format = attributes[:'report_format'] else self.report_format = 'JSON' end if attributes.key?(:'campaign_ids') if (value = attributes[:'campaign_ids']).is_a?(Array) self.campaign_ids = value end end if attributes.key?(:'campaign_statuses') if (value = attributes[:'campaign_statuses']).is_a?(Array) self.campaign_statuses = value end end if attributes.key?(:'campaign_objective_types') if (value = attributes[:'campaign_objective_types']).is_a?(Array) self.campaign_objective_types = value end end if attributes.key?(:'ad_group_ids') if (value = attributes[:'ad_group_ids']).is_a?(Array) self.ad_group_ids = value end end if attributes.key?(:'ad_group_statuses') if (value = attributes[:'ad_group_statuses']).is_a?(Array) self.ad_group_statuses = value end end if attributes.key?(:'ad_ids') if (value = attributes[:'ad_ids']).is_a?(Array) self.ad_ids = value end end if attributes.key?(:'ad_statuses') if (value = attributes[:'ad_statuses']).is_a?(Array) self.ad_statuses = value end end if attributes.key?(:'product_group_ids') if (value = attributes[:'product_group_ids']).is_a?(Array) self.product_group_ids = value end end if attributes.key?(:'product_group_statuses') if (value = attributes[:'product_group_statuses']).is_a?(Array) self.product_group_statuses = value end end if attributes.key?(:'product_item_ids') if (value = attributes[:'product_item_ids']).is_a?(Array) self.product_item_ids = value end end if attributes.key?(:'targeting_types') if (value = attributes[:'targeting_types']).is_a?(Array) self.targeting_types = value end end if attributes.key?(:'metrics_filters') if (value = attributes[:'metrics_filters']).is_a?(Array) self.metrics_filters = value end 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 @start_date.nil? invalid_properties.push('invalid value for "start_date", start_date cannot be nil.') end pattern = Regexp.new(/^(\d{4})-(\d{2})-(\d{2})$/) if @start_date !~ pattern invalid_properties.push("invalid value for \"start_date\", must conform to the pattern #{pattern}.") end if @end_date.nil? invalid_properties.push('invalid value for "end_date", end_date cannot be nil.') end pattern = Regexp.new(/^(\d{4})-(\d{2})-(\d{2})$/) if @end_date !~ pattern invalid_properties.push("invalid value for \"end_date\", must conform to the pattern #{pattern}.") end if @granularity.nil? invalid_properties.push('invalid value for "granularity", granularity cannot be nil.') end if @columns.nil? invalid_properties.push('invalid value for "columns", columns cannot be nil.') end if @level.nil? invalid_properties.push('invalid value for "level", level cannot be nil.') end if !@campaign_ids.nil? && @campaign_ids.length > 500 invalid_properties.push('invalid value for "campaign_ids", number of items must be less than or equal to 500.') end if !@campaign_ids.nil? && @campaign_ids.length < 1 invalid_properties.push('invalid value for "campaign_ids", number of items must be greater than or equal to 1.') end if !@campaign_statuses.nil? && @campaign_statuses.length > 6 invalid_properties.push('invalid value for "campaign_statuses", number of items must be less than or equal to 6.') end if !@campaign_statuses.nil? && @campaign_statuses.length < 1 invalid_properties.push('invalid value for "campaign_statuses", number of items must be greater than or equal to 1.') end if !@campaign_objective_types.nil? && @campaign_objective_types.length > 6 invalid_properties.push('invalid value for "campaign_objective_types", number of items must be less than or equal to 6.') end if !@campaign_objective_types.nil? && @campaign_objective_types.length < 1 invalid_properties.push('invalid value for "campaign_objective_types", number of items must be greater than or equal to 1.') end if !@ad_group_ids.nil? && @ad_group_ids.length > 500 invalid_properties.push('invalid value for "ad_group_ids", number of items must be less than or equal to 500.') end if !@ad_group_ids.nil? && @ad_group_ids.length < 1 invalid_properties.push('invalid value for "ad_group_ids", number of items must be greater than or equal to 1.') end if !@ad_group_statuses.nil? && @ad_group_statuses.length > 6 invalid_properties.push('invalid value for "ad_group_statuses", number of items must be less than or equal to 6.') end if !@ad_group_statuses.nil? && @ad_group_statuses.length < 1 invalid_properties.push('invalid value for "ad_group_statuses", number of items must be greater than or equal to 1.') end if !@ad_ids.nil? && @ad_ids.length > 500 invalid_properties.push('invalid value for "ad_ids", number of items must be less than or equal to 500.') end if !@ad_ids.nil? && @ad_ids.length < 1 invalid_properties.push('invalid value for "ad_ids", number of items must be greater than or equal to 1.') end if !@ad_statuses.nil? && @ad_statuses.length > 6 invalid_properties.push('invalid value for "ad_statuses", number of items must be less than or equal to 6.') end if !@ad_statuses.nil? && @ad_statuses.length < 1 invalid_properties.push('invalid value for "ad_statuses", number of items must be greater than or equal to 1.') end if !@product_group_ids.nil? && @product_group_ids.length > 500 invalid_properties.push('invalid value for "product_group_ids", number of items must be less than or equal to 500.') end if !@product_group_ids.nil? && @product_group_ids.length < 1 invalid_properties.push('invalid value for "product_group_ids", number of items must be greater than or equal to 1.') end if !@product_group_statuses.nil? && @product_group_statuses.length > 6 invalid_properties.push('invalid value for "product_group_statuses", number of items must be less than or equal to 6.') end if !@product_group_statuses.nil? && @product_group_statuses.length < 1 invalid_properties.push('invalid value for "product_group_statuses", number of items must be greater than or equal to 1.') end if !@product_item_ids.nil? && @product_item_ids.length > 500 invalid_properties.push('invalid value for "product_item_ids", number of items must be less than or equal to 500.') end if !@product_item_ids.nil? && @product_item_ids.length < 1 invalid_properties.push('invalid value for "product_item_ids", number of items must be greater than or equal to 1.') end if !@targeting_types.nil? && @targeting_types.length > 5 invalid_properties.push('invalid value for "targeting_types", number of items must be less than or equal to 5.') end if !@targeting_types.nil? && @targeting_types.length < 1 invalid_properties.push('invalid value for "targeting_types", number of items must be greater than or equal to 1.') end if !@metrics_filters.nil? && @metrics_filters.length < 1 invalid_properties.push('invalid value for "metrics_filters", number of items must be greater than or equal to 1.') 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 @start_date.nil? return false if @start_date !~ Regexp.new(/^(\d{4})-(\d{2})-(\d{2})$/) return false if @end_date.nil? return false if @end_date !~ Regexp.new(/^(\d{4})-(\d{2})-(\d{2})$/) return false if @granularity.nil? return false if @columns.nil? return false if @level.nil? return false if !@campaign_ids.nil? && @campaign_ids.length > 500 return false if !@campaign_ids.nil? && @campaign_ids.length < 1 return false if !@campaign_statuses.nil? && @campaign_statuses.length > 6 return false if !@campaign_statuses.nil? && @campaign_statuses.length < 1 return false if !@campaign_objective_types.nil? && @campaign_objective_types.length > 6 return false if !@campaign_objective_types.nil? && @campaign_objective_types.length < 1 return false if !@ad_group_ids.nil? && @ad_group_ids.length > 500 return false if !@ad_group_ids.nil? && @ad_group_ids.length < 1 return false if !@ad_group_statuses.nil? && @ad_group_statuses.length > 6 return false if !@ad_group_statuses.nil? && @ad_group_statuses.length < 1 return false if !@ad_ids.nil? && @ad_ids.length > 500 return false if !@ad_ids.nil? && @ad_ids.length < 1 return false if !@ad_statuses.nil? && @ad_statuses.length > 6 return false if !@ad_statuses.nil? && @ad_statuses.length < 1 return false if !@product_group_ids.nil? && @product_group_ids.length > 500 return false if !@product_group_ids.nil? && @product_group_ids.length < 1 return false if !@product_group_statuses.nil? && @product_group_statuses.length > 6 return false if !@product_group_statuses.nil? && @product_group_statuses.length < 1 return false if !@product_item_ids.nil? && @product_item_ids.length > 500 return false if !@product_item_ids.nil? && @product_item_ids.length < 1 return false if !@targeting_types.nil? && @targeting_types.length > 5 return false if !@targeting_types.nil? && @targeting_types.length < 1 return false if !@metrics_filters.nil? && @metrics_filters.length < 1 true end # Custom attribute writer method with validation # @param [Object] start_date Value to be assigned def start_date=(start_date) if start_date.nil? fail ArgumentError, 'start_date cannot be nil' end pattern = Regexp.new(/^(\d{4})-(\d{2})-(\d{2})$/) if start_date !~ pattern fail ArgumentError, "invalid value for \"start_date\", must conform to the pattern #{pattern}." end @start_date = start_date end # Custom attribute writer method with validation # @param [Object] end_date Value to be assigned def end_date=(end_date) if end_date.nil? fail ArgumentError, 'end_date cannot be nil' end pattern = Regexp.new(/^(\d{4})-(\d{2})-(\d{2})$/) if end_date !~ pattern fail ArgumentError, "invalid value for \"end_date\", must conform to the pattern #{pattern}." end @end_date = end_date end # Custom attribute writer method with validation # @param [Object] campaign_ids Value to be assigned def campaign_ids=(campaign_ids) if !campaign_ids.nil? && campaign_ids.length > 500 fail ArgumentError, 'invalid value for "campaign_ids", number of items must be less than or equal to 500.' end if !campaign_ids.nil? && campaign_ids.length < 1 fail ArgumentError, 'invalid value for "campaign_ids", number of items must be greater than or equal to 1.' end @campaign_ids = campaign_ids end # Custom attribute writer method with validation # @param [Object] campaign_statuses Value to be assigned def campaign_statuses=(campaign_statuses) if !campaign_statuses.nil? && campaign_statuses.length > 6 fail ArgumentError, 'invalid value for "campaign_statuses", number of items must be less than or equal to 6.' end if !campaign_statuses.nil? && campaign_statuses.length < 1 fail ArgumentError, 'invalid value for "campaign_statuses", number of items must be greater than or equal to 1.' end @campaign_statuses = campaign_statuses end # Custom attribute writer method with validation # @param [Object] campaign_objective_types Value to be assigned def campaign_objective_types=(campaign_objective_types) if !campaign_objective_types.nil? && campaign_objective_types.length > 6 fail ArgumentError, 'invalid value for "campaign_objective_types", number of items must be less than or equal to 6.' end if !campaign_objective_types.nil? && campaign_objective_types.length < 1 fail ArgumentError, 'invalid value for "campaign_objective_types", number of items must be greater than or equal to 1.' end @campaign_objective_types = campaign_objective_types end # Custom attribute writer method with validation # @param [Object] ad_group_ids Value to be assigned def ad_group_ids=(ad_group_ids) if !ad_group_ids.nil? && ad_group_ids.length > 500 fail ArgumentError, 'invalid value for "ad_group_ids", number of items must be less than or equal to 500.' end if !ad_group_ids.nil? && ad_group_ids.length < 1 fail ArgumentError, 'invalid value for "ad_group_ids", number of items must be greater than or equal to 1.' end @ad_group_ids = ad_group_ids end # Custom attribute writer method with validation # @param [Object] ad_group_statuses Value to be assigned def ad_group_statuses=(ad_group_statuses) if !ad_group_statuses.nil? && ad_group_statuses.length > 6 fail ArgumentError, 'invalid value for "ad_group_statuses", number of items must be less than or equal to 6.' end if !ad_group_statuses.nil? && ad_group_statuses.length < 1 fail ArgumentError, 'invalid value for "ad_group_statuses", number of items must be greater than or equal to 1.' end @ad_group_statuses = ad_group_statuses end # Custom attribute writer method with validation # @param [Object] ad_ids Value to be assigned def ad_ids=(ad_ids) if !ad_ids.nil? && ad_ids.length > 500 fail ArgumentError, 'invalid value for "ad_ids", number of items must be less than or equal to 500.' end if !ad_ids.nil? && ad_ids.length < 1 fail ArgumentError, 'invalid value for "ad_ids", number of items must be greater than or equal to 1.' end @ad_ids = ad_ids end # Custom attribute writer method with validation # @param [Object] ad_statuses Value to be assigned def ad_statuses=(ad_statuses) if !ad_statuses.nil? && ad_statuses.length > 6 fail ArgumentError, 'invalid value for "ad_statuses", number of items must be less than or equal to 6.' end if !ad_statuses.nil? && ad_statuses.length < 1 fail ArgumentError, 'invalid value for "ad_statuses", number of items must be greater than or equal to 1.' end @ad_statuses = ad_statuses end # Custom attribute writer method with validation # @param [Object] product_group_ids Value to be assigned def product_group_ids=(product_group_ids) if !product_group_ids.nil? && product_group_ids.length > 500 fail ArgumentError, 'invalid value for "product_group_ids", number of items must be less than or equal to 500.' end if !product_group_ids.nil? && product_group_ids.length < 1 fail ArgumentError, 'invalid value for "product_group_ids", number of items must be greater than or equal to 1.' end @product_group_ids = product_group_ids end # Custom attribute writer method with validation # @param [Object] product_group_statuses Value to be assigned def product_group_statuses=(product_group_statuses) if !product_group_statuses.nil? && product_group_statuses.length > 6 fail ArgumentError, 'invalid value for "product_group_statuses", number of items must be less than or equal to 6.' end if !product_group_statuses.nil? && product_group_statuses.length < 1 fail ArgumentError, 'invalid value for "product_group_statuses", number of items must be greater than or equal to 1.' end @product_group_statuses = product_group_statuses end # Custom attribute writer method with validation # @param [Object] product_item_ids Value to be assigned def product_item_ids=(product_item_ids) if !product_item_ids.nil? && product_item_ids.length > 500 fail ArgumentError, 'invalid value for "product_item_ids", number of items must be less than or equal to 500.' end if !product_item_ids.nil? && product_item_ids.length < 1 fail ArgumentError, 'invalid value for "product_item_ids", number of items must be greater than or equal to 1.' end @product_item_ids = product_item_ids end # Custom attribute writer method with validation # @param [Object] targeting_types Value to be assigned def targeting_types=(targeting_types) if !targeting_types.nil? && targeting_types.length > 5 fail ArgumentError, 'invalid value for "targeting_types", number of items must be less than or equal to 5.' end if !targeting_types.nil? && targeting_types.length < 1 fail ArgumentError, 'invalid value for "targeting_types", number of items must be greater than or equal to 1.' end @targeting_types = targeting_types end # Custom attribute writer method with validation # @param [Object] metrics_filters Value to be assigned def metrics_filters=(metrics_filters) if !metrics_filters.nil? && metrics_filters.length < 1 fail ArgumentError, 'invalid value for "metrics_filters", number of items must be greater than or equal to 1.' end @metrics_filters = metrics_filters 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 && start_date == o.start_date && end_date == o.end_date && granularity == o.granularity && click_window_days == o.click_window_days && engagement_window_days == o.engagement_window_days && view_window_days == o.view_window_days && conversion_report_time == o.conversion_report_time && attribution_types == o.attribution_types && columns == o.columns && level == o.level && report_format == o.report_format && campaign_ids == o.campaign_ids && campaign_statuses == o.campaign_statuses && campaign_objective_types == o.campaign_objective_types && ad_group_ids == o.ad_group_ids && ad_group_statuses == o.ad_group_statuses && ad_ids == o.ad_ids && ad_statuses == o.ad_statuses && product_group_ids == o.product_group_ids && product_group_statuses == o.product_group_statuses && product_item_ids == o.product_item_ids && targeting_types == o.targeting_types && metrics_filters == o.metrics_filters 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 [start_date, end_date, granularity, click_window_days, engagement_window_days, view_window_days, conversion_report_time, attribution_types, columns, level, report_format, campaign_ids, campaign_statuses, campaign_objective_types, ad_group_ids, ad_group_statuses, ad_ids, ad_statuses, product_group_ids, product_group_statuses, product_item_ids, targeting_types, metrics_filters].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