metatron_ruby_client 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +140 -0
  3. data/config.json +13 -0
  4. data/docs/Asset.md +9 -0
  5. data/docs/AssetAttributes.md +8 -0
  6. data/docs/AssetData.md +10 -0
  7. data/docs/AssetMeta.md +8 -0
  8. data/docs/AssetResultSet.md +10 -0
  9. data/docs/AssetResultSetMeta.md +8 -0
  10. data/docs/DefaultApi.md +631 -0
  11. data/docs/Error.md +10 -0
  12. data/docs/Errors.md +8 -0
  13. data/docs/Item.md +9 -0
  14. data/docs/ItemData.md +8 -0
  15. data/docs/ItemResultSet.md +10 -0
  16. data/docs/Links.md +10 -0
  17. data/docs/Manifestation.md +9 -0
  18. data/docs/ManifestationAttributes.md +11 -0
  19. data/docs/ManifestationData.md +11 -0
  20. data/docs/ManifestationRelationships.md +10 -0
  21. data/docs/ManifestationResultSet.md +10 -0
  22. data/docs/Meta.md +10 -0
  23. data/docs/OneToManyRelationship.md +10 -0
  24. data/docs/OneToOneRelationship.md +10 -0
  25. data/docs/Resource.md +10 -0
  26. data/docs/ResourceData.md +11 -0
  27. data/docs/ResourceLink.md +9 -0
  28. data/docs/ResultSetMeta.md +10 -0
  29. data/docs/Work.md +9 -0
  30. data/docs/WorkAttributes.md +8 -0
  31. data/docs/WorkData.md +11 -0
  32. data/docs/WorkRelationships.md +8 -0
  33. data/docs/WorkResultSet.md +11 -0
  34. data/generate.sh +0 -0
  35. data/git_push.sh +52 -0
  36. data/lib/metatron_ruby_client/api/default_api.rb +727 -0
  37. data/lib/metatron_ruby_client/api_client.rb +361 -0
  38. data/lib/metatron_ruby_client/api_error.rb +34 -0
  39. data/lib/metatron_ruby_client/configuration.rb +170 -0
  40. data/lib/metatron_ruby_client/models/asset.rb +195 -0
  41. data/lib/metatron_ruby_client/models/asset_attributes.rb +212 -0
  42. data/lib/metatron_ruby_client/models/asset_data.rb +208 -0
  43. data/lib/metatron_ruby_client/models/asset_meta.rb +198 -0
  44. data/lib/metatron_ruby_client/models/asset_result_set.rb +202 -0
  45. data/lib/metatron_ruby_client/models/asset_result_set_meta.rb +196 -0
  46. data/lib/metatron_ruby_client/models/error.rb +208 -0
  47. data/lib/metatron_ruby_client/models/errors.rb +184 -0
  48. data/lib/metatron_ruby_client/models/item.rb +197 -0
  49. data/lib/metatron_ruby_client/models/item_data.rb +186 -0
  50. data/lib/metatron_ruby_client/models/item_result_set.rb +206 -0
  51. data/lib/metatron_ruby_client/models/links.rb +204 -0
  52. data/lib/metatron_ruby_client/models/manifestation.rb +197 -0
  53. data/lib/metatron_ruby_client/models/manifestation_attributes.rb +209 -0
  54. data/lib/metatron_ruby_client/models/manifestation_data.rb +235 -0
  55. data/lib/metatron_ruby_client/models/manifestation_relationships.rb +200 -0
  56. data/lib/metatron_ruby_client/models/manifestation_result_set.rb +214 -0
  57. data/lib/metatron_ruby_client/models/meta.rb +260 -0
  58. data/lib/metatron_ruby_client/models/one_to_many_relationship.rb +206 -0
  59. data/lib/metatron_ruby_client/models/one_to_one_relationship.rb +204 -0
  60. data/lib/metatron_ruby_client/models/resource.rb +281 -0
  61. data/lib/metatron_ruby_client/models/resource_data.rb +221 -0
  62. data/lib/metatron_ruby_client/models/resource_link.rb +199 -0
  63. data/lib/metatron_ruby_client/models/result_set_meta.rb +203 -0
  64. data/lib/metatron_ruby_client/models/work.rb +197 -0
  65. data/lib/metatron_ruby_client/models/work_attributes.rb +186 -0
  66. data/lib/metatron_ruby_client/models/work_data.rb +235 -0
  67. data/lib/metatron_ruby_client/models/work_relationships.rb +182 -0
  68. data/lib/metatron_ruby_client/models/work_result_set.rb +213 -0
  69. data/lib/metatron_ruby_client/version.rb +13 -0
  70. data/lib/metatron_ruby_client.rb +60 -0
  71. data/metatron_ruby_client.gemspec +31 -0
  72. data/spec/api/default_api_spec.rb +218 -0
  73. data/spec/models/asset_attributes_spec.rb +46 -0
  74. data/spec/models/asset_data_spec.rb +66 -0
  75. data/spec/models/asset_meta_spec.rb +46 -0
  76. data/spec/models/asset_result_set_spec.rb +66 -0
  77. data/spec/models/asset_spec.rb +56 -0
  78. data/spec/models/error_spec.rb +66 -0
  79. data/spec/models/errors_spec.rb +46 -0
  80. data/spec/models/item_data_spec.rb +46 -0
  81. data/spec/models/item_result_set_spec.rb +66 -0
  82. data/spec/models/item_spec.rb +56 -0
  83. data/spec/models/links_spec.rb +66 -0
  84. data/spec/models/manifestation_attributes_spec.rb +76 -0
  85. data/spec/models/manifestation_data_spec.rb +76 -0
  86. data/spec/models/manifestation_relationships_spec.rb +66 -0
  87. data/spec/models/manifestation_result_set_spec.rb +66 -0
  88. data/spec/models/manifestation_spec.rb +56 -0
  89. data/spec/models/meta_spec.rb +66 -0
  90. data/spec/models/one_to_many_relationship_spec.rb +66 -0
  91. data/spec/models/one_to_one_relationship_spec.rb +66 -0
  92. data/spec/models/resource_data_spec.rb +76 -0
  93. data/spec/models/resource_link_spec.rb +56 -0
  94. data/spec/models/resource_spec.rb +66 -0
  95. data/spec/models/result_set_meta_spec.rb +66 -0
  96. data/spec/models/work_attributes_spec.rb +46 -0
  97. data/spec/models/work_data_spec.rb +76 -0
  98. data/spec/models/work_relationships_spec.rb +46 -0
  99. data/spec/models/work_result_set_spec.rb +76 -0
  100. data/spec/models/work_spec.rb +56 -0
  101. data/stub-service/.swagger-codegen-ignore +23 -0
  102. data/stub-service/Gemfile +4 -0
  103. data/stub-service/Gemfile.lock +22 -0
  104. data/stub-service/LICENSE +201 -0
  105. data/stub-service/README.md +29 -0
  106. data/stub-service/api/default_api.rb +370 -0
  107. data/stub-service/config.ru +2 -0
  108. data/stub-service/lib/result_set.rb +37 -0
  109. data/stub-service/lib/swaggering.rb +163 -0
  110. data/stub-service/my_app.rb +13 -0
  111. data/stub-service/responses/works/includes/manifestations.assets.yaml +42 -0
  112. data/stub-service/responses/works/includes/manifestations.yaml +88 -0
  113. data/stub-service/responses/works/result_set.yaml +18 -0
  114. data/stub-service/swagger.yaml +756 -0
  115. data/swagger-codegen-cli.jar +0 -0
  116. metadata +369 -0
@@ -0,0 +1,195 @@
1
+ =begin
2
+ production-metatron-api
3
+
4
+ OpenAPI spec version: 2016-07-15T09:42:29Z
5
+
6
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
7
+
8
+
9
+ =end
10
+
11
+ require 'date'
12
+
13
+ module MetatronClient
14
+ class Asset
15
+ attr_accessor :meta
16
+
17
+ attr_accessor :data
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'meta' => :'meta',
23
+ :'data' => :'data'
24
+ }
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.swagger_types
29
+ {
30
+ :'meta' => :'AssetResultSetMeta',
31
+ :'data' => :'AssetData'
32
+ }
33
+ end
34
+
35
+ # Initializes the object
36
+ # @param [Hash] attributes Model attributes in the form of hash
37
+ def initialize(attributes = {})
38
+ return unless attributes.is_a?(Hash)
39
+
40
+ # convert string to symbol for hash key
41
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
42
+
43
+ if attributes.has_key?(:'meta')
44
+ self.meta = attributes[:'meta']
45
+ end
46
+
47
+ if attributes.has_key?(:'data')
48
+ self.data = attributes[:'data']
49
+ end
50
+
51
+ end
52
+
53
+ # Show invalid properties with the reasons. Usually used together with valid?
54
+ # @return Array for valid properies with the reasons
55
+ def list_invalid_properties
56
+ invalid_properties = Array.new
57
+ return invalid_properties
58
+ end
59
+
60
+ # Check to see if the all the properties in the model are valid
61
+ # @return true if the model is valid
62
+ def valid?
63
+ if @data.nil?
64
+ return false
65
+ end
66
+
67
+ end
68
+
69
+ # Checks equality by comparing each attribute.
70
+ # @param [Object] Object to be compared
71
+ def ==(o)
72
+ return true if self.equal?(o)
73
+ self.class == o.class &&
74
+ meta == o.meta &&
75
+ data == o.data
76
+ end
77
+
78
+ # @see the `==` method
79
+ # @param [Object] Object to be compared
80
+ def eql?(o)
81
+ self == o
82
+ end
83
+
84
+ # Calculates hash code according to all attributes.
85
+ # @return [Fixnum] Hash code
86
+ def hash
87
+ [meta, data].hash
88
+ end
89
+
90
+ # Builds the object from hash
91
+ # @param [Hash] attributes Model attributes in the form of hash
92
+ # @return [Object] Returns the model itself
93
+ def build_from_hash(attributes)
94
+ return nil unless attributes.is_a?(Hash)
95
+ self.class.swagger_types.each_pair do |key, type|
96
+ if type =~ /^Array<(.*)>/i
97
+ # check to ensure the input is an array given that the the attribute
98
+ # is documented as an array but the input is not
99
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
100
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
101
+ end
102
+ elsif !attributes[self.class.attribute_map[key]].nil?
103
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
104
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
105
+ end
106
+
107
+ self
108
+ end
109
+
110
+ # Deserializes the data based on type
111
+ # @param string type Data type
112
+ # @param string value Value to be deserialized
113
+ # @return [Object] Deserialized data
114
+ def _deserialize(type, value)
115
+ case type.to_sym
116
+ when :DateTime
117
+ DateTime.parse(value)
118
+ when :Date
119
+ Date.parse(value)
120
+ when :String
121
+ value.to_s
122
+ when :Integer
123
+ value.to_i
124
+ when :Float
125
+ value.to_f
126
+ when :BOOLEAN
127
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
128
+ true
129
+ else
130
+ false
131
+ end
132
+ when :Object
133
+ # generic object (usually a Hash), return directly
134
+ value
135
+ when /\AArray<(?<inner_type>.+)>\z/
136
+ inner_type = Regexp.last_match[:inner_type]
137
+ value.map { |v| _deserialize(inner_type, v) }
138
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
139
+ k_type = Regexp.last_match[:k_type]
140
+ v_type = Regexp.last_match[:v_type]
141
+ {}.tap do |hash|
142
+ value.each do |k, v|
143
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
144
+ end
145
+ end
146
+ else # model
147
+ temp_model = MetatronClient.const_get(type).new
148
+ temp_model.build_from_hash(value)
149
+ end
150
+ end
151
+
152
+ # Returns the string representation of the object
153
+ # @return [String] String presentation of the object
154
+ def to_s
155
+ to_hash.to_s
156
+ end
157
+
158
+ # to_body is an alias to to_hash (backward compatibility)
159
+ # @return [Hash] Returns the object in the form of hash
160
+ def to_body
161
+ to_hash
162
+ end
163
+
164
+ # Returns the object in the form of hash
165
+ # @return [Hash] Returns the object in the form of hash
166
+ def to_hash
167
+ hash = {}
168
+ self.class.attribute_map.each_pair do |attr, param|
169
+ value = self.send(attr)
170
+ next if value.nil?
171
+ hash[param] = _to_hash(value)
172
+ end
173
+ hash
174
+ end
175
+
176
+ # Outputs non-array value in the form of hash
177
+ # For object, use to_hash. Otherwise, just return the value
178
+ # @param [Object] value Any valid value
179
+ # @return [Hash] Returns the value in the form of hash
180
+ def _to_hash(value)
181
+ if value.is_a?(Array)
182
+ value.compact.map{ |v| _to_hash(v) }
183
+ elsif value.is_a?(Hash)
184
+ {}.tap do |hash|
185
+ value.each { |k, v| hash[k] = _to_hash(v) }
186
+ end
187
+ elsif value.respond_to? :to_hash
188
+ value.to_hash
189
+ else
190
+ value
191
+ end
192
+ end
193
+
194
+ end
195
+ end
@@ -0,0 +1,212 @@
1
+ =begin
2
+ Metatron Server
3
+
4
+ A primitive modelling bibliographic metadata
5
+
6
+ OpenAPI spec version: 2.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module MetatronClient
16
+ class AssetAttributes
17
+ attr_accessor :asset_type
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+
23
+ :'asset_type' => :'asset_type'
24
+
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.swagger_types
30
+ {
31
+
32
+ :'asset_type' => :'String'
33
+
34
+ }
35
+ end
36
+
37
+ # Initializes the object
38
+ # @param [Hash] attributes Model attributes in the form of hash
39
+ def initialize(attributes = {})
40
+ return unless attributes.is_a?(Hash)
41
+
42
+ # convert string to symbol for hash key
43
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
44
+
45
+
46
+ if attributes.has_key?(:'asset_type')
47
+
48
+
49
+ self.asset_type = attributes[:'asset_type']
50
+
51
+
52
+ end
53
+
54
+
55
+ end
56
+
57
+ # Show invalid properties with the reasons. Usually used together with valid?
58
+ # @return Array for valid properies with the reasons
59
+ def list_invalid_properties
60
+ invalid_properties = Array.new
61
+
62
+
63
+ return invalid_properties
64
+ end
65
+
66
+ # Check to see if the all the properties in the model are valid
67
+ # @return true if the model is valid
68
+ def valid?
69
+
70
+
71
+ if @asset_type.nil?
72
+ return false
73
+ end
74
+
75
+
76
+
77
+
78
+
79
+ end
80
+
81
+
82
+
83
+
84
+
85
+
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
+ asset_type == o.asset_type
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 [Fixnum] Hash code
103
+ def hash
104
+ [asset_type].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 build_from_hash(attributes)
111
+ return nil unless attributes.is_a?(Hash)
112
+ self.class.swagger_types.each_pair do |key, type|
113
+ if type =~ /^Array<(.*)>/i
114
+ # check to ensure the input is an array given that the the attribute
115
+ # is documented as an array but the input is not
116
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
117
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
118
+ end
119
+ elsif !attributes[self.class.attribute_map[key]].nil?
120
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
121
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
122
+ end
123
+
124
+ self
125
+ end
126
+
127
+ # Deserializes the data based on type
128
+ # @param string type Data type
129
+ # @param string value Value to be deserialized
130
+ # @return [Object] Deserialized data
131
+ def _deserialize(type, value)
132
+ case type.to_sym
133
+ when :DateTime
134
+ DateTime.parse(value)
135
+ when :Date
136
+ Date.parse(value)
137
+ when :String
138
+ value.to_s
139
+ when :Integer
140
+ value.to_i
141
+ when :Float
142
+ value.to_f
143
+ when :BOOLEAN
144
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
145
+ true
146
+ else
147
+ false
148
+ end
149
+ when :Object
150
+ # generic object (usually a Hash), return directly
151
+ value
152
+ when /\AArray<(?<inner_type>.+)>\z/
153
+ inner_type = Regexp.last_match[:inner_type]
154
+ value.map { |v| _deserialize(inner_type, v) }
155
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
156
+ k_type = Regexp.last_match[:k_type]
157
+ v_type = Regexp.last_match[:v_type]
158
+ {}.tap do |hash|
159
+ value.each do |k, v|
160
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
161
+ end
162
+ end
163
+ else # model
164
+ temp_model = MetatronClient.const_get(type).new
165
+ temp_model.build_from_hash(value)
166
+ end
167
+ end
168
+
169
+ # Returns the string representation of the object
170
+ # @return [String] String presentation of the object
171
+ def to_s
172
+ to_hash.to_s
173
+ end
174
+
175
+ # to_body is an alias to to_hash (backward compatibility)
176
+ # @return [Hash] Returns the object in the form of hash
177
+ def to_body
178
+ to_hash
179
+ end
180
+
181
+ # Returns the object in the form of hash
182
+ # @return [Hash] Returns the object in the form of hash
183
+ def to_hash
184
+ hash = {}
185
+ self.class.attribute_map.each_pair do |attr, param|
186
+ value = self.send(attr)
187
+ next if value.nil?
188
+ hash[param] = _to_hash(value)
189
+ end
190
+ hash
191
+ end
192
+
193
+ # Outputs non-array value in the form of hash
194
+ # For object, use to_hash. Otherwise, just return the value
195
+ # @param [Object] value Any valid value
196
+ # @return [Hash] Returns the value in the form of hash
197
+ def _to_hash(value)
198
+ if value.is_a?(Array)
199
+ value.compact.map{ |v| _to_hash(v) }
200
+ elsif value.is_a?(Hash)
201
+ {}.tap do |hash|
202
+ value.each { |k, v| hash[k] = _to_hash(v) }
203
+ end
204
+ elsif value.respond_to? :to_hash
205
+ value.to_hash
206
+ else
207
+ value
208
+ end
209
+ end
210
+
211
+ end
212
+ end
@@ -0,0 +1,208 @@
1
+ =begin
2
+ production-metatron-api
3
+
4
+ OpenAPI spec version: 2016-07-15T09:42:29Z
5
+
6
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
7
+
8
+
9
+ =end
10
+
11
+ require 'date'
12
+
13
+ module MetatronClient
14
+ class AssetData
15
+ attr_accessor :id
16
+
17
+ attr_accessor :type
18
+
19
+ attr_accessor :attributes
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'id' => :'id',
25
+ :'type' => :'type',
26
+ :'attributes' => :'attributes'
27
+ }
28
+ end
29
+
30
+ # Attribute type mapping.
31
+ def self.swagger_types
32
+ {
33
+ :'id' => :'String',
34
+ :'type' => :'String',
35
+ :'attributes' => :'Object'
36
+ }
37
+ end
38
+
39
+ # Initializes the object
40
+ # @param [Hash] attributes Model attributes in the form of hash
41
+ def initialize(attributes = {})
42
+ return unless attributes.is_a?(Hash)
43
+
44
+ # convert string to symbol for hash key
45
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
46
+
47
+ if attributes.has_key?(:'id')
48
+ self.id = attributes[:'id']
49
+ end
50
+
51
+ if attributes.has_key?(:'type')
52
+ self.type = attributes[:'type']
53
+ end
54
+
55
+ if attributes.has_key?(:'attributes')
56
+ self.attributes = attributes[:'attributes']
57
+ end
58
+
59
+ end
60
+
61
+ # Show invalid properties with the reasons. Usually used together with valid?
62
+ # @return Array for valid properies with the reasons
63
+ def list_invalid_properties
64
+ invalid_properties = Array.new
65
+ return invalid_properties
66
+ end
67
+
68
+ # Check to see if the all the properties in the model are valid
69
+ # @return true if the model is valid
70
+ def valid?
71
+ if @id.nil?
72
+ return false
73
+ end
74
+
75
+ if @type.nil?
76
+ return false
77
+ end
78
+
79
+ end
80
+
81
+ # Checks equality by comparing each attribute.
82
+ # @param [Object] Object to be compared
83
+ def ==(o)
84
+ return true if self.equal?(o)
85
+ self.class == o.class &&
86
+ id == o.id &&
87
+ type == o.type &&
88
+ attributes == o.attributes
89
+ end
90
+
91
+ # @see the `==` method
92
+ # @param [Object] Object to be compared
93
+ def eql?(o)
94
+ self == o
95
+ end
96
+
97
+ # Calculates hash code according to all attributes.
98
+ # @return [Fixnum] Hash code
99
+ def hash
100
+ [id, type, attributes].hash
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def build_from_hash(attributes)
107
+ return nil unless attributes.is_a?(Hash)
108
+ self.class.swagger_types.each_pair do |key, type|
109
+ if type =~ /^Array<(.*)>/i
110
+ # check to ensure the input is an array given that the the attribute
111
+ # is documented as an array but the input is not
112
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
113
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
114
+ end
115
+ elsif !attributes[self.class.attribute_map[key]].nil?
116
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
117
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
118
+ end
119
+
120
+ self
121
+ end
122
+
123
+ # Deserializes the data based on type
124
+ # @param string type Data type
125
+ # @param string value Value to be deserialized
126
+ # @return [Object] Deserialized data
127
+ def _deserialize(type, value)
128
+ case type.to_sym
129
+ when :DateTime
130
+ DateTime.parse(value)
131
+ when :Date
132
+ Date.parse(value)
133
+ when :String
134
+ value.to_s
135
+ when :Integer
136
+ value.to_i
137
+ when :Float
138
+ value.to_f
139
+ when :BOOLEAN
140
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
141
+ true
142
+ else
143
+ false
144
+ end
145
+ when :Object
146
+ # generic object (usually a Hash), return directly
147
+ value
148
+ when /\AArray<(?<inner_type>.+)>\z/
149
+ inner_type = Regexp.last_match[:inner_type]
150
+ value.map { |v| _deserialize(inner_type, v) }
151
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
152
+ k_type = Regexp.last_match[:k_type]
153
+ v_type = Regexp.last_match[:v_type]
154
+ {}.tap do |hash|
155
+ value.each do |k, v|
156
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
157
+ end
158
+ end
159
+ else # model
160
+ temp_model = MetatronClient.const_get(type).new
161
+ temp_model.build_from_hash(value)
162
+ end
163
+ end
164
+
165
+ # Returns the string representation of the object
166
+ # @return [String] String presentation of the object
167
+ def to_s
168
+ to_hash.to_s
169
+ end
170
+
171
+ # to_body is an alias to to_hash (backward compatibility)
172
+ # @return [Hash] Returns the object in the form of hash
173
+ def to_body
174
+ to_hash
175
+ end
176
+
177
+ # Returns the object in the form of hash
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_hash
180
+ hash = {}
181
+ self.class.attribute_map.each_pair do |attr, param|
182
+ value = self.send(attr)
183
+ next if value.nil?
184
+ hash[param] = _to_hash(value)
185
+ end
186
+ hash
187
+ end
188
+
189
+ # Outputs non-array value in the form of hash
190
+ # For object, use to_hash. Otherwise, just return the value
191
+ # @param [Object] value Any valid value
192
+ # @return [Hash] Returns the value in the form of hash
193
+ def _to_hash(value)
194
+ if value.is_a?(Array)
195
+ value.compact.map{ |v| _to_hash(v) }
196
+ elsif value.is_a?(Hash)
197
+ {}.tap do |hash|
198
+ value.each { |k, v| hash[k] = _to_hash(v) }
199
+ end
200
+ elsif value.respond_to? :to_hash
201
+ value.to_hash
202
+ else
203
+ value
204
+ end
205
+ end
206
+
207
+ end
208
+ end