Method: Kuapir::FilmSearchByFiltersResponseItems#initialize

Defined in:
lib/kuapir/models/film_search_by_filters_response_items.rb

#initialize(attributes = {}) ⇒ FilmSearchByFiltersResponseItems

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/kuapir/models/film_search_by_filters_response_items.rb', line 90

def initialize(attributes = {})
  unless attributes.is_a?(Hash)
    raise ArgumentError,
          "The input argument (attributes) must be a hash in `Kuapir::FilmSearchByFiltersResponseItems` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  attributes = attributes.each_with_object({}) do |(k, v), h|
    unless self.class.attribute_map.key?(k.to_sym)
      raise ArgumentError,
            "`#{k}` is not a valid attribute in `Kuapir::FilmSearchByFiltersResponseItems`. 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
  end

  self.kinopoisk_id = attributes[:kinopoisk_id] if attributes.key?(:kinopoisk_id)

  self.imdb_id = attributes[:imdb_id] if attributes.key?(:imdb_id)

  self.name_ru = attributes[:name_ru] if attributes.key?(:name_ru)

  self.name_en = attributes[:name_en] if attributes.key?(:name_en)

  self.name_original = attributes[:name_original] if attributes.key?(:name_original)

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

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

  self.rating_kinopoisk = attributes[:rating_kinopoisk] if attributes.key?(:rating_kinopoisk)

  self.rating_imdb = attributes[:rating_imdb] if attributes.key?(:rating_imdb)

  self.year = attributes[:year] if attributes.key?(:year)

  self.type = attributes[:type] if attributes.key?(:type)

  self.poster_url = attributes[:poster_url] if attributes.key?(:poster_url)

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