mailslurp_client 15.17.17 → 15.17.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mailslurp_client/api/inbox_controller_api.rb +183 -0
  3. data/lib/mailslurp_client/api/sms_controller_api.rb +132 -0
  4. data/lib/mailslurp_client/api/tools_controller_api.rb +518 -0
  5. data/lib/mailslurp_client/models/alias_projection.rb +15 -15
  6. data/lib/mailslurp_client/models/attachment_projection.rb +16 -16
  7. data/lib/mailslurp_client/models/bounce_projection.rb +10 -10
  8. data/lib/mailslurp_client/models/connector_projection.rb +15 -15
  9. data/lib/mailslurp_client/models/generate_bimi_record_options.rb +282 -0
  10. data/lib/mailslurp_client/models/generate_bimi_record_results.rb +288 -0
  11. data/lib/mailslurp_client/models/generate_dmarc_record_options.rb +454 -0
  12. data/lib/mailslurp_client/models/generate_dmarc_record_results.rb +288 -0
  13. data/lib/mailslurp_client/models/generate_mta_sts_record_options.rb +329 -0
  14. data/lib/mailslurp_client/models/generate_mta_sts_record_results.rb +316 -0
  15. data/lib/mailslurp_client/models/generate_tls_reporting_record_options.rb +298 -0
  16. data/lib/mailslurp_client/models/generate_tls_reporting_record_results.rb +288 -0
  17. data/lib/mailslurp_client/models/inbox_forwarder_event_projection.rb +11 -11
  18. data/lib/mailslurp_client/models/inbox_replier_event_projection.rb +11 -11
  19. data/lib/mailslurp_client/models/lookup_bimi_domain_options.rb +211 -0
  20. data/lib/mailslurp_client/models/lookup_bimi_domain_results.rb +273 -0
  21. data/lib/mailslurp_client/models/lookup_dmarc_domain_options.rb +211 -0
  22. data/lib/mailslurp_client/models/lookup_dmarc_domain_results.rb +273 -0
  23. data/lib/mailslurp_client/models/lookup_mta_sts_domain_options.rb +211 -0
  24. data/lib/mailslurp_client/models/lookup_mta_sts_domain_results.rb +315 -0
  25. data/lib/mailslurp_client/models/lookup_tls_reporting_domain_options.rb +211 -0
  26. data/lib/mailslurp_client/models/lookup_tls_reporting_domain_results.rb +273 -0
  27. data/lib/mailslurp_client/models/reply_for_sms.rb +206 -0
  28. data/lib/mailslurp_client/models/sent_email_projection.rb +15 -15
  29. data/lib/mailslurp_client/models/sent_sms_dto.rb +351 -0
  30. data/lib/mailslurp_client/models/sms_reply_options.rb +211 -0
  31. data/lib/mailslurp_client/models/thread_projection.rb +16 -16
  32. data/lib/mailslurp_client/models/tracking_pixel_projection.rb +10 -10
  33. data/lib/mailslurp_client/version.rb +1 -1
  34. data/lib/mailslurp_client.rb +20 -0
  35. metadata +22 -2
@@ -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://docs.mailslurp.com/) - [Examples](https://github.com/mailslurp/examples) repository
5
+
6
+ The version of the OpenAPI document: 6.5.2
7
+ Contact: contact@mailslurp.dev
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
+ class GenerateMtaStsRecordResults
17
+ attr_accessor :name
18
+
19
+ # Domain Name Server Record Types
20
+ attr_accessor :type
21
+
22
+ attr_accessor :ttl
23
+
24
+ attr_accessor :value
25
+
26
+ attr_accessor :well_known_value
27
+
28
+ attr_accessor :well_known_url
29
+
30
+ class EnumAttributeValidator
31
+ attr_reader :datatype
32
+ attr_reader :allowable_values
33
+
34
+ def initialize(datatype, allowable_values)
35
+ @allowable_values = allowable_values.map do |value|
36
+ case datatype.to_s
37
+ when /Integer/i
38
+ value.to_i
39
+ when /Float/i
40
+ value.to_f
41
+ else
42
+ value
43
+ end
44
+ end
45
+ end
46
+
47
+ def valid?(value)
48
+ !value || allowable_values.include?(value)
49
+ end
50
+ end
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'name' => :'name',
56
+ :'type' => :'type',
57
+ :'ttl' => :'ttl',
58
+ :'value' => :'value',
59
+ :'well_known_value' => :'wellKnownValue',
60
+ :'well_known_url' => :'wellKnownUrl'
61
+ }
62
+ end
63
+
64
+ # Attribute type mapping.
65
+ def self.openapi_types
66
+ {
67
+ :'name' => :'String',
68
+ :'type' => :'String',
69
+ :'ttl' => :'Integer',
70
+ :'value' => :'String',
71
+ :'well_known_value' => :'String',
72
+ :'well_known_url' => :'String'
73
+ }
74
+ end
75
+
76
+ # List of attributes with nullable: true
77
+ def self.openapi_nullable
78
+ Set.new([
79
+ ])
80
+ end
81
+
82
+ # Initializes the object
83
+ # @param [Hash] attributes Model attributes in the form of hash
84
+ def initialize(attributes = {})
85
+ if (!attributes.is_a?(Hash))
86
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::GenerateMtaStsRecordResults` initialize method"
87
+ end
88
+
89
+ # check to see if the attribute exists and convert string to symbol for hash key
90
+ attributes = attributes.each_with_object({}) { |(k, v), h|
91
+ if (!self.class.attribute_map.key?(k.to_sym))
92
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::GenerateMtaStsRecordResults`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
93
+ end
94
+ h[k.to_sym] = v
95
+ }
96
+
97
+ if attributes.key?(:'name')
98
+ self.name = attributes[:'name']
99
+ end
100
+
101
+ if attributes.key?(:'type')
102
+ self.type = attributes[:'type']
103
+ end
104
+
105
+ if attributes.key?(:'ttl')
106
+ self.ttl = attributes[:'ttl']
107
+ end
108
+
109
+ if attributes.key?(:'value')
110
+ self.value = attributes[:'value']
111
+ end
112
+
113
+ if attributes.key?(:'well_known_value')
114
+ self.well_known_value = attributes[:'well_known_value']
115
+ end
116
+
117
+ if attributes.key?(:'well_known_url')
118
+ self.well_known_url = attributes[:'well_known_url']
119
+ end
120
+ end
121
+
122
+ # Show invalid properties with the reasons. Usually used together with valid?
123
+ # @return Array for valid properties with the reasons
124
+ def list_invalid_properties
125
+ invalid_properties = Array.new
126
+ if @name.nil?
127
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
128
+ end
129
+
130
+ if @type.nil?
131
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
132
+ end
133
+
134
+ if @ttl.nil?
135
+ invalid_properties.push('invalid value for "ttl", ttl cannot be nil.')
136
+ end
137
+
138
+ if @value.nil?
139
+ invalid_properties.push('invalid value for "value", value cannot be nil.')
140
+ end
141
+
142
+ if @well_known_value.nil?
143
+ invalid_properties.push('invalid value for "well_known_value", well_known_value cannot be nil.')
144
+ end
145
+
146
+ if @well_known_url.nil?
147
+ invalid_properties.push('invalid value for "well_known_url", well_known_url cannot be nil.')
148
+ end
149
+
150
+ invalid_properties
151
+ end
152
+
153
+ # Check to see if the all the properties in the model are valid
154
+ # @return true if the model is valid
155
+ def valid?
156
+ return false if @name.nil?
157
+ return false if @type.nil?
158
+ type_validator = EnumAttributeValidator.new('String', ["A", "NS", "MD", "MF", "CNAME", "SOA", "MB", "MG", "MR", "NULL", "WKS", "PTR", "HINFO", "MINFO", "MX", "TXT", "RP", "AFSDB", "X25", "ISDN", "RT", "NSAP", "NSAP_PTR", "SIG", "KEY", "PX", "GPOS", "AAAA", "LOC", "NXT", "EID", "NIMLOC", "SRV", "ATMA", "NAPTR", "KX", "CERT", "A6", "DNAME", "SINK", "OPT", "APL", "DS", "SSHFP", "IPSECKEY", "RRSIG", "NSEC", "DNSKEY", "DHCID", "NSEC3", "NSEC3PARAM", "TLSA", "SMIMEA", "HIP", "NINFO", "RKEY", "TALINK", "CDS", "CDNSKEY", "OPENPGPKEY", "CSYNC", "ZONEMD", "SVCB", "HTTPS", "SPF", "UINFO", "UID", "GID", "UNSPEC", "NID", "L32", "L64", "LP", "EUI48", "EUI64", "TKEY", "TSIG", "IXFR", "AXFR", "MAILB", "MAILA", "ANY", "URI", "CAA", "AVC", "DOA", "AMTRELAY", "TA", "DLV"])
159
+ return false unless type_validator.valid?(@type)
160
+ return false if @ttl.nil?
161
+ return false if @value.nil?
162
+ return false if @well_known_value.nil?
163
+ return false if @well_known_url.nil?
164
+ true
165
+ end
166
+
167
+ # Custom attribute writer method checking allowed values (enum).
168
+ # @param [Object] type Object to be assigned
169
+ def type=(type)
170
+ validator = EnumAttributeValidator.new('String', ["A", "NS", "MD", "MF", "CNAME", "SOA", "MB", "MG", "MR", "NULL", "WKS", "PTR", "HINFO", "MINFO", "MX", "TXT", "RP", "AFSDB", "X25", "ISDN", "RT", "NSAP", "NSAP_PTR", "SIG", "KEY", "PX", "GPOS", "AAAA", "LOC", "NXT", "EID", "NIMLOC", "SRV", "ATMA", "NAPTR", "KX", "CERT", "A6", "DNAME", "SINK", "OPT", "APL", "DS", "SSHFP", "IPSECKEY", "RRSIG", "NSEC", "DNSKEY", "DHCID", "NSEC3", "NSEC3PARAM", "TLSA", "SMIMEA", "HIP", "NINFO", "RKEY", "TALINK", "CDS", "CDNSKEY", "OPENPGPKEY", "CSYNC", "ZONEMD", "SVCB", "HTTPS", "SPF", "UINFO", "UID", "GID", "UNSPEC", "NID", "L32", "L64", "LP", "EUI48", "EUI64", "TKEY", "TSIG", "IXFR", "AXFR", "MAILB", "MAILA", "ANY", "URI", "CAA", "AVC", "DOA", "AMTRELAY", "TA", "DLV"])
171
+ unless validator.valid?(type)
172
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
173
+ end
174
+ @type = type
175
+ end
176
+
177
+ # Checks equality by comparing each attribute.
178
+ # @param [Object] Object to be compared
179
+ def ==(o)
180
+ return true if self.equal?(o)
181
+ self.class == o.class &&
182
+ name == o.name &&
183
+ type == o.type &&
184
+ ttl == o.ttl &&
185
+ value == o.value &&
186
+ well_known_value == o.well_known_value &&
187
+ well_known_url == o.well_known_url
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
+ [name, type, ttl, value, well_known_value, well_known_url].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
@@ -0,0 +1,298 @@
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://docs.mailslurp.com/) - [Examples](https://github.com/mailslurp/examples) repository
5
+
6
+ The version of the OpenAPI document: 6.5.2
7
+ Contact: contact@mailslurp.dev
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
+ class GenerateTlsReportingRecordOptions
17
+ attr_accessor :reporting_addresses
18
+
19
+ attr_accessor :reporting_url
20
+
21
+ attr_accessor :host
22
+
23
+ attr_accessor :version
24
+
25
+ attr_accessor :ttl
26
+
27
+ class EnumAttributeValidator
28
+ attr_reader :datatype
29
+ attr_reader :allowable_values
30
+
31
+ def initialize(datatype, allowable_values)
32
+ @allowable_values = allowable_values.map do |value|
33
+ case datatype.to_s
34
+ when /Integer/i
35
+ value.to_i
36
+ when /Float/i
37
+ value.to_f
38
+ else
39
+ value
40
+ end
41
+ end
42
+ end
43
+
44
+ def valid?(value)
45
+ !value || allowable_values.include?(value)
46
+ end
47
+ end
48
+
49
+ # Attribute mapping from ruby-style variable name to JSON key.
50
+ def self.attribute_map
51
+ {
52
+ :'reporting_addresses' => :'reportingAddresses',
53
+ :'reporting_url' => :'reportingUrl',
54
+ :'host' => :'host',
55
+ :'version' => :'version',
56
+ :'ttl' => :'ttl'
57
+ }
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.openapi_types
62
+ {
63
+ :'reporting_addresses' => :'Array<String>',
64
+ :'reporting_url' => :'String',
65
+ :'host' => :'String',
66
+ :'version' => :'String',
67
+ :'ttl' => :'Integer'
68
+ }
69
+ end
70
+
71
+ # List of attributes with nullable: true
72
+ def self.openapi_nullable
73
+ Set.new([
74
+ ])
75
+ end
76
+
77
+ # Initializes the object
78
+ # @param [Hash] attributes Model attributes in the form of hash
79
+ def initialize(attributes = {})
80
+ if (!attributes.is_a?(Hash))
81
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::GenerateTlsReportingRecordOptions` initialize method"
82
+ end
83
+
84
+ # check to see if the attribute exists and convert string to symbol for hash key
85
+ attributes = attributes.each_with_object({}) { |(k, v), h|
86
+ if (!self.class.attribute_map.key?(k.to_sym))
87
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::GenerateTlsReportingRecordOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
88
+ end
89
+ h[k.to_sym] = v
90
+ }
91
+
92
+ if attributes.key?(:'reporting_addresses')
93
+ if (value = attributes[:'reporting_addresses']).is_a?(Array)
94
+ self.reporting_addresses = value
95
+ end
96
+ end
97
+
98
+ if attributes.key?(:'reporting_url')
99
+ self.reporting_url = attributes[:'reporting_url']
100
+ end
101
+
102
+ if attributes.key?(:'host')
103
+ self.host = attributes[:'host']
104
+ end
105
+
106
+ if attributes.key?(:'version')
107
+ self.version = attributes[:'version']
108
+ end
109
+
110
+ if attributes.key?(:'ttl')
111
+ self.ttl = attributes[:'ttl']
112
+ end
113
+ end
114
+
115
+ # Show invalid properties with the reasons. Usually used together with valid?
116
+ # @return Array for valid properties with the reasons
117
+ def list_invalid_properties
118
+ invalid_properties = Array.new
119
+ if @reporting_addresses.nil?
120
+ invalid_properties.push('invalid value for "reporting_addresses", reporting_addresses cannot be nil.')
121
+ end
122
+
123
+ if @host.nil?
124
+ invalid_properties.push('invalid value for "host", host cannot be nil.')
125
+ end
126
+
127
+ if @version.nil?
128
+ invalid_properties.push('invalid value for "version", version cannot be nil.')
129
+ end
130
+
131
+ if @ttl.nil?
132
+ invalid_properties.push('invalid value for "ttl", ttl cannot be nil.')
133
+ end
134
+
135
+ invalid_properties
136
+ end
137
+
138
+ # Check to see if the all the properties in the model are valid
139
+ # @return true if the model is valid
140
+ def valid?
141
+ return false if @reporting_addresses.nil?
142
+ return false if @host.nil?
143
+ return false if @version.nil?
144
+ version_validator = EnumAttributeValidator.new('String', ["TLSRPTv1"])
145
+ return false unless version_validator.valid?(@version)
146
+ return false if @ttl.nil?
147
+ true
148
+ end
149
+
150
+ # Custom attribute writer method checking allowed values (enum).
151
+ # @param [Object] version Object to be assigned
152
+ def version=(version)
153
+ validator = EnumAttributeValidator.new('String', ["TLSRPTv1"])
154
+ unless validator.valid?(version)
155
+ fail ArgumentError, "invalid value for \"version\", must be one of #{validator.allowable_values}."
156
+ end
157
+ @version = version
158
+ end
159
+
160
+ # Checks equality by comparing each attribute.
161
+ # @param [Object] Object to be compared
162
+ def ==(o)
163
+ return true if self.equal?(o)
164
+ self.class == o.class &&
165
+ reporting_addresses == o.reporting_addresses &&
166
+ reporting_url == o.reporting_url &&
167
+ host == o.host &&
168
+ version == o.version &&
169
+ ttl == o.ttl
170
+ end
171
+
172
+ # @see the `==` method
173
+ # @param [Object] Object to be compared
174
+ def eql?(o)
175
+ self == o
176
+ end
177
+
178
+ # Calculates hash code according to all attributes.
179
+ # @return [Integer] Hash code
180
+ def hash
181
+ [reporting_addresses, reporting_url, host, version, ttl].hash
182
+ end
183
+
184
+ # Builds the object from hash
185
+ # @param [Hash] attributes Model attributes in the form of hash
186
+ # @return [Object] Returns the model itself
187
+ def self.build_from_hash(attributes)
188
+ new.build_from_hash(attributes)
189
+ end
190
+
191
+ # Builds the object from hash
192
+ # @param [Hash] attributes Model attributes in the form of hash
193
+ # @return [Object] Returns the model itself
194
+ def build_from_hash(attributes)
195
+ return nil unless attributes.is_a?(Hash)
196
+ self.class.openapi_types.each_pair do |key, type|
197
+ if type =~ /\AArray<(.*)>/i
198
+ # check to ensure the input is an array given that the attribute
199
+ # is documented as an array but the input is not
200
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
201
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
202
+ end
203
+ elsif !attributes[self.class.attribute_map[key]].nil?
204
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
205
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
206
+ end
207
+
208
+ self
209
+ end
210
+
211
+ # Deserializes the data based on type
212
+ # @param string type Data type
213
+ # @param string value Value to be deserialized
214
+ # @return [Object] Deserialized data
215
+ def _deserialize(type, value)
216
+ case type.to_sym
217
+ when :DateTime
218
+ DateTime.parse(value)
219
+ when :Date
220
+ Date.parse(value)
221
+ when :String
222
+ value.to_s
223
+ when :Integer
224
+ value.to_i
225
+ when :Float
226
+ value.to_f
227
+ when :Boolean
228
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
229
+ true
230
+ else
231
+ false
232
+ end
233
+ when :Object
234
+ # generic object (usually a Hash), return directly
235
+ value
236
+ when /\AArray<(?<inner_type>.+)>\z/
237
+ inner_type = Regexp.last_match[:inner_type]
238
+ value.map { |v| _deserialize(inner_type, v) }
239
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
240
+ k_type = Regexp.last_match[:k_type]
241
+ v_type = Regexp.last_match[:v_type]
242
+ {}.tap do |hash|
243
+ value.each do |k, v|
244
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
245
+ end
246
+ end
247
+ else # model
248
+ MailSlurpClient.const_get(type).build_from_hash(value)
249
+ end
250
+ end
251
+
252
+ # Returns the string representation of the object
253
+ # @return [String] String presentation of the object
254
+ def to_s
255
+ to_hash.to_s
256
+ end
257
+
258
+ # to_body is an alias to to_hash (backward compatibility)
259
+ # @return [Hash] Returns the object in the form of hash
260
+ def to_body
261
+ to_hash
262
+ end
263
+
264
+ # Returns the object in the form of hash
265
+ # @return [Hash] Returns the object in the form of hash
266
+ def to_hash
267
+ hash = {}
268
+ self.class.attribute_map.each_pair do |attr, param|
269
+ value = self.send(attr)
270
+ if value.nil?
271
+ is_nullable = self.class.openapi_nullable.include?(attr)
272
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
273
+ end
274
+
275
+ hash[param] = _to_hash(value)
276
+ end
277
+ hash
278
+ end
279
+
280
+ # Outputs non-array value in the form of hash
281
+ # For object, use to_hash. Otherwise, just return the value
282
+ # @param [Object] value Any valid value
283
+ # @return [Hash] Returns the value in the form of hash
284
+ def _to_hash(value)
285
+ if value.is_a?(Array)
286
+ value.compact.map { |v| _to_hash(v) }
287
+ elsif value.is_a?(Hash)
288
+ {}.tap do |hash|
289
+ value.each { |k, v| hash[k] = _to_hash(v) }
290
+ end
291
+ elsif value.respond_to? :to_hash
292
+ value.to_hash
293
+ else
294
+ value
295
+ end
296
+ end
297
+ end
298
+ end