mailslurp_client 12.6.4 → 12.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,275 @@
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
+ class CreateInboxForwarderOptions
17
+ attr_accessor :field
18
+
19
+ attr_accessor :match
20
+
21
+ attr_accessor :forward_to_recipients
22
+
23
+ class EnumAttributeValidator
24
+ attr_reader :datatype
25
+ attr_reader :allowable_values
26
+
27
+ def initialize(datatype, allowable_values)
28
+ @allowable_values = allowable_values.map do |value|
29
+ case datatype.to_s
30
+ when /Integer/i
31
+ value.to_i
32
+ when /Float/i
33
+ value.to_f
34
+ else
35
+ value
36
+ end
37
+ end
38
+ end
39
+
40
+ def valid?(value)
41
+ !value || allowable_values.include?(value)
42
+ end
43
+ end
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'field' => :'field',
49
+ :'match' => :'match',
50
+ :'forward_to_recipients' => :'forwardToRecipients'
51
+ }
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.openapi_types
56
+ {
57
+ :'field' => :'String',
58
+ :'match' => :'String',
59
+ :'forward_to_recipients' => :'Array<String>'
60
+ }
61
+ end
62
+
63
+ # List of attributes with nullable: true
64
+ def self.openapi_nullable
65
+ Set.new([
66
+ ])
67
+ end
68
+
69
+ # Initializes the object
70
+ # @param [Hash] attributes Model attributes in the form of hash
71
+ def initialize(attributes = {})
72
+ if (!attributes.is_a?(Hash))
73
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::CreateInboxForwarderOptions` initialize method"
74
+ end
75
+
76
+ # check to see if the attribute exists and convert string to symbol for hash key
77
+ attributes = attributes.each_with_object({}) { |(k, v), h|
78
+ if (!self.class.attribute_map.key?(k.to_sym))
79
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::CreateInboxForwarderOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
80
+ end
81
+ h[k.to_sym] = v
82
+ }
83
+
84
+ if attributes.key?(:'field')
85
+ self.field = attributes[:'field']
86
+ end
87
+
88
+ if attributes.key?(:'match')
89
+ self.match = attributes[:'match']
90
+ end
91
+
92
+ if attributes.key?(:'forward_to_recipients')
93
+ if (value = attributes[:'forward_to_recipients']).is_a?(Array)
94
+ self.forward_to_recipients = value
95
+ end
96
+ end
97
+ end
98
+
99
+ # Show invalid properties with the reasons. Usually used together with valid?
100
+ # @return Array for valid properties with the reasons
101
+ def list_invalid_properties
102
+ invalid_properties = Array.new
103
+ if @field.nil?
104
+ invalid_properties.push('invalid value for "field", field cannot be nil.')
105
+ end
106
+
107
+ if @match.nil?
108
+ invalid_properties.push('invalid value for "match", match cannot be nil.')
109
+ end
110
+
111
+ if @forward_to_recipients.nil?
112
+ invalid_properties.push('invalid value for "forward_to_recipients", forward_to_recipients cannot be nil.')
113
+ end
114
+
115
+ invalid_properties
116
+ end
117
+
118
+ # Check to see if the all the properties in the model are valid
119
+ # @return true if the model is valid
120
+ def valid?
121
+ return false if @field.nil?
122
+ field_validator = EnumAttributeValidator.new('String', ["RECIPIENTS", "SENDER", "SUBJECT", "ATTACHMENTS"])
123
+ return false unless field_validator.valid?(@field)
124
+ return false if @match.nil?
125
+ return false if @forward_to_recipients.nil?
126
+ true
127
+ end
128
+
129
+ # Custom attribute writer method checking allowed values (enum).
130
+ # @param [Object] field Object to be assigned
131
+ def field=(field)
132
+ validator = EnumAttributeValidator.new('String', ["RECIPIENTS", "SENDER", "SUBJECT", "ATTACHMENTS"])
133
+ unless validator.valid?(field)
134
+ fail ArgumentError, "invalid value for \"field\", must be one of #{validator.allowable_values}."
135
+ end
136
+ @field = field
137
+ end
138
+
139
+ # Checks equality by comparing each attribute.
140
+ # @param [Object] Object to be compared
141
+ def ==(o)
142
+ return true if self.equal?(o)
143
+ self.class == o.class &&
144
+ field == o.field &&
145
+ match == o.match &&
146
+ forward_to_recipients == o.forward_to_recipients
147
+ end
148
+
149
+ # @see the `==` method
150
+ # @param [Object] Object to be compared
151
+ def eql?(o)
152
+ self == o
153
+ end
154
+
155
+ # Calculates hash code according to all attributes.
156
+ # @return [Integer] Hash code
157
+ def hash
158
+ [field, match, forward_to_recipients].hash
159
+ end
160
+
161
+ # Builds the object from hash
162
+ # @param [Hash] attributes Model attributes in the form of hash
163
+ # @return [Object] Returns the model itself
164
+ def self.build_from_hash(attributes)
165
+ new.build_from_hash(attributes)
166
+ end
167
+
168
+ # Builds the object from hash
169
+ # @param [Hash] attributes Model attributes in the form of hash
170
+ # @return [Object] Returns the model itself
171
+ def build_from_hash(attributes)
172
+ return nil unless attributes.is_a?(Hash)
173
+ self.class.openapi_types.each_pair do |key, type|
174
+ if type =~ /\AArray<(.*)>/i
175
+ # check to ensure the input is an array given that the attribute
176
+ # is documented as an array but the input is not
177
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
178
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
179
+ end
180
+ elsif !attributes[self.class.attribute_map[key]].nil?
181
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
182
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
183
+ end
184
+
185
+ self
186
+ end
187
+
188
+ # Deserializes the data based on type
189
+ # @param string type Data type
190
+ # @param string value Value to be deserialized
191
+ # @return [Object] Deserialized data
192
+ def _deserialize(type, value)
193
+ case type.to_sym
194
+ when :DateTime
195
+ DateTime.parse(value)
196
+ when :Date
197
+ Date.parse(value)
198
+ when :String
199
+ value.to_s
200
+ when :Integer
201
+ value.to_i
202
+ when :Float
203
+ value.to_f
204
+ when :Boolean
205
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
206
+ true
207
+ else
208
+ false
209
+ end
210
+ when :Object
211
+ # generic object (usually a Hash), return directly
212
+ value
213
+ when /\AArray<(?<inner_type>.+)>\z/
214
+ inner_type = Regexp.last_match[:inner_type]
215
+ value.map { |v| _deserialize(inner_type, v) }
216
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
217
+ k_type = Regexp.last_match[:k_type]
218
+ v_type = Regexp.last_match[:v_type]
219
+ {}.tap do |hash|
220
+ value.each do |k, v|
221
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
222
+ end
223
+ end
224
+ else # model
225
+ MailSlurpClient.const_get(type).build_from_hash(value)
226
+ end
227
+ end
228
+
229
+ # Returns the string representation of the object
230
+ # @return [String] String presentation of the object
231
+ def to_s
232
+ to_hash.to_s
233
+ end
234
+
235
+ # to_body is an alias to to_hash (backward compatibility)
236
+ # @return [Hash] Returns the object in the form of hash
237
+ def to_body
238
+ to_hash
239
+ end
240
+
241
+ # Returns the object in the form of hash
242
+ # @return [Hash] Returns the object in the form of hash
243
+ def to_hash
244
+ hash = {}
245
+ self.class.attribute_map.each_pair do |attr, param|
246
+ value = self.send(attr)
247
+ if value.nil?
248
+ is_nullable = self.class.openapi_nullable.include?(attr)
249
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
250
+ end
251
+
252
+ hash[param] = _to_hash(value)
253
+ end
254
+ hash
255
+ end
256
+
257
+ # Outputs non-array value in the form of hash
258
+ # For object, use to_hash. Otherwise, just return the value
259
+ # @param [Object] value Any valid value
260
+ # @return [Hash] Returns the value in the form of hash
261
+ def _to_hash(value)
262
+ if value.is_a?(Array)
263
+ value.compact.map { |v| _to_hash(v) }
264
+ elsif value.is_a?(Hash)
265
+ {}.tap do |hash|
266
+ value.each { |k, v| hash[k] = _to_hash(v) }
267
+ end
268
+ elsif value.respond_to? :to_hash
269
+ value.to_hash
270
+ else
271
+ value
272
+ end
273
+ end
274
+ end
275
+ end
@@ -21,15 +21,43 @@ module MailSlurpClient
21
21
 
22
22
  attr_accessor :domain
23
23
 
24
+ attr_accessor :domain_type
25
+
24
26
  attr_accessor :id
25
27
 
28
+ attr_accessor :is_verified
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
+
26
52
  # Attribute mapping from ruby-style variable name to JSON key.
27
53
  def self.attribute_map
28
54
  {
29
55
  :'catch_all_inbox_id' => :'catchAllInboxId',
30
56
  :'created_at' => :'createdAt',
31
57
  :'domain' => :'domain',
32
- :'id' => :'id'
58
+ :'domain_type' => :'domainType',
59
+ :'id' => :'id',
60
+ :'is_verified' => :'isVerified'
33
61
  }
34
62
  end
35
63
 
@@ -39,7 +67,9 @@ module MailSlurpClient
39
67
  :'catch_all_inbox_id' => :'String',
40
68
  :'created_at' => :'DateTime',
41
69
  :'domain' => :'String',
42
- :'id' => :'String'
70
+ :'domain_type' => :'String',
71
+ :'id' => :'String',
72
+ :'is_verified' => :'Boolean'
43
73
  }
44
74
  end
45
75
 
@@ -76,9 +106,17 @@ module MailSlurpClient
76
106
  self.domain = attributes[:'domain']
77
107
  end
78
108
 
109
+ if attributes.key?(:'domain_type')
110
+ self.domain_type = attributes[:'domain_type']
111
+ end
112
+
79
113
  if attributes.key?(:'id')
80
114
  self.id = attributes[:'id']
81
115
  end
116
+
117
+ if attributes.key?(:'is_verified')
118
+ self.is_verified = attributes[:'is_verified']
119
+ end
82
120
  end
83
121
 
84
122
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -93,10 +131,18 @@ module MailSlurpClient
93
131
  invalid_properties.push('invalid value for "domain", domain cannot be nil.')
94
132
  end
95
133
 
134
+ if @domain_type.nil?
135
+ invalid_properties.push('invalid value for "domain_type", domain_type cannot be nil.')
136
+ end
137
+
96
138
  if @id.nil?
97
139
  invalid_properties.push('invalid value for "id", id cannot be nil.')
98
140
  end
99
141
 
142
+ if @is_verified.nil?
143
+ invalid_properties.push('invalid value for "is_verified", is_verified cannot be nil.')
144
+ end
145
+
100
146
  invalid_properties
101
147
  end
102
148
 
@@ -105,10 +151,24 @@ module MailSlurpClient
105
151
  def valid?
106
152
  return false if @created_at.nil?
107
153
  return false if @domain.nil?
154
+ return false if @domain_type.nil?
155
+ domain_type_validator = EnumAttributeValidator.new('String', ["HTTP_INBOX", "SMTP_DOMAIN"])
156
+ return false unless domain_type_validator.valid?(@domain_type)
108
157
  return false if @id.nil?
158
+ return false if @is_verified.nil?
109
159
  true
110
160
  end
111
161
 
162
+ # Custom attribute writer method checking allowed values (enum).
163
+ # @param [Object] domain_type Object to be assigned
164
+ def domain_type=(domain_type)
165
+ validator = EnumAttributeValidator.new('String', ["HTTP_INBOX", "SMTP_DOMAIN"])
166
+ unless validator.valid?(domain_type)
167
+ fail ArgumentError, "invalid value for \"domain_type\", must be one of #{validator.allowable_values}."
168
+ end
169
+ @domain_type = domain_type
170
+ end
171
+
112
172
  # Checks equality by comparing each attribute.
113
173
  # @param [Object] Object to be compared
114
174
  def ==(o)
@@ -117,7 +177,9 @@ module MailSlurpClient
117
177
  catch_all_inbox_id == o.catch_all_inbox_id &&
118
178
  created_at == o.created_at &&
119
179
  domain == o.domain &&
120
- id == o.id
180
+ domain_type == o.domain_type &&
181
+ id == o.id &&
182
+ is_verified == o.is_verified
121
183
  end
122
184
 
123
185
  # @see the `==` method
@@ -129,7 +191,7 @@ module MailSlurpClient
129
191
  # Calculates hash code according to all attributes.
130
192
  # @return [Integer] Hash code
131
193
  def hash
132
- [catch_all_inbox_id, created_at, domain, id].hash
194
+ [catch_all_inbox_id, created_at, domain, domain_type, id, is_verified].hash
133
195
  end
134
196
 
135
197
  # Builds the object from hash
@@ -0,0 +1,317 @@
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
+ class InboxForwarderDto
17
+ attr_accessor :created_at
18
+
19
+ attr_accessor :field
20
+
21
+ attr_accessor :forward_to_recipients
22
+
23
+ attr_accessor :id
24
+
25
+ attr_accessor :inbox_id
26
+
27
+ attr_accessor :match
28
+
29
+ class EnumAttributeValidator
30
+ attr_reader :datatype
31
+ attr_reader :allowable_values
32
+
33
+ def initialize(datatype, allowable_values)
34
+ @allowable_values = allowable_values.map do |value|
35
+ case datatype.to_s
36
+ when /Integer/i
37
+ value.to_i
38
+ when /Float/i
39
+ value.to_f
40
+ else
41
+ value
42
+ end
43
+ end
44
+ end
45
+
46
+ def valid?(value)
47
+ !value || allowable_values.include?(value)
48
+ end
49
+ end
50
+
51
+ # Attribute mapping from ruby-style variable name to JSON key.
52
+ def self.attribute_map
53
+ {
54
+ :'created_at' => :'createdAt',
55
+ :'field' => :'field',
56
+ :'forward_to_recipients' => :'forwardToRecipients',
57
+ :'id' => :'id',
58
+ :'inbox_id' => :'inboxId',
59
+ :'match' => :'match'
60
+ }
61
+ end
62
+
63
+ # Attribute type mapping.
64
+ def self.openapi_types
65
+ {
66
+ :'created_at' => :'DateTime',
67
+ :'field' => :'String',
68
+ :'forward_to_recipients' => :'Array<String>',
69
+ :'id' => :'String',
70
+ :'inbox_id' => :'String',
71
+ :'match' => :'String'
72
+ }
73
+ end
74
+
75
+ # List of attributes with nullable: true
76
+ def self.openapi_nullable
77
+ Set.new([
78
+ ])
79
+ end
80
+
81
+ # Initializes the object
82
+ # @param [Hash] attributes Model attributes in the form of hash
83
+ def initialize(attributes = {})
84
+ if (!attributes.is_a?(Hash))
85
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::InboxForwarderDto` initialize method"
86
+ end
87
+
88
+ # check to see if the attribute exists and convert string to symbol for hash key
89
+ attributes = attributes.each_with_object({}) { |(k, v), h|
90
+ if (!self.class.attribute_map.key?(k.to_sym))
91
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::InboxForwarderDto`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
92
+ end
93
+ h[k.to_sym] = v
94
+ }
95
+
96
+ if attributes.key?(:'created_at')
97
+ self.created_at = attributes[:'created_at']
98
+ end
99
+
100
+ if attributes.key?(:'field')
101
+ self.field = attributes[:'field']
102
+ end
103
+
104
+ if attributes.key?(:'forward_to_recipients')
105
+ if (value = attributes[:'forward_to_recipients']).is_a?(Array)
106
+ self.forward_to_recipients = value
107
+ end
108
+ end
109
+
110
+ if attributes.key?(:'id')
111
+ self.id = attributes[:'id']
112
+ end
113
+
114
+ if attributes.key?(:'inbox_id')
115
+ self.inbox_id = attributes[:'inbox_id']
116
+ end
117
+
118
+ if attributes.key?(:'match')
119
+ self.match = attributes[:'match']
120
+ end
121
+ end
122
+
123
+ # Show invalid properties with the reasons. Usually used together with valid?
124
+ # @return Array for valid properties with the reasons
125
+ def list_invalid_properties
126
+ invalid_properties = Array.new
127
+ if @created_at.nil?
128
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
129
+ end
130
+
131
+ if @field.nil?
132
+ invalid_properties.push('invalid value for "field", field cannot be nil.')
133
+ end
134
+
135
+ if @forward_to_recipients.nil?
136
+ invalid_properties.push('invalid value for "forward_to_recipients", forward_to_recipients cannot be nil.')
137
+ end
138
+
139
+ if @id.nil?
140
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
141
+ end
142
+
143
+ if @inbox_id.nil?
144
+ invalid_properties.push('invalid value for "inbox_id", inbox_id cannot be nil.')
145
+ end
146
+
147
+ if @match.nil?
148
+ invalid_properties.push('invalid value for "match", match cannot be nil.')
149
+ end
150
+
151
+ invalid_properties
152
+ end
153
+
154
+ # Check to see if the all the properties in the model are valid
155
+ # @return true if the model is valid
156
+ def valid?
157
+ return false if @created_at.nil?
158
+ return false if @field.nil?
159
+ field_validator = EnumAttributeValidator.new('String', ["RECIPIENTS", "SENDER", "SUBJECT", "ATTACHMENTS"])
160
+ return false unless field_validator.valid?(@field)
161
+ return false if @forward_to_recipients.nil?
162
+ return false if @id.nil?
163
+ return false if @inbox_id.nil?
164
+ return false if @match.nil?
165
+ true
166
+ end
167
+
168
+ # Custom attribute writer method checking allowed values (enum).
169
+ # @param [Object] field Object to be assigned
170
+ def field=(field)
171
+ validator = EnumAttributeValidator.new('String', ["RECIPIENTS", "SENDER", "SUBJECT", "ATTACHMENTS"])
172
+ unless validator.valid?(field)
173
+ fail ArgumentError, "invalid value for \"field\", must be one of #{validator.allowable_values}."
174
+ end
175
+ @field = field
176
+ end
177
+
178
+ # Checks equality by comparing each attribute.
179
+ # @param [Object] Object to be compared
180
+ def ==(o)
181
+ return true if self.equal?(o)
182
+ self.class == o.class &&
183
+ created_at == o.created_at &&
184
+ field == o.field &&
185
+ forward_to_recipients == o.forward_to_recipients &&
186
+ id == o.id &&
187
+ inbox_id == o.inbox_id &&
188
+ match == o.match
189
+ end
190
+
191
+ # @see the `==` method
192
+ # @param [Object] Object to be compared
193
+ def eql?(o)
194
+ self == o
195
+ end
196
+
197
+ # Calculates hash code according to all attributes.
198
+ # @return [Integer] Hash code
199
+ def hash
200
+ [created_at, field, forward_to_recipients, id, inbox_id, match].hash
201
+ end
202
+
203
+ # Builds the object from hash
204
+ # @param [Hash] attributes Model attributes in the form of hash
205
+ # @return [Object] Returns the model itself
206
+ def self.build_from_hash(attributes)
207
+ new.build_from_hash(attributes)
208
+ end
209
+
210
+ # Builds the object from hash
211
+ # @param [Hash] attributes Model attributes in the form of hash
212
+ # @return [Object] Returns the model itself
213
+ def build_from_hash(attributes)
214
+ return nil unless attributes.is_a?(Hash)
215
+ self.class.openapi_types.each_pair do |key, type|
216
+ if type =~ /\AArray<(.*)>/i
217
+ # check to ensure the input is an array given that the attribute
218
+ # is documented as an array but the input is not
219
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
220
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
221
+ end
222
+ elsif !attributes[self.class.attribute_map[key]].nil?
223
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
224
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
225
+ end
226
+
227
+ self
228
+ end
229
+
230
+ # Deserializes the data based on type
231
+ # @param string type Data type
232
+ # @param string value Value to be deserialized
233
+ # @return [Object] Deserialized data
234
+ def _deserialize(type, value)
235
+ case type.to_sym
236
+ when :DateTime
237
+ DateTime.parse(value)
238
+ when :Date
239
+ Date.parse(value)
240
+ when :String
241
+ value.to_s
242
+ when :Integer
243
+ value.to_i
244
+ when :Float
245
+ value.to_f
246
+ when :Boolean
247
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
248
+ true
249
+ else
250
+ false
251
+ end
252
+ when :Object
253
+ # generic object (usually a Hash), return directly
254
+ value
255
+ when /\AArray<(?<inner_type>.+)>\z/
256
+ inner_type = Regexp.last_match[:inner_type]
257
+ value.map { |v| _deserialize(inner_type, v) }
258
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
259
+ k_type = Regexp.last_match[:k_type]
260
+ v_type = Regexp.last_match[:v_type]
261
+ {}.tap do |hash|
262
+ value.each do |k, v|
263
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
264
+ end
265
+ end
266
+ else # model
267
+ MailSlurpClient.const_get(type).build_from_hash(value)
268
+ end
269
+ end
270
+
271
+ # Returns the string representation of the object
272
+ # @return [String] String presentation of the object
273
+ def to_s
274
+ to_hash.to_s
275
+ end
276
+
277
+ # to_body is an alias to to_hash (backward compatibility)
278
+ # @return [Hash] Returns the object in the form of hash
279
+ def to_body
280
+ to_hash
281
+ end
282
+
283
+ # Returns the object in the form of hash
284
+ # @return [Hash] Returns the object in the form of hash
285
+ def to_hash
286
+ hash = {}
287
+ self.class.attribute_map.each_pair do |attr, param|
288
+ value = self.send(attr)
289
+ if value.nil?
290
+ is_nullable = self.class.openapi_nullable.include?(attr)
291
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
292
+ end
293
+
294
+ hash[param] = _to_hash(value)
295
+ end
296
+ hash
297
+ end
298
+
299
+ # Outputs non-array value in the form of hash
300
+ # For object, use to_hash. Otherwise, just return the value
301
+ # @param [Object] value Any valid value
302
+ # @return [Hash] Returns the value in the form of hash
303
+ def _to_hash(value)
304
+ if value.is_a?(Array)
305
+ value.compact.map { |v| _to_hash(v) }
306
+ elsif value.is_a?(Hash)
307
+ {}.tap do |hash|
308
+ value.each { |k, v| hash[k] = _to_hash(v) }
309
+ end
310
+ elsif value.respond_to? :to_hash
311
+ value.to_hash
312
+ else
313
+ value
314
+ end
315
+ end
316
+ end
317
+ end