cheminee 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +72 -0
  4. data/README.md +112 -0
  5. data/Rakefile +10 -0
  6. data/cheminee.gemspec +39 -0
  7. data/docs/BulkRequest.md +18 -0
  8. data/docs/BulkRequestDoc.md +20 -0
  9. data/docs/CreateIndexError.md +18 -0
  10. data/docs/DefaultApi.md +529 -0
  11. data/docs/GetIndexesResponseError.md +18 -0
  12. data/docs/IndexMeta.md +20 -0
  13. data/docs/IndexSchema.md +20 -0
  14. data/docs/ListIndexResponseErr.md +18 -0
  15. data/docs/PostIndexBulkResponseError.md +18 -0
  16. data/docs/PostIndexBulkResponseOk.md +18 -0
  17. data/docs/PostIndexBulkResponseOkStatus.md +20 -0
  18. data/docs/QueryResponseError.md +18 -0
  19. data/docs/QuerySearchHit.md +22 -0
  20. data/docs/Schema.md +20 -0
  21. data/docs/Smile.md +18 -0
  22. data/docs/Smiles.md +18 -0
  23. data/docs/StandardizedSmile.md +20 -0
  24. data/docs/StandardizedSmiles.md +20 -0
  25. data/docs/StructureResponseError.md +18 -0
  26. data/docs/StructureSearchHit.md +26 -0
  27. data/docs/SubstructureSearchHit.md +24 -0
  28. data/git_push.sh +57 -0
  29. data/lib/cheminee/api/default_api.rb +550 -0
  30. data/lib/cheminee/api_client.rb +393 -0
  31. data/lib/cheminee/api_error.rb +58 -0
  32. data/lib/cheminee/configuration.rb +291 -0
  33. data/lib/cheminee/models/bulk_request.rb +223 -0
  34. data/lib/cheminee/models/bulk_request_doc.rb +232 -0
  35. data/lib/cheminee/models/create_index_error.rb +221 -0
  36. data/lib/cheminee/models/get_indexes_response_error.rb +221 -0
  37. data/lib/cheminee/models/index_meta.rb +237 -0
  38. data/lib/cheminee/models/index_schema.rb +233 -0
  39. data/lib/cheminee/models/list_index_response_err.rb +221 -0
  40. data/lib/cheminee/models/post_index_bulk_response_error.rb +221 -0
  41. data/lib/cheminee/models/post_index_bulk_response_ok.rb +223 -0
  42. data/lib/cheminee/models/post_index_bulk_response_ok_status.rb +223 -0
  43. data/lib/cheminee/models/query_response_error.rb +221 -0
  44. data/lib/cheminee/models/query_search_hit.rb +249 -0
  45. data/lib/cheminee/models/schema.rb +233 -0
  46. data/lib/cheminee/models/smile.rb +221 -0
  47. data/lib/cheminee/models/smiles.rb +221 -0
  48. data/lib/cheminee/models/standardized_smile.rb +223 -0
  49. data/lib/cheminee/models/standardized_smiles.rb +223 -0
  50. data/lib/cheminee/models/structure_response_error.rb +221 -0
  51. data/lib/cheminee/models/structure_search_hit.rb +281 -0
  52. data/lib/cheminee/models/substructure_search_hit.rb +265 -0
  53. data/lib/cheminee/version.rb +15 -0
  54. data/lib/cheminee.rb +57 -0
  55. data/openapi-generator-config.json +7 -0
  56. data/openapi.json +77 -0
  57. data/pkg/cheminee-0.0.14.gem +0 -0
  58. data/spec/api/default_api_spec.rb +45 -0
  59. data/spec/api_client_spec.rb +228 -0
  60. data/spec/configuration_spec.rb +42 -0
  61. data/spec/models/bulk_request_doc_spec.rb +42 -0
  62. data/spec/models/bulk_request_spec.rb +36 -0
  63. data/spec/models/create_index_error_spec.rb +36 -0
  64. data/spec/models/get_indexes_response_error_spec.rb +36 -0
  65. data/spec/models/index_meta_spec.rb +42 -0
  66. data/spec/models/index_schema_spec.rb +42 -0
  67. data/spec/models/list_index_response_err_spec.rb +36 -0
  68. data/spec/models/post_index_bulk_response_error_spec.rb +36 -0
  69. data/spec/models/post_index_bulk_response_ok_spec.rb +36 -0
  70. data/spec/models/post_index_bulk_response_ok_status_spec.rb +42 -0
  71. data/spec/models/query_response_error_spec.rb +36 -0
  72. data/spec/models/query_search_hit_spec.rb +48 -0
  73. data/spec/models/schema_spec.rb +42 -0
  74. data/spec/models/smile_spec.rb +34 -0
  75. data/spec/models/smiles_spec.rb +36 -0
  76. data/spec/models/standardized_smile_spec.rb +40 -0
  77. data/spec/models/standardized_smiles_spec.rb +42 -0
  78. data/spec/models/structure_response_error_spec.rb +36 -0
  79. data/spec/models/structure_search_hit_spec.rb +60 -0
  80. data/spec/models/substructure_search_hit_spec.rb +54 -0
  81. data/spec/spec_helper.rb +111 -0
  82. metadata +187 -0
@@ -0,0 +1,221 @@
1
+ =begin
2
+ #Cheminée
3
+
4
+ #Cheminée: The Chemical Structure Search Engine
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.3.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Cheminee
17
+ class QueryResponseError
18
+ attr_accessor :error
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'error' => :'error'
24
+ }
25
+ end
26
+
27
+ # Returns all the JSON keys this model knows about
28
+ def self.acceptable_attributes
29
+ attribute_map.values
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'error' => :'String'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Cheminee::QueryResponseError` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Cheminee::QueryResponseError`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'error')
61
+ self.error = attributes[:'error']
62
+ else
63
+ self.error = nil
64
+ end
65
+ end
66
+
67
+ # Show invalid properties with the reasons. Usually used together with valid?
68
+ # @return Array for valid properties with the reasons
69
+ def list_invalid_properties
70
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
71
+ invalid_properties = Array.new
72
+ if @error.nil?
73
+ invalid_properties.push('invalid value for "error", error cannot be nil.')
74
+ end
75
+
76
+ invalid_properties
77
+ end
78
+
79
+ # Check to see if the all the properties in the model are valid
80
+ # @return true if the model is valid
81
+ def valid?
82
+ warn '[DEPRECATED] the `valid?` method is obsolete'
83
+ return false if @error.nil?
84
+ true
85
+ end
86
+
87
+ # Checks equality by comparing each attribute.
88
+ # @param [Object] Object to be compared
89
+ def ==(o)
90
+ return true if self.equal?(o)
91
+ self.class == o.class &&
92
+ error == o.error
93
+ end
94
+
95
+ # @see the `==` method
96
+ # @param [Object] Object to be compared
97
+ def eql?(o)
98
+ self == o
99
+ end
100
+
101
+ # Calculates hash code according to all attributes.
102
+ # @return [Integer] Hash code
103
+ def hash
104
+ [error].hash
105
+ end
106
+
107
+ # Builds the object from hash
108
+ # @param [Hash] attributes Model attributes in the form of hash
109
+ # @return [Object] Returns the model itself
110
+ def self.build_from_hash(attributes)
111
+ return nil unless attributes.is_a?(Hash)
112
+ attributes = attributes.transform_keys(&:to_sym)
113
+ transformed_hash = {}
114
+ openapi_types.each_pair do |key, type|
115
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
116
+ transformed_hash["#{key}"] = nil
117
+ elsif type =~ /\AArray<(.*)>/i
118
+ # check to ensure the input is an array given that the attribute
119
+ # is documented as an array but the input is not
120
+ if attributes[attribute_map[key]].is_a?(Array)
121
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
122
+ end
123
+ elsif !attributes[attribute_map[key]].nil?
124
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
125
+ end
126
+ end
127
+ new(transformed_hash)
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def self._deserialize(type, value)
135
+ case type.to_sym
136
+ when :Time
137
+ Time.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :Boolean
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ # models (e.g. Pet) or oneOf
168
+ klass = Cheminee.const_get(type)
169
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
170
+ end
171
+ end
172
+
173
+ # Returns the string representation of the object
174
+ # @return [String] String presentation of the object
175
+ def to_s
176
+ to_hash.to_s
177
+ end
178
+
179
+ # to_body is an alias to to_hash (backward compatibility)
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_body
182
+ to_hash
183
+ end
184
+
185
+ # Returns the object in the form of hash
186
+ # @return [Hash] Returns the object in the form of hash
187
+ def to_hash
188
+ hash = {}
189
+ self.class.attribute_map.each_pair do |attr, param|
190
+ value = self.send(attr)
191
+ if value.nil?
192
+ is_nullable = self.class.openapi_nullable.include?(attr)
193
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
194
+ end
195
+
196
+ hash[param] = _to_hash(value)
197
+ end
198
+ hash
199
+ end
200
+
201
+ # Outputs non-array value in the form of hash
202
+ # For object, use to_hash. Otherwise, just return the value
203
+ # @param [Object] value Any valid value
204
+ # @return [Hash] Returns the value in the form of hash
205
+ def _to_hash(value)
206
+ if value.is_a?(Array)
207
+ value.compact.map { |v| _to_hash(v) }
208
+ elsif value.is_a?(Hash)
209
+ {}.tap do |hash|
210
+ value.each { |k, v| hash[k] = _to_hash(v) }
211
+ end
212
+ elsif value.respond_to? :to_hash
213
+ value.to_hash
214
+ else
215
+ value
216
+ end
217
+ end
218
+
219
+ end
220
+
221
+ end
@@ -0,0 +1,249 @@
1
+ =begin
2
+ #Cheminée
3
+
4
+ #Cheminée: The Chemical Structure Search Engine
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.3.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Cheminee
17
+ class QuerySearchHit
18
+ attr_accessor :extra_data
19
+
20
+ attr_accessor :smiles
21
+
22
+ attr_accessor :query
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'extra_data' => :'extra_data',
28
+ :'smiles' => :'smiles',
29
+ :'query' => :'query'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'extra_data' => :'Object',
42
+ :'smiles' => :'String',
43
+ :'query' => :'String'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ :'extra_data',
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Cheminee::QuerySearchHit` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Cheminee::QuerySearchHit`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
68
+
69
+ if attributes.key?(:'extra_data')
70
+ self.extra_data = attributes[:'extra_data']
71
+ else
72
+ self.extra_data = nil
73
+ end
74
+
75
+ if attributes.key?(:'smiles')
76
+ self.smiles = attributes[:'smiles']
77
+ else
78
+ self.smiles = nil
79
+ end
80
+
81
+ if attributes.key?(:'query')
82
+ self.query = attributes[:'query']
83
+ else
84
+ self.query = nil
85
+ end
86
+ end
87
+
88
+ # Show invalid properties with the reasons. Usually used together with valid?
89
+ # @return Array for valid properties with the reasons
90
+ def list_invalid_properties
91
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
92
+ invalid_properties = Array.new
93
+ if @smiles.nil?
94
+ invalid_properties.push('invalid value for "smiles", smiles cannot be nil.')
95
+ end
96
+
97
+ if @query.nil?
98
+ invalid_properties.push('invalid value for "query", query cannot be nil.')
99
+ end
100
+
101
+ invalid_properties
102
+ end
103
+
104
+ # Check to see if the all the properties in the model are valid
105
+ # @return true if the model is valid
106
+ def valid?
107
+ warn '[DEPRECATED] the `valid?` method is obsolete'
108
+ return false if @smiles.nil?
109
+ return false if @query.nil?
110
+ true
111
+ end
112
+
113
+ # Checks equality by comparing each attribute.
114
+ # @param [Object] Object to be compared
115
+ def ==(o)
116
+ return true if self.equal?(o)
117
+ self.class == o.class &&
118
+ extra_data == o.extra_data &&
119
+ smiles == o.smiles &&
120
+ query == o.query
121
+ end
122
+
123
+ # @see the `==` method
124
+ # @param [Object] Object to be compared
125
+ def eql?(o)
126
+ self == o
127
+ end
128
+
129
+ # Calculates hash code according to all attributes.
130
+ # @return [Integer] Hash code
131
+ def hash
132
+ [extra_data, smiles, query].hash
133
+ end
134
+
135
+ # Builds the object from hash
136
+ # @param [Hash] attributes Model attributes in the form of hash
137
+ # @return [Object] Returns the model itself
138
+ def self.build_from_hash(attributes)
139
+ return nil unless attributes.is_a?(Hash)
140
+ attributes = attributes.transform_keys(&:to_sym)
141
+ transformed_hash = {}
142
+ openapi_types.each_pair do |key, type|
143
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
144
+ transformed_hash["#{key}"] = nil
145
+ elsif type =~ /\AArray<(.*)>/i
146
+ # check to ensure the input is an array given that the attribute
147
+ # is documented as an array but the input is not
148
+ if attributes[attribute_map[key]].is_a?(Array)
149
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
150
+ end
151
+ elsif !attributes[attribute_map[key]].nil?
152
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
153
+ end
154
+ end
155
+ new(transformed_hash)
156
+ end
157
+
158
+ # Deserializes the data based on type
159
+ # @param string type Data type
160
+ # @param string value Value to be deserialized
161
+ # @return [Object] Deserialized data
162
+ def self._deserialize(type, value)
163
+ case type.to_sym
164
+ when :Time
165
+ Time.parse(value)
166
+ when :Date
167
+ Date.parse(value)
168
+ when :String
169
+ value.to_s
170
+ when :Integer
171
+ value.to_i
172
+ when :Float
173
+ value.to_f
174
+ when :Boolean
175
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
176
+ true
177
+ else
178
+ false
179
+ end
180
+ when :Object
181
+ # generic object (usually a Hash), return directly
182
+ value
183
+ when /\AArray<(?<inner_type>.+)>\z/
184
+ inner_type = Regexp.last_match[:inner_type]
185
+ value.map { |v| _deserialize(inner_type, v) }
186
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
187
+ k_type = Regexp.last_match[:k_type]
188
+ v_type = Regexp.last_match[:v_type]
189
+ {}.tap do |hash|
190
+ value.each do |k, v|
191
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
192
+ end
193
+ end
194
+ else # model
195
+ # models (e.g. Pet) or oneOf
196
+ klass = Cheminee.const_get(type)
197
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
198
+ end
199
+ end
200
+
201
+ # Returns the string representation of the object
202
+ # @return [String] String presentation of the object
203
+ def to_s
204
+ to_hash.to_s
205
+ end
206
+
207
+ # to_body is an alias to to_hash (backward compatibility)
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_body
210
+ to_hash
211
+ end
212
+
213
+ # Returns the object in the form of hash
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_hash
216
+ hash = {}
217
+ self.class.attribute_map.each_pair do |attr, param|
218
+ value = self.send(attr)
219
+ if value.nil?
220
+ is_nullable = self.class.openapi_nullable.include?(attr)
221
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
222
+ end
223
+
224
+ hash[param] = _to_hash(value)
225
+ end
226
+ hash
227
+ end
228
+
229
+ # Outputs non-array value in the form of hash
230
+ # For object, use to_hash. Otherwise, just return the value
231
+ # @param [Object] value Any valid value
232
+ # @return [Hash] Returns the value in the form of hash
233
+ def _to_hash(value)
234
+ if value.is_a?(Array)
235
+ value.compact.map { |v| _to_hash(v) }
236
+ elsif value.is_a?(Hash)
237
+ {}.tap do |hash|
238
+ value.each { |k, v| hash[k] = _to_hash(v) }
239
+ end
240
+ elsif value.respond_to? :to_hash
241
+ value.to_hash
242
+ else
243
+ value
244
+ end
245
+ end
246
+
247
+ end
248
+
249
+ end
@@ -0,0 +1,233 @@
1
+ =begin
2
+ #Cheminée
3
+
4
+ #Cheminée: The Chemical Structure Search Engine
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.3.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Cheminee
17
+ class Schema
18
+ attr_accessor :name
19
+
20
+ attr_accessor :schema
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'name' => :'name',
26
+ :'schema' => :'schema'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'name' => :'String',
39
+ :'schema' => :'Object'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ :'schema'
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Cheminee::Schema` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Cheminee::Schema`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'name')
66
+ self.name = attributes[:'name']
67
+ else
68
+ self.name = nil
69
+ end
70
+
71
+ if attributes.key?(:'schema')
72
+ self.schema = attributes[:'schema']
73
+ else
74
+ self.schema = nil
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
82
+ invalid_properties = Array.new
83
+ if @name.nil?
84
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
85
+ end
86
+
87
+ invalid_properties
88
+ end
89
+
90
+ # Check to see if the all the properties in the model are valid
91
+ # @return true if the model is valid
92
+ def valid?
93
+ warn '[DEPRECATED] the `valid?` method is obsolete'
94
+ return false if @name.nil?
95
+ true
96
+ end
97
+
98
+ # Checks equality by comparing each attribute.
99
+ # @param [Object] Object to be compared
100
+ def ==(o)
101
+ return true if self.equal?(o)
102
+ self.class == o.class &&
103
+ name == o.name &&
104
+ schema == o.schema
105
+ end
106
+
107
+ # @see the `==` method
108
+ # @param [Object] Object to be compared
109
+ def eql?(o)
110
+ self == o
111
+ end
112
+
113
+ # Calculates hash code according to all attributes.
114
+ # @return [Integer] Hash code
115
+ def hash
116
+ [name, schema].hash
117
+ end
118
+
119
+ # Builds the object from hash
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ # @return [Object] Returns the model itself
122
+ def self.build_from_hash(attributes)
123
+ return nil unless attributes.is_a?(Hash)
124
+ attributes = attributes.transform_keys(&:to_sym)
125
+ transformed_hash = {}
126
+ openapi_types.each_pair do |key, type|
127
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
128
+ transformed_hash["#{key}"] = nil
129
+ elsif type =~ /\AArray<(.*)>/i
130
+ # check to ensure the input is an array given that the attribute
131
+ # is documented as an array but the input is not
132
+ if attributes[attribute_map[key]].is_a?(Array)
133
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
134
+ end
135
+ elsif !attributes[attribute_map[key]].nil?
136
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
137
+ end
138
+ end
139
+ new(transformed_hash)
140
+ end
141
+
142
+ # Deserializes the data based on type
143
+ # @param string type Data type
144
+ # @param string value Value to be deserialized
145
+ # @return [Object] Deserialized data
146
+ def self._deserialize(type, value)
147
+ case type.to_sym
148
+ when :Time
149
+ Time.parse(value)
150
+ when :Date
151
+ Date.parse(value)
152
+ when :String
153
+ value.to_s
154
+ when :Integer
155
+ value.to_i
156
+ when :Float
157
+ value.to_f
158
+ when :Boolean
159
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
160
+ true
161
+ else
162
+ false
163
+ end
164
+ when :Object
165
+ # generic object (usually a Hash), return directly
166
+ value
167
+ when /\AArray<(?<inner_type>.+)>\z/
168
+ inner_type = Regexp.last_match[:inner_type]
169
+ value.map { |v| _deserialize(inner_type, v) }
170
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
171
+ k_type = Regexp.last_match[:k_type]
172
+ v_type = Regexp.last_match[:v_type]
173
+ {}.tap do |hash|
174
+ value.each do |k, v|
175
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
176
+ end
177
+ end
178
+ else # model
179
+ # models (e.g. Pet) or oneOf
180
+ klass = Cheminee.const_get(type)
181
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
182
+ end
183
+ end
184
+
185
+ # Returns the string representation of the object
186
+ # @return [String] String presentation of the object
187
+ def to_s
188
+ to_hash.to_s
189
+ end
190
+
191
+ # to_body is an alias to to_hash (backward compatibility)
192
+ # @return [Hash] Returns the object in the form of hash
193
+ def to_body
194
+ to_hash
195
+ end
196
+
197
+ # Returns the object in the form of hash
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_hash
200
+ hash = {}
201
+ self.class.attribute_map.each_pair do |attr, param|
202
+ value = self.send(attr)
203
+ if value.nil?
204
+ is_nullable = self.class.openapi_nullable.include?(attr)
205
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
206
+ end
207
+
208
+ hash[param] = _to_hash(value)
209
+ end
210
+ hash
211
+ end
212
+
213
+ # Outputs non-array value in the form of hash
214
+ # For object, use to_hash. Otherwise, just return the value
215
+ # @param [Object] value Any valid value
216
+ # @return [Hash] Returns the value in the form of hash
217
+ def _to_hash(value)
218
+ if value.is_a?(Array)
219
+ value.compact.map { |v| _to_hash(v) }
220
+ elsif value.is_a?(Hash)
221
+ {}.tap do |hash|
222
+ value.each { |k, v| hash[k] = _to_hash(v) }
223
+ end
224
+ elsif value.respond_to? :to_hash
225
+ value.to_hash
226
+ else
227
+ value
228
+ end
229
+ end
230
+
231
+ end
232
+
233
+ end