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,287 @@
1
+ # frozen_string_literal: true
2
+
3
+ # #Kinopoisk Unofficial API
4
+ #
5
+ #
6
+ #
7
+ # The version of the OpenAPI document: 2.0.1
8
+ # Contact: support@kinopoiskapiunofficial.tech
9
+ # Generated by: https://openapi-generator.tech
10
+ # OpenAPI Generator version: 5.3.1
11
+ #
12
+
13
+ module Kuapir
14
+ class Configuration
15
+ # Defines url scheme
16
+ attr_accessor :scheme
17
+
18
+ # Defines url host
19
+ attr_accessor :host
20
+
21
+ # Defines url base path
22
+ attr_accessor :base_path
23
+
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
36
+ # Defines API keys used with API Key authentications.
37
+ #
38
+ # @return [Hash] key: parameter name, value: parameter value (API key)
39
+ #
40
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
41
+ # config.api_key['api_key'] = 'xxx'
42
+ attr_accessor :api_key
43
+
44
+ # Defines API key prefixes used with API Key authentications.
45
+ #
46
+ # @return [Hash] key: parameter name, value: API key prefix
47
+ #
48
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
49
+ # config.api_key_prefix['api_key'] = 'Token'
50
+ attr_accessor :api_key_prefix
51
+
52
+ # Defines the username used with HTTP basic authentication.
53
+ #
54
+ # @return [String]
55
+ attr_accessor :username
56
+
57
+ # Defines the password used with HTTP basic authentication.
58
+ #
59
+ # @return [String]
60
+ attr_accessor :password
61
+
62
+ # Defines the proxy used for HTTP requests
63
+ #
64
+ # Only http/https proxy supported
65
+ #
66
+ # @return [String]
67
+ attr_accessor :proxy
68
+
69
+ # Defines the access token (Bearer) used with OAuth2.
70
+ attr_accessor :access_token
71
+
72
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
73
+ # details will be logged with `logger.debug` (see the `logger` attribute).
74
+ # Default to false.
75
+ #
76
+ # @return [true, false]
77
+ attr_accessor :debugging
78
+
79
+ # Defines the logger used for debugging.
80
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
81
+ #
82
+ # @return [#debug]
83
+ attr_accessor :logger
84
+
85
+ # Defines the temporary folder to store downloaded files
86
+ # (for API endpoints that have file response).
87
+ # Default to use `Tempfile`.
88
+ #
89
+ # @return [String]
90
+ attr_accessor :temp_folder_path
91
+
92
+ # The time limit for HTTP request in seconds.
93
+ # Default to 0 (never times out).
94
+ attr_accessor :timeout
95
+
96
+ # Set this to false to skip client side validation in the operation.
97
+ # Default to true.
98
+ # @return [true, false]
99
+ attr_accessor :client_side_validation
100
+
101
+ ### TLS/SSL setting
102
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
103
+ # Default to true.
104
+ #
105
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
106
+ #
107
+ # @return [true, false]
108
+ attr_accessor :verify_ssl
109
+
110
+ ### TLS/SSL setting
111
+ # Set this to false to skip verifying SSL host name
112
+ # Default to true.
113
+ #
114
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
115
+ #
116
+ # @return [true, false]
117
+ attr_accessor :verify_ssl_host
118
+
119
+ ### TLS/SSL setting
120
+ # Set this to customize the certificate file to verify the peer.
121
+ #
122
+ # @return [String] the path to the certificate file
123
+ #
124
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
125
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
126
+ attr_accessor :ssl_ca_cert
127
+
128
+ ### TLS/SSL setting
129
+ # Client certificate file (for client certificate)
130
+ attr_accessor :cert_file
131
+
132
+ ### TLS/SSL setting
133
+ # Client private key file (for client certificate)
134
+ attr_accessor :key_file
135
+
136
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
137
+ # Default to nil.
138
+ #
139
+ # @see The params_encoding option of Ethon. Related source code:
140
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
141
+ attr_accessor :params_encoding
142
+
143
+ attr_accessor :inject_format, :force_ending_format
144
+
145
+ def initialize
146
+ @scheme = "https"
147
+ @host = "kinopoiskapiunofficial.tech"
148
+ @base_path = ""
149
+ @proxy = nil
150
+ @server_index = 0
151
+ @server_operation_index = {}
152
+ @server_variables = {}
153
+ @server_operation_variables = {}
154
+ @api_key = {}
155
+ @api_key_prefix = {}
156
+ @client_side_validation = true
157
+ @verify_ssl = true
158
+ @verify_ssl_host = true
159
+ @params_encoding = nil
160
+ @cert_file = nil
161
+ @key_file = nil
162
+ @timeout = 0
163
+ @debugging = false
164
+ @inject_format = false
165
+ @force_ending_format = false
166
+ @logger = defined?(Rails) ? Rails.logger : Logger.new($stdout)
167
+
168
+ yield(self) if block_given?
169
+ end
170
+
171
+ # The default Configuration object.
172
+ def self.default
173
+ @@default ||= Configuration.new
174
+ end
175
+
176
+ def configure
177
+ yield(self) if block_given?
178
+ end
179
+
180
+ def scheme=(scheme)
181
+ # remove :// from scheme
182
+ @scheme = scheme.sub(%r{://}, "")
183
+ end
184
+
185
+ def host=(host)
186
+ # remove http(s):// and anything after a slash
187
+ @host = host.sub(%r{https?://}, "").split("/").first
188
+ end
189
+
190
+ def base_path=(base_path)
191
+ # Add leading and trailing slashes to base_path
192
+ @base_path = "/#{base_path}".gsub(%r{/+}, "/")
193
+ @base_path = "" if @base_path == "/"
194
+ end
195
+
196
+ # Returns base URL for specified operation based on server settings
197
+ def base_url(operation = nil)
198
+ index = server_operation_index.fetch(operation, server_index)
199
+ return "#{scheme}://#{[host, base_path].join('/').gsub(%r{/+}, '/')}".sub(%r{/+\z}, "") if index.nil?
200
+
201
+ server_url(index, server_operation_variables.fetch(operation, server_variables),
202
+ operation_server_settings[operation])
203
+ end
204
+
205
+ # Gets API key (with prefix if set).
206
+ # @param [String] param_name the parameter name of API key auth
207
+ def api_key_with_prefix(param_name, param_alias = nil)
208
+ key = @api_key[param_name]
209
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
210
+ if @api_key_prefix[param_name]
211
+ "#{@api_key_prefix[param_name]} #{key}"
212
+ else
213
+ key
214
+ end
215
+ end
216
+
217
+ # Gets Basic Auth token string
218
+ def basic_auth_token
219
+ "Basic #{["#{username}:#{password}"].pack('m').delete("\r\n")}"
220
+ end
221
+
222
+ # Returns Auth Settings hash for api client.
223
+ def auth_settings
224
+ {
225
+ "ApiKeyAuth" =>
226
+ {
227
+ type: "api_key",
228
+ in: "header",
229
+ key: "X-API-KEY",
230
+ value: api_key_with_prefix("ApiKeyAuth")
231
+ }
232
+ }
233
+ end
234
+
235
+ # Returns an array of Server setting
236
+ def server_settings
237
+ [
238
+ {
239
+ url: "https://kinopoiskapiunofficial.tech",
240
+ description: "Main (production) server"
241
+ }
242
+ ]
243
+ end
244
+
245
+ def operation_server_settings
246
+ {
247
+ }
248
+ end
249
+
250
+ # Returns URL based on server settings
251
+ #
252
+ # @param index array index of the server settings
253
+ # @param variables hash of variable and the corresponding value
254
+ def server_url(index, variables = {}, servers = nil)
255
+ servers = server_settings if servers.nil?
256
+
257
+ # check array index out of bound
258
+ if index.negative? || index >= servers.size
259
+ raise ArgumentError,
260
+ "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
261
+ end
262
+
263
+ server = servers[index]
264
+ url = server[:url]
265
+
266
+ return url unless server.key? :variables
267
+
268
+ # go through variable and assign a value
269
+ server[:variables].each do |name, _variable|
270
+ if variables.key?(name)
271
+ if !server[:variables][name].key?(:enum_values) ||
272
+ server[:variables][name][:enum_values].include?(variables[name])
273
+ url.gsub! "{#{name}}", variables[name]
274
+ else
275
+ raise ArgumentError,
276
+ "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
277
+ end
278
+ else
279
+ # use default value
280
+ url.gsub! "{#{name}}", server[:variables][name][:default_value]
281
+ end
282
+ end
283
+
284
+ url
285
+ end
286
+ end
287
+ end
@@ -0,0 +1,246 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "date"
4
+ require "time"
5
+
6
+ module Kuapir
7
+ class BoxOffice
8
+ attr_accessor :type, :amount, :currency_code, :name, :symbol
9
+
10
+ # Attribute mapping from ruby-style variable name to JSON key.
11
+ def self.attribute_map
12
+ {
13
+ 'type': :type,
14
+ 'amount': :amount,
15
+ 'currency_code': :currencyCode,
16
+ 'name': :name,
17
+ 'symbol': :symbol
18
+ }
19
+ end
20
+
21
+ # Returns all the JSON keys this model knows about
22
+ def self.acceptable_attributes
23
+ attribute_map.values
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.openapi_types
28
+ {
29
+ 'type': :String,
30
+ 'amount': :Integer,
31
+ 'currency_code': :String,
32
+ 'name': :String,
33
+ 'symbol': :String
34
+ }
35
+ end
36
+
37
+ # List of attributes with nullable: true
38
+ def self.openapi_nullable
39
+ Set.new([])
40
+ end
41
+
42
+ # Initializes the object
43
+ # @param [Hash] attributes Model attributes in the form of hash
44
+ def initialize(attributes = {})
45
+ unless attributes.is_a?(Hash)
46
+ raise ArgumentError,
47
+ "The input argument (attributes) must be a hash in `Kuapir::BoxOffice` initialize method"
48
+ end
49
+
50
+ # check to see if the attribute exists and convert string to symbol for hash key
51
+ attributes = attributes.each_with_object({}) do |(k, v), h|
52
+ unless self.class.attribute_map.key?(k.to_sym)
53
+ raise ArgumentError,
54
+ "`#{k}` is not a valid attribute in `Kuapir::BoxOffice`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
55
+ end
56
+
57
+ h[k.to_sym] = v
58
+ end
59
+
60
+ self.type = attributes[:type] if attributes.key?(:type)
61
+
62
+ self.amount = attributes[:amount] if attributes.key?(:amount)
63
+
64
+ self.currency_code = attributes[:currency_code] if attributes.key?(:currency_code)
65
+
66
+ self.name = attributes[:name] if attributes.key?(:name)
67
+
68
+ self.symbol = attributes[:symbol] if attributes.key?(:symbol)
69
+ end
70
+
71
+ # Show invalid properties with the reasons. Usually used together with valid?
72
+ # @return Array for valid properties with the reasons
73
+ def list_invalid_properties
74
+ invalid_properties = []
75
+ invalid_properties.push('invalid value for "type", type cannot be nil.') if @type.nil?
76
+
77
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.') if @amount.nil?
78
+
79
+ invalid_properties.push('invalid value for "currency_code", currency_code cannot be nil.') if @currency_code.nil?
80
+
81
+ invalid_properties.push('invalid value for "name", name cannot be nil.') if @name.nil?
82
+
83
+ invalid_properties.push('invalid value for "symbol", symbol cannot be nil.') if @symbol.nil?
84
+
85
+ invalid_properties
86
+ end
87
+
88
+ # Check to see if the all the properties in the model are valid
89
+ # @return true if the model is valid
90
+ def valid?
91
+ return false if @type.nil?
92
+ return false if @amount.nil?
93
+ return false if @currency_code.nil?
94
+ return false if @name.nil?
95
+ return false if @symbol.nil?
96
+
97
+ true
98
+ end
99
+
100
+ # Checks equality by comparing each attribute.
101
+ # @param [Object] Object to be compared
102
+ def ==(other)
103
+ return true if equal?(other)
104
+
105
+ self.class == other.class &&
106
+ type == other.type &&
107
+ amount == other.amount &&
108
+ currency_code == other.currency_code &&
109
+ name == other.name &&
110
+ symbol == other.symbol
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(other)
116
+ self == other
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [type, amount, currency_code, name, symbol].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ new.build_from_hash(attributes)
130
+ end
131
+
132
+ # Builds the object from hash
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ # @return [Object] Returns the model itself
135
+ def build_from_hash(attributes)
136
+ return nil unless attributes.is_a?(Hash)
137
+
138
+ self.class.openapi_types.each_pair do |key, type|
139
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
140
+ send("#{key}=", nil)
141
+ elsif type =~ /\AArray<(.*)>/i
142
+ # check to ensure the input is an array given that the attribute
143
+ # is documented as an array but the input is not
144
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
145
+ send("#{key}=", attributes[self.class.attribute_map[key]].map do |v|
146
+ _deserialize(Regexp.last_match(1), v)
147
+ end)
148
+ end
149
+ elsif !attributes[self.class.attribute_map[key]].nil?
150
+ send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
151
+ end
152
+ end
153
+
154
+ self
155
+ end
156
+
157
+ # Deserializes the data based on type
158
+ # @param string type Data type
159
+ # @param string value Value to be deserialized
160
+ # @return [Object] Deserialized data
161
+ def _deserialize(type, value)
162
+ case type.to_sym
163
+ when :Time
164
+ Time.parse(value)
165
+ when :Date
166
+ Date.parse(value)
167
+ when :String
168
+ value.to_s
169
+ when :Integer
170
+ value.to_i
171
+ when :Float
172
+ value.to_f
173
+ when :Boolean
174
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
175
+ true
176
+ else
177
+ false
178
+ end
179
+ when :Object
180
+ # generic object (usually a Hash), return directly
181
+ value
182
+ when /\AArray<(?<inner_type>.+)>\z/
183
+ inner_type = Regexp.last_match[:inner_type]
184
+ value.map { |v| _deserialize(inner_type, v) }
185
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
186
+ k_type = Regexp.last_match[:k_type]
187
+ v_type = Regexp.last_match[:v_type]
188
+ {}.tap do |hash|
189
+ value.each do |k, v|
190
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
191
+ end
192
+ end
193
+ else # model
194
+ # models (e.g. Pet) or oneOf
195
+ klass = Kuapir.const_get(type)
196
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
197
+ end
198
+ end
199
+
200
+ # Returns the string representation of the object
201
+ # @return [String] String presentation of the object
202
+ def to_s
203
+ to_hash.to_s
204
+ end
205
+
206
+ # to_body is an alias to to_hash (backward compatibility)
207
+ # @return [Hash] Returns the object in the form of hash
208
+ def to_body
209
+ to_hash
210
+ end
211
+
212
+ # Returns the object in the form of hash
213
+ # @return [Hash] Returns the object in the form of hash
214
+ def to_hash
215
+ hash = {}
216
+ self.class.attribute_map.each_pair do |attr, param|
217
+ value = send(attr)
218
+ if value.nil?
219
+ is_nullable = self.class.openapi_nullable.include?(attr)
220
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
221
+ end
222
+
223
+ hash[param] = _to_hash(value)
224
+ end
225
+ hash
226
+ end
227
+
228
+ # Outputs non-array value in the form of hash
229
+ # For object, use to_hash. Otherwise, just return the value
230
+ # @param [Object] value Any valid value
231
+ # @return [Hash] Returns the value in the form of hash
232
+ def _to_hash(value)
233
+ if value.is_a?(Array)
234
+ value.compact.map { |v| _to_hash(v) }
235
+ elsif value.is_a?(Hash)
236
+ {}.tap do |hash|
237
+ value.each { |k, v| hash[k] = _to_hash(v) }
238
+ end
239
+ elsif value.respond_to? :to_hash
240
+ value.to_hash
241
+ else
242
+ value
243
+ end
244
+ end
245
+ end
246
+ end