ddr_client 2.0.0.d9f2bd2b

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.md +168 -0
  4. data/Rakefile +8 -0
  5. data/ddr_client.gemspec +46 -0
  6. data/docs/BatchObjectsApi.md +125 -0
  7. data/docs/BatchesApi.md +305 -0
  8. data/docs/DdrAPIBatchEntity.md +24 -0
  9. data/docs/DdrAPIBatchEntityLogfile.md +11 -0
  10. data/docs/DdrAPIBatchObjectAttributeEntity.md +16 -0
  11. data/docs/DdrAPIBatchObjectDatastreamEntity.md +17 -0
  12. data/docs/DdrAPIBatchObjectEntity.md +26 -0
  13. data/docs/DdrAPIBatchObjectMessageEntity.md +13 -0
  14. data/docs/DdrAPIBatchObjectRelationshipEntity.md +15 -0
  15. data/docs/DdrAPIBatchObjectRoleEntity.md +15 -0
  16. data/docs/DdrAPIEventEntity.md +17 -0
  17. data/docs/DdrAPIFileEntity.md +11 -0
  18. data/docs/DdrAPIGroupEntity.md +10 -0
  19. data/docs/DdrAPIGroupMemberEntity.md +10 -0
  20. data/docs/DdrAPILinkEntity.md +9 -0
  21. data/docs/DdrAPIResourceEntity.md +17 -0
  22. data/docs/DdrAPIResourceEntityFiles.md +17 -0
  23. data/docs/DdrAPIResourceEntityMetadata.md +62 -0
  24. data/docs/DdrAPIResourceEntityRelated.md +11 -0
  25. data/docs/DdrAPIRoleEntity.md +10 -0
  26. data/docs/DdrAPITechnicalMetadataEntity.md +24 -0
  27. data/docs/DdrAPIUserEntity.md +19 -0
  28. data/docs/EventsApi.md +131 -0
  29. data/docs/GroupsApi.md +63 -0
  30. data/docs/IndexApi.md +161 -0
  31. data/docs/PatchResources.md +11 -0
  32. data/docs/PatchResourcesMetadata.md +62 -0
  33. data/docs/PatchResourcesRelated.md +11 -0
  34. data/docs/PatchResourcesRoles.md +10 -0
  35. data/docs/PostResources.md +12 -0
  36. data/docs/QueuesApi.md +102 -0
  37. data/docs/ReportsApi.md +177 -0
  38. data/docs/ResourcesApi.md +1003 -0
  39. data/docs/SchemaApi.md +128 -0
  40. data/docs/UsersApi.md +131 -0
  41. data/git_push.sh +55 -0
  42. data/lib/ddr_client/api/batch_objects_api.rb +138 -0
  43. data/lib/ddr_client/api/batches_api.rb +306 -0
  44. data/lib/ddr_client/api/events_api.rb +147 -0
  45. data/lib/ddr_client/api/groups_api.rb +70 -0
  46. data/lib/ddr_client/api/index_api.rb +164 -0
  47. data/lib/ddr_client/api/queues_api.rb +109 -0
  48. data/lib/ddr_client/api/reports_api.rb +179 -0
  49. data/lib/ddr_client/api/resources_api.rb +1098 -0
  50. data/lib/ddr_client/api/schema_api.rb +152 -0
  51. data/lib/ddr_client/api/users_api.rb +141 -0
  52. data/lib/ddr_client/api_client.rb +391 -0
  53. data/lib/ddr_client/api_error.rb +38 -0
  54. data/lib/ddr_client/configuration.rb +209 -0
  55. data/lib/ddr_client/models/ddr_api_batch_entity.rb +333 -0
  56. data/lib/ddr_client/models/ddr_api_batch_entity_logfile.rb +211 -0
  57. data/lib/ddr_client/models/ddr_api_batch_object_attribute_entity.rb +256 -0
  58. data/lib/ddr_client/models/ddr_api_batch_object_datastream_entity.rb +265 -0
  59. data/lib/ddr_client/models/ddr_api_batch_object_entity.rb +349 -0
  60. data/lib/ddr_client/models/ddr_api_batch_object_message_entity.rb +230 -0
  61. data/lib/ddr_client/models/ddr_api_batch_object_relationship_entity.rb +247 -0
  62. data/lib/ddr_client/models/ddr_api_batch_object_role_entity.rb +247 -0
  63. data/lib/ddr_client/models/ddr_api_event_entity.rb +325 -0
  64. data/lib/ddr_client/models/ddr_api_file_entity.rb +215 -0
  65. data/lib/ddr_client/models/ddr_api_group_entity.rb +203 -0
  66. data/lib/ddr_client/models/ddr_api_group_member_entity.rb +202 -0
  67. data/lib/ddr_client/models/ddr_api_link_entity.rb +193 -0
  68. data/lib/ddr_client/models/ddr_api_resource_entity.rb +310 -0
  69. data/lib/ddr_client/models/ddr_api_resource_entity_files.rb +276 -0
  70. data/lib/ddr_client/models/ddr_api_resource_entity_metadata.rb +874 -0
  71. data/lib/ddr_client/models/ddr_api_resource_entity_related.rb +216 -0
  72. data/lib/ddr_client/models/ddr_api_role_entity.rb +251 -0
  73. data/lib/ddr_client/models/ddr_api_technical_metadata_entity.rb +329 -0
  74. data/lib/ddr_client/models/ddr_api_user_entity.rb +296 -0
  75. data/lib/ddr_client/models/patch_resources.rb +221 -0
  76. data/lib/ddr_client/models/patch_resources_metadata.rb +726 -0
  77. data/lib/ddr_client/models/patch_resources_related.rb +216 -0
  78. data/lib/ddr_client/models/patch_resources_roles.rb +220 -0
  79. data/lib/ddr_client/models/post_resources.rb +265 -0
  80. data/lib/ddr_client/version.rb +15 -0
  81. data/lib/ddr_client.rb +74 -0
  82. data/spec/api/batch_objects_api_spec.rb +61 -0
  83. data/spec/api/batches_api_spec.rb +100 -0
  84. data/spec/api/events_api_spec.rb +64 -0
  85. data/spec/api/groups_api_spec.rb +46 -0
  86. data/spec/api/index_api_spec.rb +67 -0
  87. data/spec/api/queues_api_spec.rb +55 -0
  88. data/spec/api/reports_api_spec.rb +70 -0
  89. data/spec/api/resources_api_spec.rb +271 -0
  90. data/spec/api/schema_api_spec.rb +65 -0
  91. data/spec/api/users_api_spec.rb +64 -0
  92. data/spec/api_client_spec.rb +243 -0
  93. data/spec/configuration_spec.rb +42 -0
  94. data/spec/models/ddr_api_batch_entity_logfile_spec.rb +59 -0
  95. data/spec/models/ddr_api_batch_entity_spec.rb +137 -0
  96. data/spec/models/ddr_api_batch_object_attribute_entity_spec.rb +89 -0
  97. data/spec/models/ddr_api_batch_object_datastream_entity_spec.rb +95 -0
  98. data/spec/models/ddr_api_batch_object_entity_spec.rb +149 -0
  99. data/spec/models/ddr_api_batch_object_message_entity_spec.rb +71 -0
  100. data/spec/models/ddr_api_batch_object_relationship_entity_spec.rb +83 -0
  101. data/spec/models/ddr_api_batch_object_role_entity_spec.rb +83 -0
  102. data/spec/models/ddr_api_event_entity_spec.rb +103 -0
  103. data/spec/models/ddr_api_file_entity_spec.rb +59 -0
  104. data/spec/models/ddr_api_group_entity_spec.rb +53 -0
  105. data/spec/models/ddr_api_group_member_entity_spec.rb +53 -0
  106. data/spec/models/ddr_api_link_entity_spec.rb +47 -0
  107. data/spec/models/ddr_api_resource_entity_files_spec.rb +95 -0
  108. data/spec/models/ddr_api_resource_entity_metadata_spec.rb +389 -0
  109. data/spec/models/ddr_api_resource_entity_related_spec.rb +59 -0
  110. data/spec/models/ddr_api_resource_entity_spec.rb +99 -0
  111. data/spec/models/ddr_api_role_entity_spec.rb +61 -0
  112. data/spec/models/ddr_api_technical_metadata_entity_spec.rb +137 -0
  113. data/spec/models/ddr_api_user_entity_spec.rb +107 -0
  114. data/spec/models/patch_resources_metadata_spec.rb +365 -0
  115. data/spec/models/patch_resources_related_spec.rb +59 -0
  116. data/spec/models/patch_resources_roles_spec.rb +53 -0
  117. data/spec/models/patch_resources_spec.rb +59 -0
  118. data/spec/models/post_resources_spec.rb +69 -0
  119. data/spec/spec_helper.rb +111 -0
  120. metadata +399 -0
@@ -0,0 +1,193 @@
1
+ =begin
2
+ #Duke Digital Repository API
3
+
4
+ #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.36
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DdrClient
16
+ class DdrAPILinkEntity
17
+ attr_accessor :href
18
+
19
+ attr_accessor :rel
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'href' => :'href',
25
+ :'rel' => :'rel'
26
+ }
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.swagger_types
31
+ {
32
+ :'href' => :'String',
33
+ :'rel' => :'String'
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?(:'href')
46
+ self.href = attributes[:'href']
47
+ end
48
+
49
+ if attributes.has_key?(:'rel')
50
+ self.rel = attributes[:'rel']
51
+ end
52
+ end
53
+
54
+ # Show invalid properties with the reasons. Usually used together with valid?
55
+ # @return Array for valid properties with the reasons
56
+ def list_invalid_properties
57
+ invalid_properties = Array.new
58
+ invalid_properties
59
+ end
60
+
61
+ # Check to see if the all the properties in the model are valid
62
+ # @return true if the model is valid
63
+ def valid?
64
+ true
65
+ end
66
+
67
+ # Checks equality by comparing each attribute.
68
+ # @param [Object] Object to be compared
69
+ def ==(o)
70
+ return true if self.equal?(o)
71
+ self.class == o.class &&
72
+ href == o.href &&
73
+ rel == o.rel
74
+ end
75
+
76
+ # @see the `==` method
77
+ # @param [Object] Object to be compared
78
+ def eql?(o)
79
+ self == o
80
+ end
81
+
82
+ # Calculates hash code according to all attributes.
83
+ # @return [Fixnum] Hash code
84
+ def hash
85
+ [href, rel].hash
86
+ end
87
+
88
+ # Builds the object from hash
89
+ # @param [Hash] attributes Model attributes in the form of hash
90
+ # @return [Object] Returns the model itself
91
+ def build_from_hash(attributes)
92
+ return nil unless attributes.is_a?(Hash)
93
+ self.class.swagger_types.each_pair do |key, type|
94
+ if type =~ /\AArray<(.*)>/i
95
+ # check to ensure the input is an array given that the attribute
96
+ # is documented as an array but the input is not
97
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
98
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
99
+ end
100
+ elsif !attributes[self.class.attribute_map[key]].nil?
101
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
102
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
103
+ end
104
+
105
+ self
106
+ end
107
+
108
+ # Deserializes the data based on type
109
+ # @param string type Data type
110
+ # @param string value Value to be deserialized
111
+ # @return [Object] Deserialized data
112
+ def _deserialize(type, value)
113
+ case type.to_sym
114
+ when :DateTime
115
+ DateTime.parse(value)
116
+ when :Date
117
+ Date.parse(value)
118
+ when :String
119
+ value.to_s
120
+ when :Integer
121
+ value.to_i
122
+ when :Float
123
+ value.to_f
124
+ when :BOOLEAN
125
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
126
+ true
127
+ else
128
+ false
129
+ end
130
+ when :Object
131
+ # generic object (usually a Hash), return directly
132
+ value
133
+ when /\AArray<(?<inner_type>.+)>\z/
134
+ inner_type = Regexp.last_match[:inner_type]
135
+ value.map { |v| _deserialize(inner_type, v) }
136
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
137
+ k_type = Regexp.last_match[:k_type]
138
+ v_type = Regexp.last_match[:v_type]
139
+ {}.tap do |hash|
140
+ value.each do |k, v|
141
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
142
+ end
143
+ end
144
+ else # model
145
+ temp_model = DdrClient.const_get(type).new
146
+ temp_model.build_from_hash(value)
147
+ end
148
+ end
149
+
150
+ # Returns the string representation of the object
151
+ # @return [String] String presentation of the object
152
+ def to_s
153
+ to_hash.to_s
154
+ end
155
+
156
+ # to_body is an alias to to_hash (backward compatibility)
157
+ # @return [Hash] Returns the object in the form of hash
158
+ def to_body
159
+ to_hash
160
+ end
161
+
162
+ # Returns the object in the form of hash
163
+ # @return [Hash] Returns the object in the form of hash
164
+ def to_hash
165
+ hash = {}
166
+ self.class.attribute_map.each_pair do |attr, param|
167
+ value = self.send(attr)
168
+ next if value.nil?
169
+ hash[param] = _to_hash(value)
170
+ end
171
+ hash
172
+ end
173
+
174
+ # Outputs non-array value in the form of hash
175
+ # For object, use to_hash. Otherwise, just return the value
176
+ # @param [Object] value Any valid value
177
+ # @return [Hash] Returns the value in the form of hash
178
+ def _to_hash(value)
179
+ if value.is_a?(Array)
180
+ value.compact.map { |v| _to_hash(v) }
181
+ elsif value.is_a?(Hash)
182
+ {}.tap do |hash|
183
+ value.each { |k, v| hash[k] = _to_hash(v) }
184
+ end
185
+ elsif value.respond_to? :to_hash
186
+ value.to_hash
187
+ else
188
+ value
189
+ end
190
+ end
191
+
192
+ end
193
+ end
@@ -0,0 +1,310 @@
1
+ =begin
2
+ #Duke Digital Repository API
3
+
4
+ #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.36
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DdrClient
16
+ # Ddr_API_ResourceEntity model
17
+ class DdrAPIResourceEntity
18
+ # Unique resource identifier assigned by the repository
19
+ attr_accessor :id
20
+
21
+ # The model type of the resource
22
+ attr_accessor :model
23
+
24
+ # Creation time of the database record (may differ from ingestion date)
25
+ attr_accessor :created_at
26
+
27
+ # Modification time of the database record
28
+ attr_accessor :updated_at
29
+
30
+ # Token required for update with optimistic locking
31
+ attr_accessor :optimistic_lock_token
32
+
33
+ attr_accessor :metadata
34
+
35
+ # Role-based access control assertions on the resource
36
+ attr_accessor :roles
37
+
38
+ attr_accessor :files
39
+
40
+ attr_accessor :related
41
+
42
+ attr_accessor :links
43
+
44
+ class EnumAttributeValidator
45
+ attr_reader :datatype
46
+ attr_reader :allowable_values
47
+
48
+ def initialize(datatype, allowable_values)
49
+ @allowable_values = allowable_values.map do |value|
50
+ case datatype.to_s
51
+ when /Integer/i
52
+ value.to_i
53
+ when /Float/i
54
+ value.to_f
55
+ else
56
+ value
57
+ end
58
+ end
59
+ end
60
+
61
+ def valid?(value)
62
+ !value || allowable_values.include?(value)
63
+ end
64
+ end
65
+
66
+ # Attribute mapping from ruby-style variable name to JSON key.
67
+ def self.attribute_map
68
+ {
69
+ :'id' => :'id',
70
+ :'model' => :'model',
71
+ :'created_at' => :'created_at',
72
+ :'updated_at' => :'updated_at',
73
+ :'optimistic_lock_token' => :'optimistic_lock_token',
74
+ :'metadata' => :'metadata',
75
+ :'roles' => :'roles',
76
+ :'files' => :'files',
77
+ :'related' => :'related',
78
+ :'links' => :'links'
79
+ }
80
+ end
81
+
82
+ # Attribute type mapping.
83
+ def self.swagger_types
84
+ {
85
+ :'id' => :'String',
86
+ :'model' => :'String',
87
+ :'created_at' => :'DateTime',
88
+ :'updated_at' => :'DateTime',
89
+ :'optimistic_lock_token' => :'String',
90
+ :'metadata' => :'DdrAPIResourceEntityMetadata',
91
+ :'roles' => :'Array<DdrAPIRoleEntity>',
92
+ :'files' => :'DdrAPIResourceEntityFiles',
93
+ :'related' => :'DdrAPIResourceEntityRelated',
94
+ :'links' => :'Array<DdrAPILinkEntity>'
95
+ }
96
+ end
97
+
98
+ # Initializes the object
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ def initialize(attributes = {})
101
+ return unless attributes.is_a?(Hash)
102
+
103
+ # convert string to symbol for hash key
104
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
105
+
106
+ if attributes.has_key?(:'id')
107
+ self.id = attributes[:'id']
108
+ end
109
+
110
+ if attributes.has_key?(:'model')
111
+ self.model = attributes[:'model']
112
+ end
113
+
114
+ if attributes.has_key?(:'created_at')
115
+ self.created_at = attributes[:'created_at']
116
+ end
117
+
118
+ if attributes.has_key?(:'updated_at')
119
+ self.updated_at = attributes[:'updated_at']
120
+ end
121
+
122
+ if attributes.has_key?(:'optimistic_lock_token')
123
+ self.optimistic_lock_token = attributes[:'optimistic_lock_token']
124
+ end
125
+
126
+ if attributes.has_key?(:'metadata')
127
+ self.metadata = attributes[:'metadata']
128
+ end
129
+
130
+ if attributes.has_key?(:'roles')
131
+ if (value = attributes[:'roles']).is_a?(Array)
132
+ self.roles = value
133
+ end
134
+ end
135
+
136
+ if attributes.has_key?(:'files')
137
+ self.files = attributes[:'files']
138
+ end
139
+
140
+ if attributes.has_key?(:'related')
141
+ self.related = attributes[:'related']
142
+ end
143
+
144
+ if attributes.has_key?(:'links')
145
+ if (value = attributes[:'links']).is_a?(Array)
146
+ self.links = value
147
+ end
148
+ end
149
+ end
150
+
151
+ # Show invalid properties with the reasons. Usually used together with valid?
152
+ # @return Array for valid properties with the reasons
153
+ def list_invalid_properties
154
+ invalid_properties = Array.new
155
+ invalid_properties
156
+ end
157
+
158
+ # Check to see if the all the properties in the model are valid
159
+ # @return true if the model is valid
160
+ def valid?
161
+ model_validator = EnumAttributeValidator.new('String', ['Collection', 'Item', 'Component', 'Target', 'Attachment'])
162
+ return false unless model_validator.valid?(@model)
163
+ true
164
+ end
165
+
166
+ # Custom attribute writer method checking allowed values (enum).
167
+ # @param [Object] model Object to be assigned
168
+ def model=(model)
169
+ validator = EnumAttributeValidator.new('String', ['Collection', 'Item', 'Component', 'Target', 'Attachment'])
170
+ unless validator.valid?(model)
171
+ fail ArgumentError, 'invalid value for "model", must be one of #{validator.allowable_values}.'
172
+ end
173
+ @model = model
174
+ end
175
+
176
+ # Checks equality by comparing each attribute.
177
+ # @param [Object] Object to be compared
178
+ def ==(o)
179
+ return true if self.equal?(o)
180
+ self.class == o.class &&
181
+ id == o.id &&
182
+ model == o.model &&
183
+ created_at == o.created_at &&
184
+ updated_at == o.updated_at &&
185
+ optimistic_lock_token == o.optimistic_lock_token &&
186
+ metadata == o.metadata &&
187
+ roles == o.roles &&
188
+ files == o.files &&
189
+ related == o.related &&
190
+ links == o.links
191
+ end
192
+
193
+ # @see the `==` method
194
+ # @param [Object] Object to be compared
195
+ def eql?(o)
196
+ self == o
197
+ end
198
+
199
+ # Calculates hash code according to all attributes.
200
+ # @return [Fixnum] Hash code
201
+ def hash
202
+ [id, model, created_at, updated_at, optimistic_lock_token, metadata, roles, files, related, links].hash
203
+ end
204
+
205
+ # Builds the object from hash
206
+ # @param [Hash] attributes Model attributes in the form of hash
207
+ # @return [Object] Returns the model itself
208
+ def build_from_hash(attributes)
209
+ return nil unless attributes.is_a?(Hash)
210
+ self.class.swagger_types.each_pair do |key, type|
211
+ if type =~ /\AArray<(.*)>/i
212
+ # check to ensure the input is an array given that the attribute
213
+ # is documented as an array but the input is not
214
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
215
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
216
+ end
217
+ elsif !attributes[self.class.attribute_map[key]].nil?
218
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
219
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
220
+ end
221
+
222
+ self
223
+ end
224
+
225
+ # Deserializes the data based on type
226
+ # @param string type Data type
227
+ # @param string value Value to be deserialized
228
+ # @return [Object] Deserialized data
229
+ def _deserialize(type, value)
230
+ case type.to_sym
231
+ when :DateTime
232
+ DateTime.parse(value)
233
+ when :Date
234
+ Date.parse(value)
235
+ when :String
236
+ value.to_s
237
+ when :Integer
238
+ value.to_i
239
+ when :Float
240
+ value.to_f
241
+ when :BOOLEAN
242
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
243
+ true
244
+ else
245
+ false
246
+ end
247
+ when :Object
248
+ # generic object (usually a Hash), return directly
249
+ value
250
+ when /\AArray<(?<inner_type>.+)>\z/
251
+ inner_type = Regexp.last_match[:inner_type]
252
+ value.map { |v| _deserialize(inner_type, v) }
253
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
254
+ k_type = Regexp.last_match[:k_type]
255
+ v_type = Regexp.last_match[:v_type]
256
+ {}.tap do |hash|
257
+ value.each do |k, v|
258
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
259
+ end
260
+ end
261
+ else # model
262
+ temp_model = DdrClient.const_get(type).new
263
+ temp_model.build_from_hash(value)
264
+ end
265
+ end
266
+
267
+ # Returns the string representation of the object
268
+ # @return [String] String presentation of the object
269
+ def to_s
270
+ to_hash.to_s
271
+ end
272
+
273
+ # to_body is an alias to to_hash (backward compatibility)
274
+ # @return [Hash] Returns the object in the form of hash
275
+ def to_body
276
+ to_hash
277
+ end
278
+
279
+ # Returns the object in the form of hash
280
+ # @return [Hash] Returns the object in the form of hash
281
+ def to_hash
282
+ hash = {}
283
+ self.class.attribute_map.each_pair do |attr, param|
284
+ value = self.send(attr)
285
+ next if value.nil?
286
+ hash[param] = _to_hash(value)
287
+ end
288
+ hash
289
+ end
290
+
291
+ # Outputs non-array value in the form of hash
292
+ # For object, use to_hash. Otherwise, just return the value
293
+ # @param [Object] value Any valid value
294
+ # @return [Hash] Returns the value in the form of hash
295
+ def _to_hash(value)
296
+ if value.is_a?(Array)
297
+ value.compact.map { |v| _to_hash(v) }
298
+ elsif value.is_a?(Hash)
299
+ {}.tap do |hash|
300
+ value.each { |k, v| hash[k] = _to_hash(v) }
301
+ end
302
+ elsif value.respond_to? :to_hash
303
+ value.to_hash
304
+ else
305
+ value
306
+ end
307
+ end
308
+
309
+ end
310
+ end