cloudmersive-dlp-api-client 2.2.0

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 (66) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.md +124 -0
  4. data/Rakefile +8 -0
  5. data/cloudmersive-dlp-api-client.gemspec +45 -0
  6. data/docs/DetectApi.md +232 -0
  7. data/docs/DlpAdvancedDetectionRequest.md +43 -0
  8. data/docs/DlpAdvancedDetectionResponse.md +44 -0
  9. data/docs/DlpAdvancedDocumentDetectionRequest.md +46 -0
  10. data/docs/DlpAdvancedDocumentRedactionRequest.md +47 -0
  11. data/docs/DlpAdvancedDocumentRedactionResponse.md +46 -0
  12. data/docs/DlpAdvancedRedactionRequest.md +44 -0
  13. data/docs/DlpAdvancedRedactionResponse.md +44 -0
  14. data/docs/DlpDetectionRequest.md +31 -0
  15. data/docs/DlpDetectionResponse.md +31 -0
  16. data/docs/DlpDocumentDetectionRequest.md +33 -0
  17. data/docs/DlpDocumentRedactionRequest.md +34 -0
  18. data/docs/DlpDocumentRedactionResponse.md +33 -0
  19. data/docs/DlpRedactionRequest.md +32 -0
  20. data/docs/DlpRedactionResponse.md +32 -0
  21. data/docs/RedactApi.md +232 -0
  22. data/docs/RedactedPageInfo.md +8 -0
  23. data/git_push.sh +55 -0
  24. data/lib/cloudmersive-dlp-api-client/api/detect_api.rb +223 -0
  25. data/lib/cloudmersive-dlp-api-client/api/redact_api.rb +223 -0
  26. data/lib/cloudmersive-dlp-api-client/api_client.rb +391 -0
  27. data/lib/cloudmersive-dlp-api-client/api_error.rb +38 -0
  28. data/lib/cloudmersive-dlp-api-client/configuration.rb +209 -0
  29. data/lib/cloudmersive-dlp-api-client/models/dlp_advanced_detection_request.rb +536 -0
  30. data/lib/cloudmersive-dlp-api-client/models/dlp_advanced_detection_response.rb +546 -0
  31. data/lib/cloudmersive-dlp-api-client/models/dlp_advanced_document_detection_request.rb +581 -0
  32. data/lib/cloudmersive-dlp-api-client/models/dlp_advanced_document_redaction_request.rb +591 -0
  33. data/lib/cloudmersive-dlp-api-client/models/dlp_advanced_document_redaction_response.rb +583 -0
  34. data/lib/cloudmersive-dlp-api-client/models/dlp_advanced_redaction_request.rb +546 -0
  35. data/lib/cloudmersive-dlp-api-client/models/dlp_advanced_redaction_response.rb +546 -0
  36. data/lib/cloudmersive-dlp-api-client/models/dlp_detection_request.rb +416 -0
  37. data/lib/cloudmersive-dlp-api-client/models/dlp_detection_response.rb +416 -0
  38. data/lib/cloudmersive-dlp-api-client/models/dlp_document_detection_request.rb +451 -0
  39. data/lib/cloudmersive-dlp-api-client/models/dlp_document_redaction_request.rb +461 -0
  40. data/lib/cloudmersive-dlp-api-client/models/dlp_document_redaction_response.rb +453 -0
  41. data/lib/cloudmersive-dlp-api-client/models/dlp_redaction_request.rb +426 -0
  42. data/lib/cloudmersive-dlp-api-client/models/dlp_redaction_response.rb +426 -0
  43. data/lib/cloudmersive-dlp-api-client/models/redacted_page_info.rb +186 -0
  44. data/lib/cloudmersive-dlp-api-client/version.rb +15 -0
  45. data/lib/cloudmersive-dlp-api-client.rb +56 -0
  46. data/spec/api/detect_api_spec.rb +83 -0
  47. data/spec/api/redact_api_spec.rb +83 -0
  48. data/spec/api_client_spec.rb +243 -0
  49. data/spec/configuration_spec.rb +42 -0
  50. data/spec/models/dlp_advanced_detection_request_spec.rb +251 -0
  51. data/spec/models/dlp_advanced_detection_response_spec.rb +257 -0
  52. data/spec/models/dlp_advanced_document_detection_request_spec.rb +269 -0
  53. data/spec/models/dlp_advanced_document_redaction_request_spec.rb +275 -0
  54. data/spec/models/dlp_advanced_document_redaction_response_spec.rb +269 -0
  55. data/spec/models/dlp_advanced_redaction_request_spec.rb +257 -0
  56. data/spec/models/dlp_advanced_redaction_response_spec.rb +257 -0
  57. data/spec/models/dlp_detection_request_spec.rb +179 -0
  58. data/spec/models/dlp_detection_response_spec.rb +179 -0
  59. data/spec/models/dlp_document_detection_request_spec.rb +191 -0
  60. data/spec/models/dlp_document_redaction_request_spec.rb +197 -0
  61. data/spec/models/dlp_document_redaction_response_spec.rb +191 -0
  62. data/spec/models/dlp_redaction_request_spec.rb +185 -0
  63. data/spec/models/dlp_redaction_response_spec.rb +185 -0
  64. data/spec/models/redacted_page_info_spec.rb +41 -0
  65. data/spec/spec_helper.rb +111 -0
  66. metadata +290 -0
@@ -0,0 +1,451 @@
1
+ =begin
2
+ #dlpapi
3
+
4
+ #Easily and directly scan and detect sensitive data (PII) in input text.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.14
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CloudmersiveDlpApiClient
16
+ # Request object for DLP document detection with 23 PII detection types.
17
+ class DlpDocumentDetectionRequest
18
+ # Document file bytes (PDF, DOCX, PNG, or JPG) to scan for PII and sensitive data.
19
+ attr_accessor :input_file
20
+
21
+ # Optional. Name of the input file including extension, used for format detection. If not provided, format is detected from file contents.
22
+ attr_accessor :file_name
23
+
24
+ # Optional. Recognition mode for image processing. Options: null (default), \"Fast\", \"FastPlus\", \"FastMini\".
25
+ attr_accessor :recognition_mode
26
+
27
+ # Set to true to allow email addresses in the document and not flag them as PII.
28
+ attr_accessor :allow_email_address
29
+
30
+ # Set to true to allow phone numbers in the document and not flag them as PII.
31
+ attr_accessor :allow_phone_number
32
+
33
+ # Set to true to allow street addresses in the document and not flag them as PII.
34
+ attr_accessor :allow_street_address
35
+
36
+ # Set to true to allow person names in the document and not flag them as PII.
37
+ attr_accessor :allow_person_name
38
+
39
+ # Set to true to allow birth dates in the document and not flag them as PII.
40
+ attr_accessor :allow_birth_date
41
+
42
+ # Set to true to allow passport numbers in the document and not flag them as PII.
43
+ attr_accessor :allow_passport_number
44
+
45
+ # Set to true to allow drivers license numbers in the document and not flag them as PII.
46
+ attr_accessor :allow_drivers_license
47
+
48
+ # Set to true to allow social security numbers in the document and not flag them as PII.
49
+ attr_accessor :allow_social_security_number
50
+
51
+ # Set to true to allow taxpayer IDs in the document and not flag them as PII.
52
+ attr_accessor :allow_taxpayer_id
53
+
54
+ # Set to true to allow credit card numbers in the document and not flag them as PII.
55
+ attr_accessor :allow_credit_card_number
56
+
57
+ # Set to true to allow credit card expiration dates in the document and not flag them as PII.
58
+ attr_accessor :allow_credit_card_expiration_date
59
+
60
+ # Set to true to allow credit card verification codes in the document and not flag them as PII.
61
+ attr_accessor :allow_credit_card_verification_code
62
+
63
+ # Set to true to allow bank account numbers in the document and not flag them as PII.
64
+ attr_accessor :allow_bank_account_number
65
+
66
+ # Set to true to allow IBANs in the document and not flag them as PII.
67
+ attr_accessor :allow_iban
68
+
69
+ # Set to true to allow health insurance numbers in the document and not flag them as PII.
70
+ attr_accessor :allow_health_insurance_number
71
+
72
+ # Set to true to allow bearer tokens in the document and not flag them as PII.
73
+ attr_accessor :allow_bearer_token
74
+
75
+ # Set to true to allow HTTP cookies in the document and not flag them as PII.
76
+ attr_accessor :allow_http_cookie
77
+
78
+ # Set to true to allow private keys in the document and not flag them as PII.
79
+ attr_accessor :allow_private_keys
80
+
81
+ # Set to true to allow credentials (usernames/passwords) in the document and not flag them as PII.
82
+ attr_accessor :allow_credentials
83
+
84
+ # Set to true to allow deep web URLs (.onion) in the document and not flag them as PII.
85
+ attr_accessor :allow_deep_web_urls
86
+
87
+ # Set to true to allow source code in the document and not flag it as sensitive data.
88
+ attr_accessor :allow_source_code
89
+
90
+ # Set to true to allow IP addresses in the document and not flag them as PII.
91
+ attr_accessor :allow_ip_address
92
+
93
+ # Set to true to allow MAC addresses in the document and not flag them as PII.
94
+ attr_accessor :allow_mac_address
95
+
96
+ # Attribute mapping from ruby-style variable name to JSON key.
97
+ def self.attribute_map
98
+ {
99
+ :'input_file' => :'InputFile',
100
+ :'file_name' => :'FileName',
101
+ :'recognition_mode' => :'RecognitionMode',
102
+ :'allow_email_address' => :'AllowEmailAddress',
103
+ :'allow_phone_number' => :'AllowPhoneNumber',
104
+ :'allow_street_address' => :'AllowStreetAddress',
105
+ :'allow_person_name' => :'AllowPersonName',
106
+ :'allow_birth_date' => :'AllowBirthDate',
107
+ :'allow_passport_number' => :'AllowPassportNumber',
108
+ :'allow_drivers_license' => :'AllowDriversLicense',
109
+ :'allow_social_security_number' => :'AllowSocialSecurityNumber',
110
+ :'allow_taxpayer_id' => :'AllowTaxpayerID',
111
+ :'allow_credit_card_number' => :'AllowCreditCardNumber',
112
+ :'allow_credit_card_expiration_date' => :'AllowCreditCardExpirationDate',
113
+ :'allow_credit_card_verification_code' => :'AllowCreditCardVerificationCode',
114
+ :'allow_bank_account_number' => :'AllowBankAccountNumber',
115
+ :'allow_iban' => :'AllowIBAN',
116
+ :'allow_health_insurance_number' => :'AllowHealthInsuranceNumber',
117
+ :'allow_bearer_token' => :'AllowBearerToken',
118
+ :'allow_http_cookie' => :'AllowHttpCookie',
119
+ :'allow_private_keys' => :'AllowPrivateKeys',
120
+ :'allow_credentials' => :'AllowCredentials',
121
+ :'allow_deep_web_urls' => :'AllowDeepWebUrls',
122
+ :'allow_source_code' => :'AllowSourceCode',
123
+ :'allow_ip_address' => :'AllowIpAddress',
124
+ :'allow_mac_address' => :'AllowMacAddress'
125
+ }
126
+ end
127
+
128
+ # Attribute type mapping.
129
+ def self.swagger_types
130
+ {
131
+ :'input_file' => :'String',
132
+ :'file_name' => :'String',
133
+ :'recognition_mode' => :'String',
134
+ :'allow_email_address' => :'BOOLEAN',
135
+ :'allow_phone_number' => :'BOOLEAN',
136
+ :'allow_street_address' => :'BOOLEAN',
137
+ :'allow_person_name' => :'BOOLEAN',
138
+ :'allow_birth_date' => :'BOOLEAN',
139
+ :'allow_passport_number' => :'BOOLEAN',
140
+ :'allow_drivers_license' => :'BOOLEAN',
141
+ :'allow_social_security_number' => :'BOOLEAN',
142
+ :'allow_taxpayer_id' => :'BOOLEAN',
143
+ :'allow_credit_card_number' => :'BOOLEAN',
144
+ :'allow_credit_card_expiration_date' => :'BOOLEAN',
145
+ :'allow_credit_card_verification_code' => :'BOOLEAN',
146
+ :'allow_bank_account_number' => :'BOOLEAN',
147
+ :'allow_iban' => :'BOOLEAN',
148
+ :'allow_health_insurance_number' => :'BOOLEAN',
149
+ :'allow_bearer_token' => :'BOOLEAN',
150
+ :'allow_http_cookie' => :'BOOLEAN',
151
+ :'allow_private_keys' => :'BOOLEAN',
152
+ :'allow_credentials' => :'BOOLEAN',
153
+ :'allow_deep_web_urls' => :'BOOLEAN',
154
+ :'allow_source_code' => :'BOOLEAN',
155
+ :'allow_ip_address' => :'BOOLEAN',
156
+ :'allow_mac_address' => :'BOOLEAN'
157
+ }
158
+ end
159
+
160
+ # Initializes the object
161
+ # @param [Hash] attributes Model attributes in the form of hash
162
+ def initialize(attributes = {})
163
+ return unless attributes.is_a?(Hash)
164
+
165
+ # convert string to symbol for hash key
166
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
167
+
168
+ if attributes.has_key?(:'InputFile')
169
+ self.input_file = attributes[:'InputFile']
170
+ end
171
+
172
+ if attributes.has_key?(:'FileName')
173
+ self.file_name = attributes[:'FileName']
174
+ end
175
+
176
+ if attributes.has_key?(:'RecognitionMode')
177
+ self.recognition_mode = attributes[:'RecognitionMode']
178
+ end
179
+
180
+ if attributes.has_key?(:'AllowEmailAddress')
181
+ self.allow_email_address = attributes[:'AllowEmailAddress']
182
+ end
183
+
184
+ if attributes.has_key?(:'AllowPhoneNumber')
185
+ self.allow_phone_number = attributes[:'AllowPhoneNumber']
186
+ end
187
+
188
+ if attributes.has_key?(:'AllowStreetAddress')
189
+ self.allow_street_address = attributes[:'AllowStreetAddress']
190
+ end
191
+
192
+ if attributes.has_key?(:'AllowPersonName')
193
+ self.allow_person_name = attributes[:'AllowPersonName']
194
+ end
195
+
196
+ if attributes.has_key?(:'AllowBirthDate')
197
+ self.allow_birth_date = attributes[:'AllowBirthDate']
198
+ end
199
+
200
+ if attributes.has_key?(:'AllowPassportNumber')
201
+ self.allow_passport_number = attributes[:'AllowPassportNumber']
202
+ end
203
+
204
+ if attributes.has_key?(:'AllowDriversLicense')
205
+ self.allow_drivers_license = attributes[:'AllowDriversLicense']
206
+ end
207
+
208
+ if attributes.has_key?(:'AllowSocialSecurityNumber')
209
+ self.allow_social_security_number = attributes[:'AllowSocialSecurityNumber']
210
+ end
211
+
212
+ if attributes.has_key?(:'AllowTaxpayerID')
213
+ self.allow_taxpayer_id = attributes[:'AllowTaxpayerID']
214
+ end
215
+
216
+ if attributes.has_key?(:'AllowCreditCardNumber')
217
+ self.allow_credit_card_number = attributes[:'AllowCreditCardNumber']
218
+ end
219
+
220
+ if attributes.has_key?(:'AllowCreditCardExpirationDate')
221
+ self.allow_credit_card_expiration_date = attributes[:'AllowCreditCardExpirationDate']
222
+ end
223
+
224
+ if attributes.has_key?(:'AllowCreditCardVerificationCode')
225
+ self.allow_credit_card_verification_code = attributes[:'AllowCreditCardVerificationCode']
226
+ end
227
+
228
+ if attributes.has_key?(:'AllowBankAccountNumber')
229
+ self.allow_bank_account_number = attributes[:'AllowBankAccountNumber']
230
+ end
231
+
232
+ if attributes.has_key?(:'AllowIBAN')
233
+ self.allow_iban = attributes[:'AllowIBAN']
234
+ end
235
+
236
+ if attributes.has_key?(:'AllowHealthInsuranceNumber')
237
+ self.allow_health_insurance_number = attributes[:'AllowHealthInsuranceNumber']
238
+ end
239
+
240
+ if attributes.has_key?(:'AllowBearerToken')
241
+ self.allow_bearer_token = attributes[:'AllowBearerToken']
242
+ end
243
+
244
+ if attributes.has_key?(:'AllowHttpCookie')
245
+ self.allow_http_cookie = attributes[:'AllowHttpCookie']
246
+ end
247
+
248
+ if attributes.has_key?(:'AllowPrivateKeys')
249
+ self.allow_private_keys = attributes[:'AllowPrivateKeys']
250
+ end
251
+
252
+ if attributes.has_key?(:'AllowCredentials')
253
+ self.allow_credentials = attributes[:'AllowCredentials']
254
+ end
255
+
256
+ if attributes.has_key?(:'AllowDeepWebUrls')
257
+ self.allow_deep_web_urls = attributes[:'AllowDeepWebUrls']
258
+ end
259
+
260
+ if attributes.has_key?(:'AllowSourceCode')
261
+ self.allow_source_code = attributes[:'AllowSourceCode']
262
+ end
263
+
264
+ if attributes.has_key?(:'AllowIpAddress')
265
+ self.allow_ip_address = attributes[:'AllowIpAddress']
266
+ end
267
+
268
+ if attributes.has_key?(:'AllowMacAddress')
269
+ self.allow_mac_address = attributes[:'AllowMacAddress']
270
+ end
271
+ end
272
+
273
+ # Show invalid properties with the reasons. Usually used together with valid?
274
+ # @return Array for valid properties with the reasons
275
+ def list_invalid_properties
276
+ invalid_properties = Array.new
277
+ if !@input_file.nil? && @input_file !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
278
+ invalid_properties.push('invalid value for "input_file", must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.')
279
+ end
280
+
281
+ invalid_properties
282
+ end
283
+
284
+ # Check to see if the all the properties in the model are valid
285
+ # @return true if the model is valid
286
+ def valid?
287
+ return false if !@input_file.nil? && @input_file !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
288
+ true
289
+ end
290
+
291
+ # Custom attribute writer method with validation
292
+ # @param [Object] input_file Value to be assigned
293
+ def input_file=(input_file)
294
+ if !input_file.nil? && input_file !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
295
+ fail ArgumentError, 'invalid value for "input_file", must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.'
296
+ end
297
+
298
+ @input_file = input_file
299
+ end
300
+
301
+ # Checks equality by comparing each attribute.
302
+ # @param [Object] Object to be compared
303
+ def ==(o)
304
+ return true if self.equal?(o)
305
+ self.class == o.class &&
306
+ input_file == o.input_file &&
307
+ file_name == o.file_name &&
308
+ recognition_mode == o.recognition_mode &&
309
+ allow_email_address == o.allow_email_address &&
310
+ allow_phone_number == o.allow_phone_number &&
311
+ allow_street_address == o.allow_street_address &&
312
+ allow_person_name == o.allow_person_name &&
313
+ allow_birth_date == o.allow_birth_date &&
314
+ allow_passport_number == o.allow_passport_number &&
315
+ allow_drivers_license == o.allow_drivers_license &&
316
+ allow_social_security_number == o.allow_social_security_number &&
317
+ allow_taxpayer_id == o.allow_taxpayer_id &&
318
+ allow_credit_card_number == o.allow_credit_card_number &&
319
+ allow_credit_card_expiration_date == o.allow_credit_card_expiration_date &&
320
+ allow_credit_card_verification_code == o.allow_credit_card_verification_code &&
321
+ allow_bank_account_number == o.allow_bank_account_number &&
322
+ allow_iban == o.allow_iban &&
323
+ allow_health_insurance_number == o.allow_health_insurance_number &&
324
+ allow_bearer_token == o.allow_bearer_token &&
325
+ allow_http_cookie == o.allow_http_cookie &&
326
+ allow_private_keys == o.allow_private_keys &&
327
+ allow_credentials == o.allow_credentials &&
328
+ allow_deep_web_urls == o.allow_deep_web_urls &&
329
+ allow_source_code == o.allow_source_code &&
330
+ allow_ip_address == o.allow_ip_address &&
331
+ allow_mac_address == o.allow_mac_address
332
+ end
333
+
334
+ # @see the `==` method
335
+ # @param [Object] Object to be compared
336
+ def eql?(o)
337
+ self == o
338
+ end
339
+
340
+ # Calculates hash code according to all attributes.
341
+ # @return [Fixnum] Hash code
342
+ def hash
343
+ [input_file, file_name, recognition_mode, allow_email_address, allow_phone_number, allow_street_address, allow_person_name, allow_birth_date, allow_passport_number, allow_drivers_license, allow_social_security_number, allow_taxpayer_id, allow_credit_card_number, allow_credit_card_expiration_date, allow_credit_card_verification_code, allow_bank_account_number, allow_iban, allow_health_insurance_number, allow_bearer_token, allow_http_cookie, allow_private_keys, allow_credentials, allow_deep_web_urls, allow_source_code, allow_ip_address, allow_mac_address].hash
344
+ end
345
+
346
+ # Builds the object from hash
347
+ # @param [Hash] attributes Model attributes in the form of hash
348
+ # @return [Object] Returns the model itself
349
+ def build_from_hash(attributes)
350
+ return nil unless attributes.is_a?(Hash)
351
+ self.class.swagger_types.each_pair do |key, type|
352
+ if type =~ /\AArray<(.*)>/i
353
+ # check to ensure the input is an array given that the attribute
354
+ # is documented as an array but the input is not
355
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
356
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
357
+ end
358
+ elsif !attributes[self.class.attribute_map[key]].nil?
359
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
360
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
361
+ end
362
+
363
+ self
364
+ end
365
+
366
+ # Deserializes the data based on type
367
+ # @param string type Data type
368
+ # @param string value Value to be deserialized
369
+ # @return [Object] Deserialized data
370
+ def _deserialize(type, value)
371
+ case type.to_sym
372
+ when :DateTime
373
+ DateTime.parse(value)
374
+ when :Date
375
+ Date.parse(value)
376
+ when :String
377
+ value.to_s
378
+ when :Integer
379
+ value.to_i
380
+ when :Float
381
+ value.to_f
382
+ when :BOOLEAN
383
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
384
+ true
385
+ else
386
+ false
387
+ end
388
+ when :Object
389
+ # generic object (usually a Hash), return directly
390
+ value
391
+ when /\AArray<(?<inner_type>.+)>\z/
392
+ inner_type = Regexp.last_match[:inner_type]
393
+ value.map { |v| _deserialize(inner_type, v) }
394
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
395
+ k_type = Regexp.last_match[:k_type]
396
+ v_type = Regexp.last_match[:v_type]
397
+ {}.tap do |hash|
398
+ value.each do |k, v|
399
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
400
+ end
401
+ end
402
+ else # model
403
+ temp_model = CloudmersiveDlpApiClient.const_get(type).new
404
+ temp_model.build_from_hash(value)
405
+ end
406
+ end
407
+
408
+ # Returns the string representation of the object
409
+ # @return [String] String presentation of the object
410
+ def to_s
411
+ to_hash.to_s
412
+ end
413
+
414
+ # to_body is an alias to to_hash (backward compatibility)
415
+ # @return [Hash] Returns the object in the form of hash
416
+ def to_body
417
+ to_hash
418
+ end
419
+
420
+ # Returns the object in the form of hash
421
+ # @return [Hash] Returns the object in the form of hash
422
+ def to_hash
423
+ hash = {}
424
+ self.class.attribute_map.each_pair do |attr, param|
425
+ value = self.send(attr)
426
+ next if value.nil?
427
+ hash[param] = _to_hash(value)
428
+ end
429
+ hash
430
+ end
431
+
432
+ # Outputs non-array value in the form of hash
433
+ # For object, use to_hash. Otherwise, just return the value
434
+ # @param [Object] value Any valid value
435
+ # @return [Hash] Returns the value in the form of hash
436
+ def _to_hash(value)
437
+ if value.is_a?(Array)
438
+ value.compact.map { |v| _to_hash(v) }
439
+ elsif value.is_a?(Hash)
440
+ {}.tap do |hash|
441
+ value.each { |k, v| hash[k] = _to_hash(v) }
442
+ end
443
+ elsif value.respond_to? :to_hash
444
+ value.to_hash
445
+ else
446
+ value
447
+ end
448
+ end
449
+
450
+ end
451
+ end