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,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 Error
15
+ attr_accessor :status
16
+
17
+ attr_accessor :title
18
+
19
+ attr_accessor :detail
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'status' => :'status',
25
+ :'title' => :'title',
26
+ :'detail' => :'detail'
27
+ }
28
+ end
29
+
30
+ # Attribute type mapping.
31
+ def self.swagger_types
32
+ {
33
+ :'status' => :'Float',
34
+ :'title' => :'String',
35
+ :'detail' => :'String'
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?(:'status')
48
+ self.status = attributes[:'status']
49
+ end
50
+
51
+ if attributes.has_key?(:'title')
52
+ self.title = attributes[:'title']
53
+ end
54
+
55
+ if attributes.has_key?(:'detail')
56
+ self.detail = attributes[:'detail']
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 @status.nil?
72
+ return false
73
+ end
74
+
75
+ if @title.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
+ status == o.status &&
87
+ title == o.title &&
88
+ detail == o.detail
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
+ [status, title, detail].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
@@ -0,0 +1,184 @@
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 Errors
15
+ attr_accessor :errors
16
+
17
+ # Attribute mapping from ruby-style variable name to JSON key.
18
+ def self.attribute_map
19
+ {
20
+ :'errors' => :'errors'
21
+ }
22
+ end
23
+
24
+ # Attribute type mapping.
25
+ def self.swagger_types
26
+ {
27
+ :'errors' => :'Array<Error>'
28
+ }
29
+ end
30
+
31
+ # Initializes the object
32
+ # @param [Hash] attributes Model attributes in the form of hash
33
+ def initialize(attributes = {})
34
+ return unless attributes.is_a?(Hash)
35
+
36
+ # convert string to symbol for hash key
37
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
38
+
39
+ if attributes.has_key?(:'errors')
40
+ if (value = attributes[:'errors']).is_a?(Array)
41
+ self.errors = value
42
+ end
43
+ end
44
+
45
+ end
46
+
47
+ # Show invalid properties with the reasons. Usually used together with valid?
48
+ # @return Array for valid properies with the reasons
49
+ def list_invalid_properties
50
+ invalid_properties = Array.new
51
+ return invalid_properties
52
+ end
53
+
54
+ # Check to see if the all the properties in the model are valid
55
+ # @return true if the model is valid
56
+ def valid?
57
+ end
58
+
59
+ # Checks equality by comparing each attribute.
60
+ # @param [Object] Object to be compared
61
+ def ==(o)
62
+ return true if self.equal?(o)
63
+ self.class == o.class &&
64
+ errors == o.errors
65
+ end
66
+
67
+ # @see the `==` method
68
+ # @param [Object] Object to be compared
69
+ def eql?(o)
70
+ self == o
71
+ end
72
+
73
+ # Calculates hash code according to all attributes.
74
+ # @return [Fixnum] Hash code
75
+ def hash
76
+ [errors].hash
77
+ end
78
+
79
+ # Builds the object from hash
80
+ # @param [Hash] attributes Model attributes in the form of hash
81
+ # @return [Object] Returns the model itself
82
+ def build_from_hash(attributes)
83
+ return nil unless attributes.is_a?(Hash)
84
+ self.class.swagger_types.each_pair do |key, type|
85
+ if type =~ /^Array<(.*)>/i
86
+ # check to ensure the input is an array given that the the attribute
87
+ # is documented as an array but the input is not
88
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
89
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
90
+ end
91
+ elsif !attributes[self.class.attribute_map[key]].nil?
92
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
93
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
94
+ end
95
+
96
+ self
97
+ end
98
+
99
+ # Deserializes the data based on type
100
+ # @param string type Data type
101
+ # @param string value Value to be deserialized
102
+ # @return [Object] Deserialized data
103
+ def _deserialize(type, value)
104
+ case type.to_sym
105
+ when :DateTime
106
+ DateTime.parse(value)
107
+ when :Date
108
+ Date.parse(value)
109
+ when :String
110
+ value.to_s
111
+ when :Integer
112
+ value.to_i
113
+ when :Float
114
+ value.to_f
115
+ when :BOOLEAN
116
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
117
+ true
118
+ else
119
+ false
120
+ end
121
+ when :Object
122
+ # generic object (usually a Hash), return directly
123
+ value
124
+ when /\AArray<(?<inner_type>.+)>\z/
125
+ inner_type = Regexp.last_match[:inner_type]
126
+ value.map { |v| _deserialize(inner_type, v) }
127
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
128
+ k_type = Regexp.last_match[:k_type]
129
+ v_type = Regexp.last_match[:v_type]
130
+ {}.tap do |hash|
131
+ value.each do |k, v|
132
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
133
+ end
134
+ end
135
+ else # model
136
+ temp_model = MetatronClient.const_get(type).new
137
+ temp_model.build_from_hash(value)
138
+ end
139
+ end
140
+
141
+ # Returns the string representation of the object
142
+ # @return [String] String presentation of the object
143
+ def to_s
144
+ to_hash.to_s
145
+ end
146
+
147
+ # to_body is an alias to to_hash (backward compatibility)
148
+ # @return [Hash] Returns the object in the form of hash
149
+ def to_body
150
+ to_hash
151
+ end
152
+
153
+ # Returns the object in the form of hash
154
+ # @return [Hash] Returns the object in the form of hash
155
+ def to_hash
156
+ hash = {}
157
+ self.class.attribute_map.each_pair do |attr, param|
158
+ value = self.send(attr)
159
+ next if value.nil?
160
+ hash[param] = _to_hash(value)
161
+ end
162
+ hash
163
+ end
164
+
165
+ # Outputs non-array value in the form of hash
166
+ # For object, use to_hash. Otherwise, just return the value
167
+ # @param [Object] value Any valid value
168
+ # @return [Hash] Returns the value in the form of hash
169
+ def _to_hash(value)
170
+ if value.is_a?(Array)
171
+ value.compact.map{ |v| _to_hash(v) }
172
+ elsif value.is_a?(Hash)
173
+ {}.tap do |hash|
174
+ value.each { |k, v| hash[k] = _to_hash(v) }
175
+ end
176
+ elsif value.respond_to? :to_hash
177
+ value.to_hash
178
+ else
179
+ value
180
+ end
181
+ end
182
+
183
+ end
184
+ end
@@ -0,0 +1,197 @@
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 Item
17
+ attr_accessor :links
18
+
19
+ attr_accessor :data
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'links' => :'links',
25
+ :'data' => :'data'
26
+ }
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.swagger_types
31
+ {
32
+ :'links' => :'Links',
33
+ :'data' => :'ItemData'
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
+ if attributes.has_key?(:'links')
46
+ self.links = attributes[:'links']
47
+ end
48
+
49
+ if attributes.has_key?(:'data')
50
+ self.data = attributes[:'data']
51
+ end
52
+
53
+ end
54
+
55
+ # Show invalid properties with the reasons. Usually used together with valid?
56
+ # @return Array for valid properies with the reasons
57
+ def list_invalid_properties
58
+ invalid_properties = Array.new
59
+ return invalid_properties
60
+ end
61
+
62
+ # Check to see if the all the properties in the model are valid
63
+ # @return true if the model is valid
64
+ def valid?
65
+ if @data.nil?
66
+ return false
67
+ end
68
+
69
+ end
70
+
71
+ # Checks equality by comparing each attribute.
72
+ # @param [Object] Object to be compared
73
+ def ==(o)
74
+ return true if self.equal?(o)
75
+ self.class == o.class &&
76
+ links == o.links &&
77
+ data == o.data
78
+ end
79
+
80
+ # @see the `==` method
81
+ # @param [Object] Object to be compared
82
+ def eql?(o)
83
+ self == o
84
+ end
85
+
86
+ # Calculates hash code according to all attributes.
87
+ # @return [Fixnum] Hash code
88
+ def hash
89
+ [links, data].hash
90
+ end
91
+
92
+ # Builds the object from hash
93
+ # @param [Hash] attributes Model attributes in the form of hash
94
+ # @return [Object] Returns the model itself
95
+ def build_from_hash(attributes)
96
+ return nil unless attributes.is_a?(Hash)
97
+ self.class.swagger_types.each_pair do |key, type|
98
+ if type =~ /^Array<(.*)>/i
99
+ # check to ensure the input is an array given that the the attribute
100
+ # is documented as an array but the input is not
101
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
102
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
103
+ end
104
+ elsif !attributes[self.class.attribute_map[key]].nil?
105
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
106
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
107
+ end
108
+
109
+ self
110
+ end
111
+
112
+ # Deserializes the data based on type
113
+ # @param string type Data type
114
+ # @param string value Value to be deserialized
115
+ # @return [Object] Deserialized data
116
+ def _deserialize(type, value)
117
+ case type.to_sym
118
+ when :DateTime
119
+ DateTime.parse(value)
120
+ when :Date
121
+ Date.parse(value)
122
+ when :String
123
+ value.to_s
124
+ when :Integer
125
+ value.to_i
126
+ when :Float
127
+ value.to_f
128
+ when :BOOLEAN
129
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
130
+ true
131
+ else
132
+ false
133
+ end
134
+ when :Object
135
+ # generic object (usually a Hash), return directly
136
+ value
137
+ when /\AArray<(?<inner_type>.+)>\z/
138
+ inner_type = Regexp.last_match[:inner_type]
139
+ value.map { |v| _deserialize(inner_type, v) }
140
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
141
+ k_type = Regexp.last_match[:k_type]
142
+ v_type = Regexp.last_match[:v_type]
143
+ {}.tap do |hash|
144
+ value.each do |k, v|
145
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
146
+ end
147
+ end
148
+ else # model
149
+ temp_model = MetatronClient.const_get(type).new
150
+ temp_model.build_from_hash(value)
151
+ end
152
+ end
153
+
154
+ # Returns the string representation of the object
155
+ # @return [String] String presentation of the object
156
+ def to_s
157
+ to_hash.to_s
158
+ end
159
+
160
+ # to_body is an alias to to_hash (backward compatibility)
161
+ # @return [Hash] Returns the object in the form of hash
162
+ def to_body
163
+ to_hash
164
+ end
165
+
166
+ # Returns the object in the form of hash
167
+ # @return [Hash] Returns the object in the form of hash
168
+ def to_hash
169
+ hash = {}
170
+ self.class.attribute_map.each_pair do |attr, param|
171
+ value = self.send(attr)
172
+ next if value.nil?
173
+ hash[param] = _to_hash(value)
174
+ end
175
+ hash
176
+ end
177
+
178
+ # Outputs non-array value in the form of hash
179
+ # For object, use to_hash. Otherwise, just return the value
180
+ # @param [Object] value Any valid value
181
+ # @return [Hash] Returns the value in the form of hash
182
+ def _to_hash(value)
183
+ if value.is_a?(Array)
184
+ value.compact.map{ |v| _to_hash(v) }
185
+ elsif value.is_a?(Hash)
186
+ {}.tap do |hash|
187
+ value.each { |k, v| hash[k] = _to_hash(v) }
188
+ end
189
+ elsif value.respond_to? :to_hash
190
+ value.to_hash
191
+ else
192
+ value
193
+ end
194
+ end
195
+
196
+ end
197
+ end