kuapir 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +13 -0
  3. data/Gemfile.lock +77 -0
  4. data/LICENSE +21 -0
  5. data/README.md +170 -0
  6. data/Rakefile +12 -0
  7. data/docs/BoxOffice.md +26 -0
  8. data/docs/BoxOfficeResponse.md +20 -0
  9. data/docs/Company.md +18 -0
  10. data/docs/Country.md +18 -0
  11. data/docs/DigitalReleaseItem.md +44 -0
  12. data/docs/DigitalReleaseResponse.md +22 -0
  13. data/docs/Distribution.md +28 -0
  14. data/docs/DistributionResponse.md +20 -0
  15. data/docs/Episode.md +28 -0
  16. data/docs/Fact.md +22 -0
  17. data/docs/FactResponse.md +20 -0
  18. data/docs/Film.md +100 -0
  19. data/docs/FilmSearchByFiltersResponse.md +22 -0
  20. data/docs/FilmSearchByFiltersResponseItems.md +42 -0
  21. data/docs/FilmSearchResponse.md +24 -0
  22. data/docs/FilmSearchResponseFilms.md +42 -0
  23. data/docs/FilmSequelsAndPrequelsResponse.md +30 -0
  24. data/docs/FilmTopResponse.md +20 -0
  25. data/docs/FilmTopResponseFilms.md +38 -0
  26. data/docs/FilmsApi.md +1126 -0
  27. data/docs/FiltersResponse.md +20 -0
  28. data/docs/FiltersResponseCountries.md +20 -0
  29. data/docs/FiltersResponseGenres.md +20 -0
  30. data/docs/Genre.md +18 -0
  31. data/docs/ImageResponse.md +22 -0
  32. data/docs/ImageResponseItems.md +20 -0
  33. data/docs/PersonByNameResponse.md +20 -0
  34. data/docs/PersonByNameResponseItems.md +28 -0
  35. data/docs/PersonResponse.md +50 -0
  36. data/docs/PersonResponseFilms.md +30 -0
  37. data/docs/PersonResponseSpouses.md +32 -0
  38. data/docs/PersonsApi.md +83 -0
  39. data/docs/PremiereResponse.md +20 -0
  40. data/docs/PremiereResponseItem.md +36 -0
  41. data/docs/RelatedFilmResponse.md +20 -0
  42. data/docs/RelatedFilmResponseItems.md +30 -0
  43. data/docs/ReviewDetailsResponse.md +32 -0
  44. data/docs/ReviewsApi.md +155 -0
  45. data/docs/ReviewsResponse.md +34 -0
  46. data/docs/ReviewsResponseReviews.md +32 -0
  47. data/docs/Season.md +20 -0
  48. data/docs/SeasonResponse.md +20 -0
  49. data/docs/StaffApi.md +147 -0
  50. data/docs/StaffResponse.md +30 -0
  51. data/docs/VideoResponse.md +20 -0
  52. data/docs/VideoResponseItems.md +22 -0
  53. data/kinopoiskapiunofficial-openapi.json +2918 -0
  54. data/kuapir.gemspec +42 -0
  55. data/lib/kuapir/api/films_api.rb +1193 -0
  56. data/lib/kuapir/api/persons_api.rb +89 -0
  57. data/lib/kuapir/api/reviews_api.rb +165 -0
  58. data/lib/kuapir/api/staff_api.rb +145 -0
  59. data/lib/kuapir/api_client.rb +390 -0
  60. data/lib/kuapir/api_error.rb +57 -0
  61. data/lib/kuapir/configuration.rb +287 -0
  62. data/lib/kuapir/models/box_office.rb +246 -0
  63. data/lib/kuapir/models/box_office_response.rb +224 -0
  64. data/lib/kuapir/models/company.rb +214 -0
  65. data/lib/kuapir/models/country.rb +214 -0
  66. data/lib/kuapir/models/digital_release_item.rb +334 -0
  67. data/lib/kuapir/models/digital_release_response.rb +232 -0
  68. data/lib/kuapir/models/distribution.rb +300 -0
  69. data/lib/kuapir/models/distribution_response.rb +224 -0
  70. data/lib/kuapir/models/episode.rb +249 -0
  71. data/lib/kuapir/models/fact.rb +266 -0
  72. data/lib/kuapir/models/fact_response.rb +224 -0
  73. data/lib/kuapir/models/film.rb +551 -0
  74. data/lib/kuapir/models/film_search_by_filters_response.rb +232 -0
  75. data/lib/kuapir/models/film_search_by_filters_response_items.rb +319 -0
  76. data/lib/kuapir/models/film_search_response.rb +244 -0
  77. data/lib/kuapir/models/film_search_response_films.rb +311 -0
  78. data/lib/kuapir/models/film_sequels_and_prequels_response.rb +300 -0
  79. data/lib/kuapir/models/film_top_response.rb +224 -0
  80. data/lib/kuapir/models/film_top_response_films.rb +272 -0
  81. data/lib/kuapir/models/filters_response.rb +226 -0
  82. data/lib/kuapir/models/filters_response_countries.rb +214 -0
  83. data/lib/kuapir/models/filters_response_genres.rb +214 -0
  84. data/lib/kuapir/models/genre.rb +214 -0
  85. data/lib/kuapir/models/image_response.rb +238 -0
  86. data/lib/kuapir/models/image_response_items.rb +214 -0
  87. data/lib/kuapir/models/person_by_name_response.rb +224 -0
  88. data/lib/kuapir/models/person_by_name_response_items.rb +274 -0
  89. data/lib/kuapir/models/person_response.rb +363 -0
  90. data/lib/kuapir/models/person_response_films.rb +284 -0
  91. data/lib/kuapir/models/person_response_spouses.rb +283 -0
  92. data/lib/kuapir/models/premiere_response.rb +224 -0
  93. data/lib/kuapir/models/premiere_response_item.rb +289 -0
  94. data/lib/kuapir/models/related_film_response.rb +224 -0
  95. data/lib/kuapir/models/related_film_response_items.rb +279 -0
  96. data/lib/kuapir/models/review_details_response.rb +314 -0
  97. data/lib/kuapir/models/reviews_response.rb +294 -0
  98. data/lib/kuapir/models/reviews_response_reviews.rb +282 -0
  99. data/lib/kuapir/models/season.rb +224 -0
  100. data/lib/kuapir/models/season_response.rb +224 -0
  101. data/lib/kuapir/models/staff_response.rb +301 -0
  102. data/lib/kuapir/models/video_response.rb +224 -0
  103. data/lib/kuapir/models/video_response_items.rb +255 -0
  104. data/lib/kuapir/version.rb +5 -0
  105. data/lib/kuapir.rb +83 -0
  106. data/openapi-generator-templates/Gemfile.mustache +9 -0
  107. data/openapi-generator-templates/README.mustache +148 -0
  108. data/openapi-generator-templates/Rakefile.mustache +10 -0
  109. data/openapi-generator-templates/api.mustache +205 -0
  110. data/openapi-generator-templates/api_client.mustache +260 -0
  111. data/openapi-generator-templates/api_client_faraday_partial.mustache +136 -0
  112. data/openapi-generator-templates/api_client_spec.mustache +216 -0
  113. data/openapi-generator-templates/api_client_typhoeus_partial.mustache +153 -0
  114. data/openapi-generator-templates/api_doc.mustache +118 -0
  115. data/openapi-generator-templates/api_error.mustache +45 -0
  116. data/openapi-generator-templates/api_info.mustache +12 -0
  117. data/openapi-generator-templates/api_test.mustache +43 -0
  118. data/openapi-generator-templates/base_object.mustache +120 -0
  119. data/openapi-generator-templates/configuration.mustache +381 -0
  120. data/openapi-generator-templates/configuration_spec.mustache +30 -0
  121. data/openapi-generator-templates/configuration_tls_faraday_partial.mustache +29 -0
  122. data/openapi-generator-templates/configuration_tls_typhoeus_partial.mustache +34 -0
  123. data/openapi-generator-templates/gem.mustache +50 -0
  124. data/openapi-generator-templates/gemspec.mustache +31 -0
  125. data/openapi-generator-templates/git_push.sh.mustache +57 -0
  126. data/openapi-generator-templates/gitignore.mustache +39 -0
  127. data/openapi-generator-templates/model.mustache +22 -0
  128. data/openapi-generator-templates/model_doc.mustache +12 -0
  129. data/openapi-generator-templates/model_test.mustache +73 -0
  130. data/openapi-generator-templates/partial_model_enum_class.mustache +20 -0
  131. data/openapi-generator-templates/partial_model_generic.mustache +371 -0
  132. data/openapi-generator-templates/partial_model_generic_doc.mustache +28 -0
  133. data/openapi-generator-templates/partial_oneof_module.mustache +137 -0
  134. data/openapi-generator-templates/partial_oneof_module_doc.mustache +92 -0
  135. data/openapi-generator-templates/rspec.mustache +2 -0
  136. data/openapi-generator-templates/rubocop.mustache +148 -0
  137. data/openapi-generator-templates/spec_helper.mustache +99 -0
  138. data/openapi-generator-templates/travis.mustache +14 -0
  139. data/openapi-generator-templates/version.mustache +3 -0
  140. data/openapitools.json +21 -0
  141. data/spec/api/films_api_spec.rb +227 -0
  142. data/spec/api/persons_api_spec.rb +45 -0
  143. data/spec/api/reviews_api_spec.rb +57 -0
  144. data/spec/api/staff_api_spec.rb +54 -0
  145. data/spec/api_client_spec.rb +229 -0
  146. data/spec/configuration_spec.rb +28 -0
  147. data/spec/models/box_office_response_spec.rb +37 -0
  148. data/spec/models/box_office_spec.rb +55 -0
  149. data/spec/models/company_spec.rb +31 -0
  150. data/spec/models/country_spec.rb +31 -0
  151. data/spec/models/digital_release_item_spec.rb +109 -0
  152. data/spec/models/digital_release_response_spec.rb +43 -0
  153. data/spec/models/distribution_response_spec.rb +37 -0
  154. data/spec/models/distribution_spec.rb +69 -0
  155. data/spec/models/episode_spec.rb +61 -0
  156. data/spec/models/fact_response_spec.rb +37 -0
  157. data/spec/models/fact_spec.rb +47 -0
  158. data/spec/models/film_search_by_filters_response_items_spec.rb +107 -0
  159. data/spec/models/film_search_by_filters_response_spec.rb +43 -0
  160. data/spec/models/film_search_response_films_spec.rb +107 -0
  161. data/spec/models/film_search_response_spec.rb +49 -0
  162. data/spec/models/film_sequels_and_prequels_response_spec.rb +71 -0
  163. data/spec/models/film_spec.rb +285 -0
  164. data/spec/models/film_top_response_films_spec.rb +91 -0
  165. data/spec/models/film_top_response_spec.rb +37 -0
  166. data/spec/models/filters_response_countries_spec.rb +37 -0
  167. data/spec/models/filters_response_genres_spec.rb +37 -0
  168. data/spec/models/filters_response_spec.rb +37 -0
  169. data/spec/models/genre_spec.rb +31 -0
  170. data/spec/models/image_response_items_spec.rb +37 -0
  171. data/spec/models/image_response_spec.rb +43 -0
  172. data/spec/models/person_by_name_response_items_spec.rb +65 -0
  173. data/spec/models/person_by_name_response_spec.rb +37 -0
  174. data/spec/models/person_response_films_spec.rb +71 -0
  175. data/spec/models/person_response_spec.rb +131 -0
  176. data/spec/models/person_response_spouses_spec.rb +77 -0
  177. data/spec/models/premiere_response_item_spec.rb +85 -0
  178. data/spec/models/premiere_response_spec.rb +37 -0
  179. data/spec/models/related_film_response_items_spec.rb +71 -0
  180. data/spec/models/related_film_response_spec.rb +37 -0
  181. data/spec/models/review_details_response_spec.rb +77 -0
  182. data/spec/models/reviews_response_reviews_spec.rb +77 -0
  183. data/spec/models/reviews_response_spec.rb +79 -0
  184. data/spec/models/season_response_spec.rb +37 -0
  185. data/spec/models/season_spec.rb +37 -0
  186. data/spec/models/staff_response_spec.rb +71 -0
  187. data/spec/models/video_response_items_spec.rb +47 -0
  188. data/spec/models/video_response_spec.rb +37 -0
  189. data/spec/spec_helper.rb +107 -0
  190. metadata +326 -0
@@ -0,0 +1,363 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+ require "time"
5
+
6
+ module Kuapir
7
+ class PersonResponse
8
+ attr_accessor :person_id, :web_url, :name_ru, :name_en, :sex, :poster_url, :growth, :birthday, :death, :age,
9
+ :birthplace, :deathplace, :has_awards, :profession, :facts, :spouses, :films
10
+
11
+ class EnumAttributeValidator
12
+ attr_reader :datatype, :allowable_values
13
+
14
+ def initialize(datatype, allowable_values)
15
+ @allowable_values = allowable_values.map do |value|
16
+ case datatype.to_s
17
+ when /Integer/i
18
+ value.to_i
19
+ when /Float/i
20
+ value.to_f
21
+ else
22
+ value
23
+ end
24
+ end
25
+ end
26
+
27
+ def valid?(value)
28
+ !value || allowable_values.include?(value)
29
+ end
30
+ end
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ 'person_id': :personId,
36
+ 'web_url': :webUrl,
37
+ 'name_ru': :nameRu,
38
+ 'name_en': :nameEn,
39
+ 'sex': :sex,
40
+ 'poster_url': :posterUrl,
41
+ 'growth': :growth,
42
+ 'birthday': :birthday,
43
+ 'death': :death,
44
+ 'age': :age,
45
+ 'birthplace': :birthplace,
46
+ 'deathplace': :deathplace,
47
+ 'has_awards': :hasAwards,
48
+ 'profession': :profession,
49
+ 'facts': :facts,
50
+ 'spouses': :spouses,
51
+ 'films': :films
52
+ }
53
+ end
54
+
55
+ # Returns all the JSON keys this model knows about
56
+ def self.acceptable_attributes
57
+ attribute_map.values
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.openapi_types
62
+ {
63
+ 'person_id': :Integer,
64
+ 'web_url': :String,
65
+ 'name_ru': :String,
66
+ 'name_en': :String,
67
+ 'sex': :String,
68
+ 'poster_url': :String,
69
+ 'growth': :String,
70
+ 'birthday': :String,
71
+ 'death': :String,
72
+ 'age': :Integer,
73
+ 'birthplace': :String,
74
+ 'deathplace': :String,
75
+ 'has_awards': :Integer,
76
+ 'profession': :String,
77
+ 'facts': :'Array<String>',
78
+ 'spouses': :'Array<PersonResponseSpouses>',
79
+ 'films': :'Array<PersonResponseFilms>'
80
+ }
81
+ end
82
+
83
+ # List of attributes with nullable: true
84
+ def self.openapi_nullable
85
+ Set.new(%i[
86
+ web_url
87
+ name_ru
88
+ name_en
89
+ sex
90
+ growth
91
+ birthday
92
+ death
93
+ age
94
+ birthplace
95
+ deathplace
96
+ has_awards
97
+ profession
98
+ ])
99
+ end
100
+
101
+ # Initializes the object
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ def initialize(attributes = {})
104
+ unless attributes.is_a?(Hash)
105
+ raise ArgumentError,
106
+ "The input argument (attributes) must be a hash in `Kuapir::PersonResponse` initialize method"
107
+ end
108
+
109
+ # check to see if the attribute exists and convert string to symbol for hash key
110
+ attributes = attributes.each_with_object({}) do |(k, v), h|
111
+ unless self.class.attribute_map.key?(k.to_sym)
112
+ raise ArgumentError,
113
+ "`#{k}` is not a valid attribute in `Kuapir::PersonResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
114
+ end
115
+
116
+ h[k.to_sym] = v
117
+ end
118
+
119
+ self.person_id = attributes[:person_id] if attributes.key?(:person_id)
120
+
121
+ self.web_url = attributes[:web_url] if attributes.key?(:web_url)
122
+
123
+ self.name_ru = attributes[:name_ru] if attributes.key?(:name_ru)
124
+
125
+ self.name_en = attributes[:name_en] if attributes.key?(:name_en)
126
+
127
+ self.sex = attributes[:sex] if attributes.key?(:sex)
128
+
129
+ self.poster_url = attributes[:poster_url] if attributes.key?(:poster_url)
130
+
131
+ self.growth = attributes[:growth] if attributes.key?(:growth)
132
+
133
+ self.birthday = attributes[:birthday] if attributes.key?(:birthday)
134
+
135
+ self.death = attributes[:death] if attributes.key?(:death)
136
+
137
+ self.age = attributes[:age] if attributes.key?(:age)
138
+
139
+ self.birthplace = attributes[:birthplace] if attributes.key?(:birthplace)
140
+
141
+ self.deathplace = attributes[:deathplace] if attributes.key?(:deathplace)
142
+
143
+ self.has_awards = attributes[:has_awards] if attributes.key?(:has_awards)
144
+
145
+ self.profession = attributes[:profession] if attributes.key?(:profession)
146
+
147
+ if attributes.key?(:facts) && (value = attributes[:facts]).is_a?(Array)
148
+ self.facts = value
149
+ end
150
+
151
+ if attributes.key?(:spouses) && (value = attributes[:spouses]).is_a?(Array)
152
+ self.spouses = value
153
+ end
154
+
155
+ if attributes.key?(:films) && (value = attributes[:films]).is_a?(Array)
156
+ self.films = value
157
+ end
158
+ end
159
+
160
+ # Show invalid properties with the reasons. Usually used together with valid?
161
+ # @return Array for valid properties with the reasons
162
+ def list_invalid_properties
163
+ invalid_properties = []
164
+ invalid_properties.push('invalid value for "person_id", person_id cannot be nil.') if @person_id.nil?
165
+
166
+ invalid_properties.push('invalid value for "poster_url", poster_url cannot be nil.') if @poster_url.nil?
167
+
168
+ invalid_properties.push('invalid value for "facts", facts cannot be nil.') if @facts.nil?
169
+
170
+ invalid_properties.push('invalid value for "spouses", spouses cannot be nil.') if @spouses.nil?
171
+
172
+ invalid_properties.push('invalid value for "films", films cannot be nil.') if @films.nil?
173
+
174
+ invalid_properties
175
+ end
176
+
177
+ # Check to see if the all the properties in the model are valid
178
+ # @return true if the model is valid
179
+ def valid?
180
+ return false if @person_id.nil?
181
+
182
+ sex_validator = EnumAttributeValidator.new("String", %w[MALE FEMALE])
183
+ return false unless sex_validator.valid?(@sex)
184
+ return false if @poster_url.nil?
185
+ return false if @facts.nil?
186
+ return false if @spouses.nil?
187
+ return false if @films.nil?
188
+
189
+ true
190
+ end
191
+
192
+ # Custom attribute writer method checking allowed values (enum).
193
+ # @param [Object] sex Object to be assigned
194
+ def sex=(sex)
195
+ validator = EnumAttributeValidator.new("String", %w[MALE FEMALE])
196
+ unless validator.valid?(sex)
197
+ raise ArgumentError,
198
+ "invalid value for \"sex\", must be one of #{validator.allowable_values}."
199
+ end
200
+
201
+ @sex = sex
202
+ end
203
+
204
+ # Checks equality by comparing each attribute.
205
+ # @param [Object] Object to be compared
206
+ def ==(other)
207
+ return true if equal?(other)
208
+
209
+ self.class == other.class &&
210
+ person_id == other.person_id &&
211
+ web_url == other.web_url &&
212
+ name_ru == other.name_ru &&
213
+ name_en == other.name_en &&
214
+ sex == other.sex &&
215
+ poster_url == other.poster_url &&
216
+ growth == other.growth &&
217
+ birthday == other.birthday &&
218
+ death == other.death &&
219
+ age == other.age &&
220
+ birthplace == other.birthplace &&
221
+ deathplace == other.deathplace &&
222
+ has_awards == other.has_awards &&
223
+ profession == other.profession &&
224
+ facts == other.facts &&
225
+ spouses == other.spouses &&
226
+ films == other.films
227
+ end
228
+
229
+ # @see the `==` method
230
+ # @param [Object] Object to be compared
231
+ def eql?(other)
232
+ self == other
233
+ end
234
+
235
+ # Calculates hash code according to all attributes.
236
+ # @return [Integer] Hash code
237
+ def hash
238
+ [person_id, web_url, name_ru, name_en, sex, poster_url, growth, birthday, death, age, birthplace, deathplace,
239
+ has_awards, profession, facts, spouses, films].hash
240
+ end
241
+
242
+ # Builds the object from hash
243
+ # @param [Hash] attributes Model attributes in the form of hash
244
+ # @return [Object] Returns the model itself
245
+ def self.build_from_hash(attributes)
246
+ new.build_from_hash(attributes)
247
+ end
248
+
249
+ # Builds the object from hash
250
+ # @param [Hash] attributes Model attributes in the form of hash
251
+ # @return [Object] Returns the model itself
252
+ def build_from_hash(attributes)
253
+ return nil unless attributes.is_a?(Hash)
254
+
255
+ self.class.openapi_types.each_pair do |key, type|
256
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
257
+ send("#{key}=", nil)
258
+ elsif type =~ /\AArray<(.*)>/i
259
+ # check to ensure the input is an array given that the attribute
260
+ # is documented as an array but the input is not
261
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
262
+ send("#{key}=", attributes[self.class.attribute_map[key]].map do |v|
263
+ _deserialize(Regexp.last_match(1), v)
264
+ end)
265
+ end
266
+ elsif !attributes[self.class.attribute_map[key]].nil?
267
+ send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
268
+ end
269
+ end
270
+
271
+ self
272
+ end
273
+
274
+ # Deserializes the data based on type
275
+ # @param string type Data type
276
+ # @param string value Value to be deserialized
277
+ # @return [Object] Deserialized data
278
+ def _deserialize(type, value)
279
+ case type.to_sym
280
+ when :Time
281
+ Time.parse(value)
282
+ when :Date
283
+ Date.parse(value)
284
+ when :String
285
+ value.to_s
286
+ when :Integer
287
+ value.to_i
288
+ when :Float
289
+ value.to_f
290
+ when :Boolean
291
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
292
+ true
293
+ else
294
+ false
295
+ end
296
+ when :Object
297
+ # generic object (usually a Hash), return directly
298
+ value
299
+ when /\AArray<(?<inner_type>.+)>\z/
300
+ inner_type = Regexp.last_match[:inner_type]
301
+ value.map { |v| _deserialize(inner_type, v) }
302
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
303
+ k_type = Regexp.last_match[:k_type]
304
+ v_type = Regexp.last_match[:v_type]
305
+ {}.tap do |hash|
306
+ value.each do |k, v|
307
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
308
+ end
309
+ end
310
+ else # model
311
+ # models (e.g. Pet) or oneOf
312
+ klass = Kuapir.const_get(type)
313
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
314
+ end
315
+ end
316
+
317
+ # Returns the string representation of the object
318
+ # @return [String] String presentation of the object
319
+ def to_s
320
+ to_hash.to_s
321
+ end
322
+
323
+ # to_body is an alias to to_hash (backward compatibility)
324
+ # @return [Hash] Returns the object in the form of hash
325
+ def to_body
326
+ to_hash
327
+ end
328
+
329
+ # Returns the object in the form of hash
330
+ # @return [Hash] Returns the object in the form of hash
331
+ def to_hash
332
+ hash = {}
333
+ self.class.attribute_map.each_pair do |attr, param|
334
+ value = send(attr)
335
+ if value.nil?
336
+ is_nullable = self.class.openapi_nullable.include?(attr)
337
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
338
+ end
339
+
340
+ hash[param] = _to_hash(value)
341
+ end
342
+ hash
343
+ end
344
+
345
+ # Outputs non-array value in the form of hash
346
+ # For object, use to_hash. Otherwise, just return the value
347
+ # @param [Object] value Any valid value
348
+ # @return [Hash] Returns the value in the form of hash
349
+ def _to_hash(value)
350
+ if value.is_a?(Array)
351
+ value.compact.map { |v| _to_hash(v) }
352
+ elsif value.is_a?(Hash)
353
+ {}.tap do |hash|
354
+ value.each { |k, v| hash[k] = _to_hash(v) }
355
+ end
356
+ elsif value.respond_to? :to_hash
357
+ value.to_hash
358
+ else
359
+ value
360
+ end
361
+ end
362
+ end
363
+ end
@@ -0,0 +1,284 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+ require "time"
5
+
6
+ module Kuapir
7
+ class PersonResponseFilms
8
+ attr_accessor :film_id, :name_ru, :name_en, :rating, :general, :description, :profession_key
9
+
10
+ class EnumAttributeValidator
11
+ attr_reader :datatype, :allowable_values
12
+
13
+ def initialize(datatype, allowable_values)
14
+ @allowable_values = allowable_values.map do |value|
15
+ case datatype.to_s
16
+ when /Integer/i
17
+ value.to_i
18
+ when /Float/i
19
+ value.to_f
20
+ else
21
+ value
22
+ end
23
+ end
24
+ end
25
+
26
+ def valid?(value)
27
+ !value || allowable_values.include?(value)
28
+ end
29
+ end
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ 'film_id': :filmId,
35
+ 'name_ru': :nameRu,
36
+ 'name_en': :nameEn,
37
+ 'rating': :rating,
38
+ 'general': :general,
39
+ 'description': :description,
40
+ 'profession_key': :professionKey
41
+ }
42
+ end
43
+
44
+ # Returns all the JSON keys this model knows about
45
+ def self.acceptable_attributes
46
+ attribute_map.values
47
+ end
48
+
49
+ # Attribute type mapping.
50
+ def self.openapi_types
51
+ {
52
+ 'film_id': :Integer,
53
+ 'name_ru': :String,
54
+ 'name_en': :String,
55
+ 'rating': :String,
56
+ 'general': :Boolean,
57
+ 'description': :String,
58
+ 'profession_key': :String
59
+ }
60
+ end
61
+
62
+ # List of attributes with nullable: true
63
+ def self.openapi_nullable
64
+ Set.new(%i[
65
+ name_ru
66
+ name_en
67
+ rating
68
+ description
69
+ ])
70
+ end
71
+
72
+ # Initializes the object
73
+ # @param [Hash] attributes Model attributes in the form of hash
74
+ def initialize(attributes = {})
75
+ unless attributes.is_a?(Hash)
76
+ raise ArgumentError,
77
+ "The input argument (attributes) must be a hash in `Kuapir::PersonResponseFilms` initialize method"
78
+ end
79
+
80
+ # check to see if the attribute exists and convert string to symbol for hash key
81
+ attributes = attributes.each_with_object({}) do |(k, v), h|
82
+ unless self.class.attribute_map.key?(k.to_sym)
83
+ raise ArgumentError,
84
+ "`#{k}` is not a valid attribute in `Kuapir::PersonResponseFilms`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
85
+ end
86
+
87
+ h[k.to_sym] = v
88
+ end
89
+
90
+ self.film_id = attributes[:film_id] if attributes.key?(:film_id)
91
+
92
+ self.name_ru = attributes[:name_ru] if attributes.key?(:name_ru)
93
+
94
+ self.name_en = attributes[:name_en] if attributes.key?(:name_en)
95
+
96
+ self.rating = attributes[:rating] if attributes.key?(:rating)
97
+
98
+ self.general = attributes[:general] if attributes.key?(:general)
99
+
100
+ self.description = attributes[:description] if attributes.key?(:description)
101
+
102
+ self.profession_key = attributes[:profession_key] if attributes.key?(:profession_key)
103
+ end
104
+
105
+ # Show invalid properties with the reasons. Usually used together with valid?
106
+ # @return Array for valid properties with the reasons
107
+ def list_invalid_properties
108
+ []
109
+ end
110
+
111
+ # Check to see if the all the properties in the model are valid
112
+ # @return true if the model is valid
113
+ def valid?
114
+ profession_key_validator = EnumAttributeValidator.new("String",
115
+ %w[WRITER OPERATOR EDITOR COMPOSER PRODUCER_USSR HIMSELF HERSELF HRONO_TITR_MALE HRONO_TITR_FEMALE TRANSLATOR DIRECTOR
116
+ DESIGN PRODUCER ACTOR VOICE_DIRECTOR UNKNOWN])
117
+ return false unless profession_key_validator.valid?(@profession_key)
118
+
119
+ true
120
+ end
121
+
122
+ # Custom attribute writer method checking allowed values (enum).
123
+ # @param [Object] profession_key Object to be assigned
124
+ def profession_key=(profession_key)
125
+ validator = EnumAttributeValidator.new("String",
126
+ %w[WRITER OPERATOR EDITOR COMPOSER PRODUCER_USSR HIMSELF HERSELF HRONO_TITR_MALE HRONO_TITR_FEMALE TRANSLATOR DIRECTOR
127
+ DESIGN PRODUCER ACTOR VOICE_DIRECTOR UNKNOWN])
128
+ unless validator.valid?(profession_key)
129
+ raise ArgumentError,
130
+ "invalid value for \"profession_key\", must be one of #{validator.allowable_values}."
131
+ end
132
+
133
+ @profession_key = profession_key
134
+ end
135
+
136
+ # Checks equality by comparing each attribute.
137
+ # @param [Object] Object to be compared
138
+ def ==(other)
139
+ return true if equal?(other)
140
+
141
+ self.class == other.class &&
142
+ film_id == other.film_id &&
143
+ name_ru == other.name_ru &&
144
+ name_en == other.name_en &&
145
+ rating == other.rating &&
146
+ general == other.general &&
147
+ description == other.description &&
148
+ profession_key == other.profession_key
149
+ end
150
+
151
+ # @see the `==` method
152
+ # @param [Object] Object to be compared
153
+ def eql?(other)
154
+ self == other
155
+ end
156
+
157
+ # Calculates hash code according to all attributes.
158
+ # @return [Integer] Hash code
159
+ def hash
160
+ [film_id, name_ru, name_en, rating, general, description, profession_key].hash
161
+ end
162
+
163
+ # Builds the object from hash
164
+ # @param [Hash] attributes Model attributes in the form of hash
165
+ # @return [Object] Returns the model itself
166
+ def self.build_from_hash(attributes)
167
+ new.build_from_hash(attributes)
168
+ end
169
+
170
+ # Builds the object from hash
171
+ # @param [Hash] attributes Model attributes in the form of hash
172
+ # @return [Object] Returns the model itself
173
+ def build_from_hash(attributes)
174
+ return nil unless attributes.is_a?(Hash)
175
+
176
+ self.class.openapi_types.each_pair do |key, type|
177
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
178
+ send("#{key}=", nil)
179
+ elsif type =~ /\AArray<(.*)>/i
180
+ # check to ensure the input is an array given that the attribute
181
+ # is documented as an array but the input is not
182
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
183
+ send("#{key}=", attributes[self.class.attribute_map[key]].map do |v|
184
+ _deserialize(Regexp.last_match(1), v)
185
+ end)
186
+ end
187
+ elsif !attributes[self.class.attribute_map[key]].nil?
188
+ send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
189
+ end
190
+ end
191
+
192
+ self
193
+ end
194
+
195
+ # Deserializes the data based on type
196
+ # @param string type Data type
197
+ # @param string value Value to be deserialized
198
+ # @return [Object] Deserialized data
199
+ def _deserialize(type, value)
200
+ case type.to_sym
201
+ when :Time
202
+ Time.parse(value)
203
+ when :Date
204
+ Date.parse(value)
205
+ when :String
206
+ value.to_s
207
+ when :Integer
208
+ value.to_i
209
+ when :Float
210
+ value.to_f
211
+ when :Boolean
212
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
213
+ true
214
+ else
215
+ false
216
+ end
217
+ when :Object
218
+ # generic object (usually a Hash), return directly
219
+ value
220
+ when /\AArray<(?<inner_type>.+)>\z/
221
+ inner_type = Regexp.last_match[:inner_type]
222
+ value.map { |v| _deserialize(inner_type, v) }
223
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
224
+ k_type = Regexp.last_match[:k_type]
225
+ v_type = Regexp.last_match[:v_type]
226
+ {}.tap do |hash|
227
+ value.each do |k, v|
228
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
229
+ end
230
+ end
231
+ else # model
232
+ # models (e.g. Pet) or oneOf
233
+ klass = Kuapir.const_get(type)
234
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
235
+ end
236
+ end
237
+
238
+ # Returns the string representation of the object
239
+ # @return [String] String presentation of the object
240
+ def to_s
241
+ to_hash.to_s
242
+ end
243
+
244
+ # to_body is an alias to to_hash (backward compatibility)
245
+ # @return [Hash] Returns the object in the form of hash
246
+ def to_body
247
+ to_hash
248
+ end
249
+
250
+ # Returns the object in the form of hash
251
+ # @return [Hash] Returns the object in the form of hash
252
+ def to_hash
253
+ hash = {}
254
+ self.class.attribute_map.each_pair do |attr, param|
255
+ value = send(attr)
256
+ if value.nil?
257
+ is_nullable = self.class.openapi_nullable.include?(attr)
258
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
259
+ end
260
+
261
+ hash[param] = _to_hash(value)
262
+ end
263
+ hash
264
+ end
265
+
266
+ # Outputs non-array value in the form of hash
267
+ # For object, use to_hash. Otherwise, just return the value
268
+ # @param [Object] value Any valid value
269
+ # @return [Hash] Returns the value in the form of hash
270
+ def _to_hash(value)
271
+ if value.is_a?(Array)
272
+ value.compact.map { |v| _to_hash(v) }
273
+ elsif value.is_a?(Hash)
274
+ {}.tap do |hash|
275
+ value.each { |k, v| hash[k] = _to_hash(v) }
276
+ end
277
+ elsif value.respond_to? :to_hash
278
+ value.to_hash
279
+ else
280
+ value
281
+ end
282
+ end
283
+ end
284
+ end