mailslurp_client 8.0.6 → 8.0.12

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 (90) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +7 -0
  3. data/README.md +117 -0
  4. data/SECURITY.md +4 -0
  5. data/SUPPORT.md +4 -0
  6. data/lib/mailslurp_client/api/alias_controller_api.rb +405 -0
  7. data/lib/mailslurp_client/api/attachment_controller_api.rb +160 -0
  8. data/lib/mailslurp_client/api/bulk_actions_controller_api.rb +203 -0
  9. data/lib/mailslurp_client/api/common_actions_controller_api.rb +257 -0
  10. data/lib/mailslurp_client/api/contact_controller_api.rb +323 -0
  11. data/lib/mailslurp_client/api/domain_controller_api.rb +264 -0
  12. data/lib/mailslurp_client/api/email_controller_api.rb +852 -0
  13. data/lib/mailslurp_client/api/form_controller_api.rb +104 -0
  14. data/lib/mailslurp_client/api/group_controller_api.rb +592 -0
  15. data/lib/mailslurp_client/api/inbox_controller_api.rb +897 -0
  16. data/lib/mailslurp_client/api/mail_server_controller_api.rb +146 -0
  17. data/lib/mailslurp_client/api/sent_emails_controller_api.rb +152 -0
  18. data/lib/mailslurp_client/api/template_controller_api.rb +323 -0
  19. data/lib/mailslurp_client/api/wait_for_controller_api.rb +359 -0
  20. data/lib/mailslurp_client/api/webhook_controller_api.rb +405 -0
  21. data/lib/mailslurp_client/api_client.rb +388 -0
  22. data/lib/mailslurp_client/api_error.rb +57 -0
  23. data/lib/mailslurp_client/configuration.rb +248 -0
  24. data/lib/mailslurp_client/models/attachment_meta_data.rb +238 -0
  25. data/lib/mailslurp_client/models/basic_auth_options.rb +226 -0
  26. data/lib/mailslurp_client/models/bulk_send_email_options.rb +219 -0
  27. data/lib/mailslurp_client/models/contact_dto.rb +311 -0
  28. data/lib/mailslurp_client/models/contact_projection.rb +270 -0
  29. data/lib/mailslurp_client/models/create_anonymous_alias_options.rb +208 -0
  30. data/lib/mailslurp_client/models/create_contact_options.rb +277 -0
  31. data/lib/mailslurp_client/models/create_domain_options.rb +208 -0
  32. data/lib/mailslurp_client/models/create_group_options.rb +220 -0
  33. data/lib/mailslurp_client/models/create_owned_alias_options.rb +238 -0
  34. data/lib/mailslurp_client/models/create_template_options.rb +225 -0
  35. data/lib/mailslurp_client/models/create_webhook_options.rb +227 -0
  36. data/lib/mailslurp_client/models/describe_domain_options.rb +211 -0
  37. data/lib/mailslurp_client/models/describe_mail_server_domain_result.rb +237 -0
  38. data/lib/mailslurp_client/models/domain_dto.rb +296 -0
  39. data/lib/mailslurp_client/models/domain_preview.rb +240 -0
  40. data/lib/mailslurp_client/models/email.rb +386 -0
  41. data/lib/mailslurp_client/models/email_analysis.rb +248 -0
  42. data/lib/mailslurp_client/models/email_preview.rb +296 -0
  43. data/lib/mailslurp_client/models/email_projection.rb +325 -0
  44. data/lib/mailslurp_client/models/email_verification_result.rb +263 -0
  45. data/lib/mailslurp_client/models/forward_email_options.rb +244 -0
  46. data/lib/mailslurp_client/models/group_contacts_dto.rb +227 -0
  47. data/lib/mailslurp_client/models/group_dto.rb +248 -0
  48. data/lib/mailslurp_client/models/group_projection.rb +248 -0
  49. data/lib/mailslurp_client/models/html_validation_result.rb +244 -0
  50. data/lib/mailslurp_client/models/inbox.rb +290 -0
  51. data/lib/mailslurp_client/models/inbox_projection.rb +263 -0
  52. data/lib/mailslurp_client/models/match_option.rb +274 -0
  53. data/lib/mailslurp_client/models/match_options.rb +210 -0
  54. data/lib/mailslurp_client/models/model_alias.rb +284 -0
  55. data/lib/mailslurp_client/models/name_server_record.rb +254 -0
  56. data/lib/mailslurp_client/models/page_alias.rb +298 -0
  57. data/lib/mailslurp_client/models/page_contact_projection.rb +298 -0
  58. data/lib/mailslurp_client/models/page_email_preview.rb +298 -0
  59. data/lib/mailslurp_client/models/page_email_projection.rb +298 -0
  60. data/lib/mailslurp_client/models/page_group_projection.rb +298 -0
  61. data/lib/mailslurp_client/models/page_inbox_projection.rb +298 -0
  62. data/lib/mailslurp_client/models/page_sent_email_projection.rb +298 -0
  63. data/lib/mailslurp_client/models/page_template_projection.rb +298 -0
  64. data/lib/mailslurp_client/models/page_webhook_projection.rb +298 -0
  65. data/lib/mailslurp_client/models/pageable.rb +251 -0
  66. data/lib/mailslurp_client/models/raw_email_json.rb +211 -0
  67. data/lib/mailslurp_client/models/send_email_options.rb +392 -0
  68. data/lib/mailslurp_client/models/sent_email_dto.rb +351 -0
  69. data/lib/mailslurp_client/models/sent_email_projection.rb +344 -0
  70. data/lib/mailslurp_client/models/set_inbox_favourited_options.rb +208 -0
  71. data/lib/mailslurp_client/models/simple_send_email_options.rb +237 -0
  72. data/lib/mailslurp_client/models/sort.rb +224 -0
  73. data/lib/mailslurp_client/models/template_dto.rb +269 -0
  74. data/lib/mailslurp_client/models/template_projection.rb +269 -0
  75. data/lib/mailslurp_client/models/template_variable.rb +259 -0
  76. data/lib/mailslurp_client/models/unread_count.rb +211 -0
  77. data/lib/mailslurp_client/models/update_group_contacts.rb +213 -0
  78. data/lib/mailslurp_client/models/update_inbox_options.rb +250 -0
  79. data/lib/mailslurp_client/models/upload_attachment_options.rb +228 -0
  80. data/lib/mailslurp_client/models/validation_dto.rb +217 -0
  81. data/lib/mailslurp_client/models/validation_message.rb +220 -0
  82. data/lib/mailslurp_client/models/verify_email_address_options.rb +239 -0
  83. data/lib/mailslurp_client/models/wait_for_conditions.rb +316 -0
  84. data/lib/mailslurp_client/models/webhook_dto.rb +326 -0
  85. data/lib/mailslurp_client/models/webhook_projection.rb +277 -0
  86. data/lib/mailslurp_client/models/webhook_test_request.rb +284 -0
  87. data/lib/mailslurp_client/models/webhook_test_response.rb +215 -0
  88. data/lib/mailslurp_client/models/webhook_test_result.rb +235 -0
  89. data/lib/mailslurp_client/version.rb +15 -0
  90. metadata +90 -2
@@ -0,0 +1,239 @@
1
+ =begin
2
+ #MailSlurp API
3
+
4
+ #MailSlurp is an API for sending and receiving emails from dynamically allocated email addresses. It's designed for developers and QA teams to test applications, process inbound emails, send templated notifications, attachments, and more. ## Resources - [Homepage](https://www.mailslurp.com) - Get an [API KEY](https://app.mailslurp.com/sign-up/) - Generated [SDK Clients](https://www.mailslurp.com/docs/) - [Examples](https://github.com/mailslurp/examples) repository
5
+
6
+ The version of the OpenAPI document: 6.5.2
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module MailSlurpClient
16
+ # Options for verifying that an email address exists at a remote mail server.
17
+ class VerifyEmailAddressOptions
18
+ attr_accessor :mail_server_domain
19
+
20
+ attr_accessor :email_address
21
+
22
+ attr_accessor :sender_email_address
23
+
24
+ attr_accessor :port
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'mail_server_domain' => :'mailServerDomain',
30
+ :'email_address' => :'emailAddress',
31
+ :'sender_email_address' => :'senderEmailAddress',
32
+ :'port' => :'port'
33
+ }
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'mail_server_domain' => :'String',
40
+ :'email_address' => :'String',
41
+ :'sender_email_address' => :'String',
42
+ :'port' => :'Integer'
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ ])
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ if (!attributes.is_a?(Hash))
56
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::VerifyEmailAddressOptions` initialize method"
57
+ end
58
+
59
+ # check to see if the attribute exists and convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!self.class.attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::VerifyEmailAddressOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'mail_server_domain')
68
+ self.mail_server_domain = attributes[:'mail_server_domain']
69
+ end
70
+
71
+ if attributes.key?(:'email_address')
72
+ self.email_address = attributes[:'email_address']
73
+ end
74
+
75
+ if attributes.key?(:'sender_email_address')
76
+ self.sender_email_address = attributes[:'sender_email_address']
77
+ end
78
+
79
+ if attributes.key?(:'port')
80
+ self.port = attributes[:'port']
81
+ end
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properties with the reasons
86
+ def list_invalid_properties
87
+ invalid_properties = Array.new
88
+ if @email_address.nil?
89
+ invalid_properties.push('invalid value for "email_address", email_address cannot be nil.')
90
+ end
91
+
92
+ invalid_properties
93
+ end
94
+
95
+ # Check to see if the all the properties in the model are valid
96
+ # @return true if the model is valid
97
+ def valid?
98
+ return false if @email_address.nil?
99
+ true
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(o)
105
+ return true if self.equal?(o)
106
+ self.class == o.class &&
107
+ mail_server_domain == o.mail_server_domain &&
108
+ email_address == o.email_address &&
109
+ sender_email_address == o.sender_email_address &&
110
+ port == o.port
111
+ end
112
+
113
+ # @see the `==` method
114
+ # @param [Object] Object to be compared
115
+ def eql?(o)
116
+ self == o
117
+ end
118
+
119
+ # Calculates hash code according to all attributes.
120
+ # @return [Integer] Hash code
121
+ def hash
122
+ [mail_server_domain, email_address, sender_email_address, port].hash
123
+ end
124
+
125
+ # Builds the object from hash
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ # @return [Object] Returns the model itself
128
+ def self.build_from_hash(attributes)
129
+ new.build_from_hash(attributes)
130
+ end
131
+
132
+ # Builds the object from hash
133
+ # @param [Hash] attributes Model attributes in the form of hash
134
+ # @return [Object] Returns the model itself
135
+ def build_from_hash(attributes)
136
+ return nil unless attributes.is_a?(Hash)
137
+ self.class.openapi_types.each_pair do |key, type|
138
+ if type =~ /\AArray<(.*)>/i
139
+ # check to ensure the input is an array given that the attribute
140
+ # is documented as an array but the input is not
141
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
142
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
143
+ end
144
+ elsif !attributes[self.class.attribute_map[key]].nil?
145
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
146
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
147
+ end
148
+
149
+ self
150
+ end
151
+
152
+ # Deserializes the data based on type
153
+ # @param string type Data type
154
+ # @param string value Value to be deserialized
155
+ # @return [Object] Deserialized data
156
+ def _deserialize(type, value)
157
+ case type.to_sym
158
+ when :DateTime
159
+ DateTime.parse(value)
160
+ when :Date
161
+ Date.parse(value)
162
+ when :String
163
+ value.to_s
164
+ when :Integer
165
+ value.to_i
166
+ when :Float
167
+ value.to_f
168
+ when :Boolean
169
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
170
+ true
171
+ else
172
+ false
173
+ end
174
+ when :Object
175
+ # generic object (usually a Hash), return directly
176
+ value
177
+ when /\AArray<(?<inner_type>.+)>\z/
178
+ inner_type = Regexp.last_match[:inner_type]
179
+ value.map { |v| _deserialize(inner_type, v) }
180
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
181
+ k_type = Regexp.last_match[:k_type]
182
+ v_type = Regexp.last_match[:v_type]
183
+ {}.tap do |hash|
184
+ value.each do |k, v|
185
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
186
+ end
187
+ end
188
+ else # model
189
+ MailSlurpClient.const_get(type).build_from_hash(value)
190
+ end
191
+ end
192
+
193
+ # Returns the string representation of the object
194
+ # @return [String] String presentation of the object
195
+ def to_s
196
+ to_hash.to_s
197
+ end
198
+
199
+ # to_body is an alias to to_hash (backward compatibility)
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_body
202
+ to_hash
203
+ end
204
+
205
+ # Returns the object in the form of hash
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_hash
208
+ hash = {}
209
+ self.class.attribute_map.each_pair do |attr, param|
210
+ value = self.send(attr)
211
+ if value.nil?
212
+ is_nullable = self.class.openapi_nullable.include?(attr)
213
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
214
+ end
215
+
216
+ hash[param] = _to_hash(value)
217
+ end
218
+ hash
219
+ end
220
+
221
+ # Outputs non-array value in the form of hash
222
+ # For object, use to_hash. Otherwise, just return the value
223
+ # @param [Object] value Any valid value
224
+ # @return [Hash] Returns the value in the form of hash
225
+ def _to_hash(value)
226
+ if value.is_a?(Array)
227
+ value.compact.map { |v| _to_hash(v) }
228
+ elsif value.is_a?(Hash)
229
+ {}.tap do |hash|
230
+ value.each { |k, v| hash[k] = _to_hash(v) }
231
+ end
232
+ elsif value.respond_to? :to_hash
233
+ value.to_hash
234
+ else
235
+ value
236
+ end
237
+ end
238
+ end
239
+ end
@@ -0,0 +1,316 @@
1
+ =begin
2
+ #MailSlurp API
3
+
4
+ #MailSlurp is an API for sending and receiving emails from dynamically allocated email addresses. It's designed for developers and QA teams to test applications, process inbound emails, send templated notifications, attachments, and more. ## Resources - [Homepage](https://www.mailslurp.com) - Get an [API KEY](https://app.mailslurp.com/sign-up/) - Generated [SDK Clients](https://www.mailslurp.com/docs/) - [Examples](https://github.com/mailslurp/examples) repository
5
+
6
+ The version of the OpenAPI document: 6.5.2
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module MailSlurpClient
16
+ # Conditions that a `waitForXEmails` endpoint operates on. The methods wait until given conditions are met or a timeout is reached. If the conditions are met without needing to wait the results will be returned immediately.
17
+ class WaitForConditions
18
+ # Number of results that should match conditions. Either exactly or at least this amount based on the `countType`. If count condition is not met and the timeout has not been reached the `waitFor` method will retry the operation.
19
+ attr_accessor :count
20
+
21
+ # How should the found count be compared to the expected count.
22
+ attr_accessor :count_type
23
+
24
+ # ID of inbox to search within and apply conditions to. Essentially filtering the emails found to give a count.
25
+ attr_accessor :inbox_id
26
+
27
+ # Conditions that should be matched for an email to qualify for results. Each condition will be applied in order to each email within an inbox to filter a result list of matching emails you are waiting for.
28
+ attr_accessor :matches
29
+
30
+ # Direction to sort matching emails by created time
31
+ attr_accessor :sort_direction
32
+
33
+ # Max time in milliseconds to retry the `waitFor` operation until conditions are met.
34
+ attr_accessor :timeout
35
+
36
+ # Apply conditions only to **unread** emails. All emails begin with `read=false`. An email is marked `read=true` when an `EmailDto` representation of it has been returned to the user at least once. For example you have called `getEmail` or `waitForLatestEmail` etc., or you have viewed the email in the dashboard.
37
+ attr_accessor :unread_only
38
+
39
+ class EnumAttributeValidator
40
+ attr_reader :datatype
41
+ attr_reader :allowable_values
42
+
43
+ def initialize(datatype, allowable_values)
44
+ @allowable_values = allowable_values.map do |value|
45
+ case datatype.to_s
46
+ when /Integer/i
47
+ value.to_i
48
+ when /Float/i
49
+ value.to_f
50
+ else
51
+ value
52
+ end
53
+ end
54
+ end
55
+
56
+ def valid?(value)
57
+ !value || allowable_values.include?(value)
58
+ end
59
+ end
60
+
61
+ # Attribute mapping from ruby-style variable name to JSON key.
62
+ def self.attribute_map
63
+ {
64
+ :'count' => :'count',
65
+ :'count_type' => :'countType',
66
+ :'inbox_id' => :'inboxId',
67
+ :'matches' => :'matches',
68
+ :'sort_direction' => :'sortDirection',
69
+ :'timeout' => :'timeout',
70
+ :'unread_only' => :'unreadOnly'
71
+ }
72
+ end
73
+
74
+ # Attribute type mapping.
75
+ def self.openapi_types
76
+ {
77
+ :'count' => :'Integer',
78
+ :'count_type' => :'String',
79
+ :'inbox_id' => :'String',
80
+ :'matches' => :'Array<MatchOption>',
81
+ :'sort_direction' => :'String',
82
+ :'timeout' => :'Integer',
83
+ :'unread_only' => :'Boolean'
84
+ }
85
+ end
86
+
87
+ # List of attributes with nullable: true
88
+ def self.openapi_nullable
89
+ Set.new([
90
+ ])
91
+ end
92
+
93
+ # Initializes the object
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ def initialize(attributes = {})
96
+ if (!attributes.is_a?(Hash))
97
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::WaitForConditions` initialize method"
98
+ end
99
+
100
+ # check to see if the attribute exists and convert string to symbol for hash key
101
+ attributes = attributes.each_with_object({}) { |(k, v), h|
102
+ if (!self.class.attribute_map.key?(k.to_sym))
103
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::WaitForConditions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
104
+ end
105
+ h[k.to_sym] = v
106
+ }
107
+
108
+ if attributes.key?(:'count')
109
+ self.count = attributes[:'count']
110
+ end
111
+
112
+ if attributes.key?(:'count_type')
113
+ self.count_type = attributes[:'count_type']
114
+ end
115
+
116
+ if attributes.key?(:'inbox_id')
117
+ self.inbox_id = attributes[:'inbox_id']
118
+ end
119
+
120
+ if attributes.key?(:'matches')
121
+ if (value = attributes[:'matches']).is_a?(Array)
122
+ self.matches = value
123
+ end
124
+ end
125
+
126
+ if attributes.key?(:'sort_direction')
127
+ self.sort_direction = attributes[:'sort_direction']
128
+ end
129
+
130
+ if attributes.key?(:'timeout')
131
+ self.timeout = attributes[:'timeout']
132
+ end
133
+
134
+ if attributes.key?(:'unread_only')
135
+ self.unread_only = attributes[:'unread_only']
136
+ end
137
+ end
138
+
139
+ # Show invalid properties with the reasons. Usually used together with valid?
140
+ # @return Array for valid properties with the reasons
141
+ def list_invalid_properties
142
+ invalid_properties = Array.new
143
+ invalid_properties
144
+ end
145
+
146
+ # Check to see if the all the properties in the model are valid
147
+ # @return true if the model is valid
148
+ def valid?
149
+ count_type_validator = EnumAttributeValidator.new('String', ["EXACTLY", "ATLEAST"])
150
+ return false unless count_type_validator.valid?(@count_type)
151
+ sort_direction_validator = EnumAttributeValidator.new('String', ["ASC", "DESC"])
152
+ return false unless sort_direction_validator.valid?(@sort_direction)
153
+ true
154
+ end
155
+
156
+ # Custom attribute writer method checking allowed values (enum).
157
+ # @param [Object] count_type Object to be assigned
158
+ def count_type=(count_type)
159
+ validator = EnumAttributeValidator.new('String', ["EXACTLY", "ATLEAST"])
160
+ unless validator.valid?(count_type)
161
+ fail ArgumentError, "invalid value for \"count_type\", must be one of #{validator.allowable_values}."
162
+ end
163
+ @count_type = count_type
164
+ end
165
+
166
+ # Custom attribute writer method checking allowed values (enum).
167
+ # @param [Object] sort_direction Object to be assigned
168
+ def sort_direction=(sort_direction)
169
+ validator = EnumAttributeValidator.new('String', ["ASC", "DESC"])
170
+ unless validator.valid?(sort_direction)
171
+ fail ArgumentError, "invalid value for \"sort_direction\", must be one of #{validator.allowable_values}."
172
+ end
173
+ @sort_direction = sort_direction
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
+ count == o.count &&
182
+ count_type == o.count_type &&
183
+ inbox_id == o.inbox_id &&
184
+ matches == o.matches &&
185
+ sort_direction == o.sort_direction &&
186
+ timeout == o.timeout &&
187
+ unread_only == o.unread_only
188
+ end
189
+
190
+ # @see the `==` method
191
+ # @param [Object] Object to be compared
192
+ def eql?(o)
193
+ self == o
194
+ end
195
+
196
+ # Calculates hash code according to all attributes.
197
+ # @return [Integer] Hash code
198
+ def hash
199
+ [count, count_type, inbox_id, matches, sort_direction, timeout, unread_only].hash
200
+ end
201
+
202
+ # Builds the object from hash
203
+ # @param [Hash] attributes Model attributes in the form of hash
204
+ # @return [Object] Returns the model itself
205
+ def self.build_from_hash(attributes)
206
+ new.build_from_hash(attributes)
207
+ end
208
+
209
+ # Builds the object from hash
210
+ # @param [Hash] attributes Model attributes in the form of hash
211
+ # @return [Object] Returns the model itself
212
+ def build_from_hash(attributes)
213
+ return nil unless attributes.is_a?(Hash)
214
+ self.class.openapi_types.each_pair do |key, type|
215
+ if type =~ /\AArray<(.*)>/i
216
+ # check to ensure the input is an array given that the attribute
217
+ # is documented as an array but the input is not
218
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
219
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
220
+ end
221
+ elsif !attributes[self.class.attribute_map[key]].nil?
222
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
223
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
224
+ end
225
+
226
+ self
227
+ end
228
+
229
+ # Deserializes the data based on type
230
+ # @param string type Data type
231
+ # @param string value Value to be deserialized
232
+ # @return [Object] Deserialized data
233
+ def _deserialize(type, value)
234
+ case type.to_sym
235
+ when :DateTime
236
+ DateTime.parse(value)
237
+ when :Date
238
+ Date.parse(value)
239
+ when :String
240
+ value.to_s
241
+ when :Integer
242
+ value.to_i
243
+ when :Float
244
+ value.to_f
245
+ when :Boolean
246
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
247
+ true
248
+ else
249
+ false
250
+ end
251
+ when :Object
252
+ # generic object (usually a Hash), return directly
253
+ value
254
+ when /\AArray<(?<inner_type>.+)>\z/
255
+ inner_type = Regexp.last_match[:inner_type]
256
+ value.map { |v| _deserialize(inner_type, v) }
257
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
258
+ k_type = Regexp.last_match[:k_type]
259
+ v_type = Regexp.last_match[:v_type]
260
+ {}.tap do |hash|
261
+ value.each do |k, v|
262
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
263
+ end
264
+ end
265
+ else # model
266
+ MailSlurpClient.const_get(type).build_from_hash(value)
267
+ end
268
+ end
269
+
270
+ # Returns the string representation of the object
271
+ # @return [String] String presentation of the object
272
+ def to_s
273
+ to_hash.to_s
274
+ end
275
+
276
+ # to_body is an alias to to_hash (backward compatibility)
277
+ # @return [Hash] Returns the object in the form of hash
278
+ def to_body
279
+ to_hash
280
+ end
281
+
282
+ # Returns the object in the form of hash
283
+ # @return [Hash] Returns the object in the form of hash
284
+ def to_hash
285
+ hash = {}
286
+ self.class.attribute_map.each_pair do |attr, param|
287
+ value = self.send(attr)
288
+ if value.nil?
289
+ is_nullable = self.class.openapi_nullable.include?(attr)
290
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
291
+ end
292
+
293
+ hash[param] = _to_hash(value)
294
+ end
295
+ hash
296
+ end
297
+
298
+ # Outputs non-array value in the form of hash
299
+ # For object, use to_hash. Otherwise, just return the value
300
+ # @param [Object] value Any valid value
301
+ # @return [Hash] Returns the value in the form of hash
302
+ def _to_hash(value)
303
+ if value.is_a?(Array)
304
+ value.compact.map { |v| _to_hash(v) }
305
+ elsif value.is_a?(Hash)
306
+ {}.tap do |hash|
307
+ value.each { |k, v| hash[k] = _to_hash(v) }
308
+ end
309
+ elsif value.respond_to? :to_hash
310
+ value.to_hash
311
+ else
312
+ value
313
+ end
314
+ end
315
+ end
316
+ end