=begin
#GameBrain API
#GameBrain API
The version of the OpenAPI document: 1.0.1
Contact: mail@gamebrain.co
Generated by: https://openapi-generator.tech
Generator version: 7.8.0-SNAPSHOT
=end
require 'date'
require 'time'
module OpenapiClient
class GameResponse
attr_accessor :id
attr_accessor :name
attr_accessor :image
attr_accessor :gameplay
attr_accessor :link
attr_accessor :x_url
attr_accessor :rating
attr_accessor :description
attr_accessor :short_description
attr_accessor :release_date
attr_accessor :developer
attr_accessor :playtime
attr_accessor :platforms
attr_accessor :tags
attr_accessor :genres
attr_accessor :genre
attr_accessor :themes
attr_accessor :adult_only
attr_accessor :play_modes
attr_accessor :screenshots
attr_accessor :videos
attr_accessor :offers
attr_accessor :official_stores
attr_accessor :micro_trailer
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'id' => :'id',
:'name' => :'name',
:'image' => :'image',
:'gameplay' => :'gameplay',
:'link' => :'link',
:'x_url' => :'x_url',
:'rating' => :'rating',
:'description' => :'description',
:'short_description' => :'short_description',
:'release_date' => :'release_date',
:'developer' => :'developer',
:'playtime' => :'playtime',
:'platforms' => :'platforms',
:'tags' => :'tags',
:'genres' => :'genres',
:'genre' => :'genre',
:'themes' => :'themes',
:'adult_only' => :'adult_only',
:'play_modes' => :'play_modes',
:'screenshots' => :'screenshots',
:'videos' => :'videos',
:'offers' => :'offers',
:'official_stores' => :'official_stores',
:'micro_trailer' => :'micro_trailer'
}
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
{
:'id' => :'Integer',
:'name' => :'String',
:'image' => :'String',
:'gameplay' => :'String',
:'link' => :'String',
:'x_url' => :'String',
:'rating' => :'GameResponseRating',
:'description' => :'String',
:'short_description' => :'String',
:'release_date' => :'Date',
:'developer' => :'String',
:'playtime' => :'GameResponsePlaytime',
:'platforms' => :'Array<GameResponsePlatformsInner>',
:'tags' => :'Array<String>',
:'genres' => :'Array<GameResponsePlatformsInner>',
:'genre' => :'String',
:'themes' => :'Array<GameResponsePlatformsInner>',
:'adult_only' => :'Boolean',
:'play_modes' => :'Array<GameResponsePlatformsInner>',
:'screenshots' => :'Array<String>',
:'videos' => :'Array<String>',
:'offers' => :'Array<GameResponseOffersInner>',
:'official_stores' => :'Array<GameResponseOfficialStoresInner>',
:'micro_trailer' => :'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 `OpenapiClient::GameResponse` 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 `OpenapiClient::GameResponse`. 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?(:'id')
self.id = attributes[:'id']
end
if attributes.key?(:'name')
self.name = attributes[:'name']
end
if attributes.key?(:'image')
self.image = attributes[:'image']
end
if attributes.key?(:'gameplay')
self.gameplay = attributes[:'gameplay']
end
if attributes.key?(:'link')
self.link = attributes[:'link']
end
if attributes.key?(:'x_url')
self.x_url = attributes[:'x_url']
end
if attributes.key?(:'rating')
self.rating = attributes[:'rating']
end
if attributes.key?(:'description')
self.description = attributes[:'description']
end
if attributes.key?(:'short_description')
self.short_description = attributes[:'short_description']
end
if attributes.key?(:'release_date')
self.release_date = attributes[:'release_date']
end
if attributes.key?(:'developer')
self.developer = attributes[:'developer']
end
if attributes.key?(:'playtime')
self.playtime = attributes[:'playtime']
end
if attributes.key?(:'platforms')
if (value = attributes[:'platforms']).is_a?(Array)
self.platforms = value
end
end
if attributes.key?(:'tags')
if (value = attributes[:'tags']).is_a?(Array)
self.tags = value
end
end
if attributes.key?(:'genres')
if (value = attributes[:'genres']).is_a?(Array)
self.genres = value
end
end
if attributes.key?(:'genre')
self.genre = attributes[:'genre']
end
if attributes.key?(:'themes')
if (value = attributes[:'themes']).is_a?(Array)
self.themes = value
end
end
if attributes.key?(:'adult_only')
self.adult_only = attributes[:'adult_only']
end
if attributes.key?(:'play_modes')
if (value = attributes[:'play_modes']).is_a?(Array)
self.play_modes = value
end
end
if attributes.key?(:'screenshots')
if (value = attributes[:'screenshots']).is_a?(Array)
self.screenshots = value
end
end
if attributes.key?(:'videos')
if (value = attributes[:'videos']).is_a?(Array)
self.videos = value
end
end
if attributes.key?(:'offers')
if (value = attributes[:'offers']).is_a?(Array)
self.offers = value
end
end
if attributes.key?(:'official_stores')
if (value = attributes[:'official_stores']).is_a?(Array)
self.official_stores = value
end
end
if attributes.key?(:'micro_trailer')
self.micro_trailer = attributes[:'micro_trailer']
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
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
invalid_properties = Array.new
if !@platforms.nil? && @platforms.length > 100
invalid_properties.push('invalid value for "platforms", number of items must be less than or equal to 100.')
end
if !@tags.nil? && @tags.length > 100
invalid_properties.push('invalid value for "tags", number of items must be less than or equal to 100.')
end
if !@genres.nil? && @genres.length > 100
invalid_properties.push('invalid value for "genres", number of items must be less than or equal to 100.')
end
if !@themes.nil? && @themes.length > 100
invalid_properties.push('invalid value for "themes", number of items must be less than or equal to 100.')
end
if !@play_modes.nil? && @play_modes.length > 100
invalid_properties.push('invalid value for "play_modes", number of items must be less than or equal to 100.')
end
if !@screenshots.nil? && @screenshots.length > 100
invalid_properties.push('invalid value for "screenshots", number of items must be less than or equal to 100.')
end
if !@videos.nil? && @videos.length > 100
invalid_properties.push('invalid value for "videos", number of items must be less than or equal to 100.')
end
if !@offers.nil? && @offers.length > 100
invalid_properties.push('invalid value for "offers", number of items must be less than or equal to 100.')
end
if !@official_stores.nil? && @official_stores.length > 100
invalid_properties.push('invalid value for "official_stores", number of items must be less than or equal to 100.')
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?
warn '[DEPRECATED] the `valid?` method is obsolete'
return false if !@platforms.nil? && @platforms.length > 100
return false if !@tags.nil? && @tags.length > 100
return false if !@genres.nil? && @genres.length > 100
return false if !@themes.nil? && @themes.length > 100
return false if !@play_modes.nil? && @play_modes.length > 100
return false if !@screenshots.nil? && @screenshots.length > 100
return false if !@videos.nil? && @videos.length > 100
return false if !@offers.nil? && @offers.length > 100
return false if !@official_stores.nil? && @official_stores.length > 100
true
end
# Custom attribute writer method with validation
# @param [Object] platforms Value to be assigned
def platforms=(platforms)
if platforms.nil?
fail ArgumentError, 'platforms cannot be nil'
end
if platforms.length > 100
fail ArgumentError, 'invalid value for "platforms", number of items must be less than or equal to 100.'
end
@platforms = platforms
end
# Custom attribute writer method with validation
# @param [Object] tags Value to be assigned
def tags=(tags)
if tags.nil?
fail ArgumentError, 'tags cannot be nil'
end
if tags.length > 100
fail ArgumentError, 'invalid value for "tags", number of items must be less than or equal to 100.'
end
@tags = tags
end
# Custom attribute writer method with validation
# @param [Object] genres Value to be assigned
def genres=(genres)
if genres.nil?
fail ArgumentError, 'genres cannot be nil'
end
if genres.length > 100
fail ArgumentError, 'invalid value for "genres", number of items must be less than or equal to 100.'
end
@genres = genres
end
# Custom attribute writer method with validation
# @param [Object] themes Value to be assigned
def themes=(themes)
if themes.nil?
fail ArgumentError, 'themes cannot be nil'
end
if themes.length > 100
fail ArgumentError, 'invalid value for "themes", number of items must be less than or equal to 100.'
end
@themes = themes
end
# Custom attribute writer method with validation
# @param [Object] play_modes Value to be assigned
def play_modes=(play_modes)
if play_modes.nil?
fail ArgumentError, 'play_modes cannot be nil'
end
if play_modes.length > 100
fail ArgumentError, 'invalid value for "play_modes", number of items must be less than or equal to 100.'
end
@play_modes = play_modes
end
# Custom attribute writer method with validation
# @param [Object] screenshots Value to be assigned
def screenshots=(screenshots)
if screenshots.nil?
fail ArgumentError, 'screenshots cannot be nil'
end
if screenshots.length > 100
fail ArgumentError, 'invalid value for "screenshots", number of items must be less than or equal to 100.'
end
@screenshots = screenshots
end
# Custom attribute writer method with validation
# @param [Object] videos Value to be assigned
def videos=(videos)
if videos.nil?
fail ArgumentError, 'videos cannot be nil'
end
if videos.length > 100
fail ArgumentError, 'invalid value for "videos", number of items must be less than or equal to 100.'
end
@videos = videos
end
# Custom attribute writer method with validation
# @param [Object] offers Value to be assigned
def offers=(offers)
if offers.nil?
fail ArgumentError, 'offers cannot be nil'
end
if offers.length > 100
fail ArgumentError, 'invalid value for "offers", number of items must be less than or equal to 100.'
end
@offers = offers
end
# Custom attribute writer method with validation
# @param [Object] official_stores Value to be assigned
def official_stores=(official_stores)
if official_stores.nil?
fail ArgumentError, 'official_stores cannot be nil'
end
if official_stores.length > 100
fail ArgumentError, 'invalid value for "official_stores", number of items must be less than or equal to 100.'
end
@official_stores = official_stores
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 &&
id == o.id &&
name == o.name &&
image == o.image &&
gameplay == o.gameplay &&
link == o.link &&
x_url == o.x_url &&
rating == o.rating &&
description == o.description &&
short_description == o.short_description &&
release_date == o.release_date &&
developer == o.developer &&
playtime == o.playtime &&
platforms == o.platforms &&
tags == o.tags &&
genres == o.genres &&
genre == o.genre &&
themes == o.themes &&
adult_only == o.adult_only &&
play_modes == o.play_modes &&
screenshots == o.screenshots &&
videos == o.videos &&
offers == o.offers &&
official_stores == o.official_stores &&
micro_trailer == o.micro_trailer
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
[id, name, image, gameplay, link, x_url, rating, description, short_description, release_date, developer, playtime, platforms, tags, genres, genre, themes, adult_only, play_modes, screenshots, videos, offers, official_stores, micro_trailer].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)
return nil unless attributes.is_a?(Hash)
attributes = attributes.transform_keys(&:to_sym)
transformed_hash = {}
openapi_types.each_pair do |key, type|
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
transformed_hash["#{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[attribute_map[key]].is_a?(Array)
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
end
elsif !attributes[attribute_map[key]].nil?
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
end
end
new(transformed_hash)
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def self._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 = OpenapiClient.const_get(type)
klass.respond_to?(:openapi_any_of) || 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