mailslurp_client 8.2.16 → 8.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +31 -2
  3. data/lib/mailslurp_client.rb +10 -2
  4. data/lib/mailslurp_client/api/alias_controller_api.rb +34 -96
  5. data/lib/mailslurp_client/api/domain_controller_api.rb +7 -5
  6. data/lib/mailslurp_client/api/email_controller_api.rb +72 -2
  7. data/lib/mailslurp_client/api/form_controller_api.rb +4 -7
  8. data/lib/mailslurp_client/api/inbox_controller_api.rb +87 -10
  9. data/lib/mailslurp_client/api/mail_server_controller_api.rb +123 -0
  10. data/lib/mailslurp_client/models/alias_dto.rb +276 -0
  11. data/lib/mailslurp_client/models/alias_projection.rb +276 -0
  12. data/lib/mailslurp_client/models/{create_owned_alias_options.rb → create_alias_options.rb} +13 -13
  13. data/lib/mailslurp_client/models/create_inbox_dto.rb +259 -0
  14. data/lib/mailslurp_client/models/dns_lookup_options.rb +252 -0
  15. data/lib/mailslurp_client/models/dns_lookup_result.rb +288 -0
  16. data/lib/mailslurp_client/models/dns_lookup_results.rb +214 -0
  17. data/lib/mailslurp_client/models/domain_dto.rb +16 -16
  18. data/lib/mailslurp_client/models/email.rb +11 -1
  19. data/lib/mailslurp_client/models/html_validation_result.rb +3 -15
  20. data/lib/mailslurp_client/models/inbox.rb +5 -5
  21. data/lib/mailslurp_client/models/ip_address_result.rb +226 -0
  22. data/lib/mailslurp_client/models/model_alias.rb +36 -22
  23. data/lib/mailslurp_client/models/page_alias.rb +1 -1
  24. data/lib/mailslurp_client/models/reply_to_email_options.rb +313 -0
  25. data/lib/mailslurp_client/models/{create_anonymous_alias_options.rb → update_alias_options.rb} +12 -12
  26. data/lib/mailslurp_client/models/update_inbox_options.rb +2 -2
  27. data/lib/mailslurp_client/version.rb +1 -1
  28. metadata +12 -4
@@ -0,0 +1,226 @@
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
+ # IP Address look up result for a given domain / hostname
17
+ class IPAddressResult
18
+ attr_accessor :address
19
+
20
+ attr_accessor :hostname
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'address' => :'address',
26
+ :'hostname' => :'hostname'
27
+ }
28
+ end
29
+
30
+ # Attribute type mapping.
31
+ def self.openapi_types
32
+ {
33
+ :'address' => :'String',
34
+ :'hostname' => :'String'
35
+ }
36
+ end
37
+
38
+ # List of attributes with nullable: true
39
+ def self.openapi_nullable
40
+ Set.new([
41
+ ])
42
+ end
43
+
44
+ # Initializes the object
45
+ # @param [Hash] attributes Model attributes in the form of hash
46
+ def initialize(attributes = {})
47
+ if (!attributes.is_a?(Hash))
48
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::IPAddressResult` initialize method"
49
+ end
50
+
51
+ # check to see if the attribute exists and convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}) { |(k, v), h|
53
+ if (!self.class.attribute_map.key?(k.to_sym))
54
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::IPAddressResult`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
55
+ end
56
+ h[k.to_sym] = v
57
+ }
58
+
59
+ if attributes.key?(:'address')
60
+ self.address = attributes[:'address']
61
+ end
62
+
63
+ if attributes.key?(:'hostname')
64
+ self.hostname = attributes[:'hostname']
65
+ end
66
+ end
67
+
68
+ # Show invalid properties with the reasons. Usually used together with valid?
69
+ # @return Array for valid properties with the reasons
70
+ def list_invalid_properties
71
+ invalid_properties = Array.new
72
+ if @address.nil?
73
+ invalid_properties.push('invalid value for "address", address cannot be nil.')
74
+ end
75
+
76
+ if @hostname.nil?
77
+ invalid_properties.push('invalid value for "hostname", hostname cannot be nil.')
78
+ end
79
+
80
+ invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ return false if @address.nil?
87
+ return false if @hostname.nil?
88
+ true
89
+ end
90
+
91
+ # Checks equality by comparing each attribute.
92
+ # @param [Object] Object to be compared
93
+ def ==(o)
94
+ return true if self.equal?(o)
95
+ self.class == o.class &&
96
+ address == o.address &&
97
+ hostname == o.hostname
98
+ end
99
+
100
+ # @see the `==` method
101
+ # @param [Object] Object to be compared
102
+ def eql?(o)
103
+ self == o
104
+ end
105
+
106
+ # Calculates hash code according to all attributes.
107
+ # @return [Integer] Hash code
108
+ def hash
109
+ [address, hostname].hash
110
+ end
111
+
112
+ # Builds the object from hash
113
+ # @param [Hash] attributes Model attributes in the form of hash
114
+ # @return [Object] Returns the model itself
115
+ def self.build_from_hash(attributes)
116
+ new.build_from_hash(attributes)
117
+ end
118
+
119
+ # Builds the object from hash
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ # @return [Object] Returns the model itself
122
+ def build_from_hash(attributes)
123
+ return nil unless attributes.is_a?(Hash)
124
+ self.class.openapi_types.each_pair do |key, type|
125
+ if type =~ /\AArray<(.*)>/i
126
+ # check to ensure the input is an array given that the attribute
127
+ # is documented as an array but the input is not
128
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
129
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
130
+ end
131
+ elsif !attributes[self.class.attribute_map[key]].nil?
132
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
133
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
134
+ end
135
+
136
+ self
137
+ end
138
+
139
+ # Deserializes the data based on type
140
+ # @param string type Data type
141
+ # @param string value Value to be deserialized
142
+ # @return [Object] Deserialized data
143
+ def _deserialize(type, value)
144
+ case type.to_sym
145
+ when :DateTime
146
+ DateTime.parse(value)
147
+ when :Date
148
+ Date.parse(value)
149
+ when :String
150
+ value.to_s
151
+ when :Integer
152
+ value.to_i
153
+ when :Float
154
+ value.to_f
155
+ when :Boolean
156
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
157
+ true
158
+ else
159
+ false
160
+ end
161
+ when :Object
162
+ # generic object (usually a Hash), return directly
163
+ value
164
+ when /\AArray<(?<inner_type>.+)>\z/
165
+ inner_type = Regexp.last_match[:inner_type]
166
+ value.map { |v| _deserialize(inner_type, v) }
167
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
168
+ k_type = Regexp.last_match[:k_type]
169
+ v_type = Regexp.last_match[:v_type]
170
+ {}.tap do |hash|
171
+ value.each do |k, v|
172
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
173
+ end
174
+ end
175
+ else # model
176
+ MailSlurpClient.const_get(type).build_from_hash(value)
177
+ end
178
+ end
179
+
180
+ # Returns the string representation of the object
181
+ # @return [String] String presentation of the object
182
+ def to_s
183
+ to_hash.to_s
184
+ end
185
+
186
+ # to_body is an alias to to_hash (backward compatibility)
187
+ # @return [Hash] Returns the object in the form of hash
188
+ def to_body
189
+ to_hash
190
+ end
191
+
192
+ # Returns the object in the form of hash
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_hash
195
+ hash = {}
196
+ self.class.attribute_map.each_pair do |attr, param|
197
+ value = self.send(attr)
198
+ if value.nil?
199
+ is_nullable = self.class.openapi_nullable.include?(attr)
200
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
201
+ end
202
+
203
+ hash[param] = _to_hash(value)
204
+ end
205
+ hash
206
+ end
207
+
208
+ # Outputs non-array value in the form of hash
209
+ # For object, use to_hash. Otherwise, just return the value
210
+ # @param [Object] value Any valid value
211
+ # @return [Hash] Returns the value in the form of hash
212
+ def _to_hash(value)
213
+ if value.is_a?(Array)
214
+ value.compact.map { |v| _to_hash(v) }
215
+ elsif value.is_a?(Hash)
216
+ {}.tap do |hash|
217
+ value.each { |k, v| hash[k] = _to_hash(v) }
218
+ end
219
+ elsif value.respond_to? :to_hash
220
+ value.to_hash
221
+ else
222
+ value
223
+ end
224
+ end
225
+ end
226
+ end
@@ -16,31 +16,34 @@ module MailSlurpClient
16
16
  class ModelAlias
17
17
  attr_accessor :created_at
18
18
 
19
- attr_accessor :email_address
20
-
21
19
  attr_accessor :id
22
20
 
23
21
  attr_accessor :inbox_id
24
22
 
25
23
  attr_accessor :name
26
24
 
27
- attr_accessor :proxied
25
+ attr_accessor :pending_email_address
28
26
 
29
27
  attr_accessor :updated_at
30
28
 
29
+ attr_accessor :use_threads
30
+
31
31
  attr_accessor :user_id
32
32
 
33
+ attr_accessor :verified_email_address
34
+
33
35
  # Attribute mapping from ruby-style variable name to JSON key.
34
36
  def self.attribute_map
35
37
  {
36
38
  :'created_at' => :'createdAt',
37
- :'email_address' => :'emailAddress',
38
39
  :'id' => :'id',
39
40
  :'inbox_id' => :'inboxId',
40
41
  :'name' => :'name',
41
- :'proxied' => :'proxied',
42
+ :'pending_email_address' => :'pendingEmailAddress',
42
43
  :'updated_at' => :'updatedAt',
43
- :'user_id' => :'userId'
44
+ :'use_threads' => :'useThreads',
45
+ :'user_id' => :'userId',
46
+ :'verified_email_address' => :'verifiedEmailAddress'
44
47
  }
45
48
  end
46
49
 
@@ -48,13 +51,14 @@ module MailSlurpClient
48
51
  def self.openapi_types
49
52
  {
50
53
  :'created_at' => :'DateTime',
51
- :'email_address' => :'String',
52
54
  :'id' => :'String',
53
55
  :'inbox_id' => :'String',
54
56
  :'name' => :'String',
55
- :'proxied' => :'Boolean',
57
+ :'pending_email_address' => :'String',
56
58
  :'updated_at' => :'DateTime',
57
- :'user_id' => :'String'
59
+ :'use_threads' => :'Boolean',
60
+ :'user_id' => :'String',
61
+ :'verified_email_address' => :'String'
58
62
  }
59
63
  end
60
64
 
@@ -83,10 +87,6 @@ module MailSlurpClient
83
87
  self.created_at = attributes[:'created_at']
84
88
  end
85
89
 
86
- if attributes.key?(:'email_address')
87
- self.email_address = attributes[:'email_address']
88
- end
89
-
90
90
  if attributes.key?(:'id')
91
91
  self.id = attributes[:'id']
92
92
  end
@@ -99,17 +99,25 @@ module MailSlurpClient
99
99
  self.name = attributes[:'name']
100
100
  end
101
101
 
102
- if attributes.key?(:'proxied')
103
- self.proxied = attributes[:'proxied']
102
+ if attributes.key?(:'pending_email_address')
103
+ self.pending_email_address = attributes[:'pending_email_address']
104
104
  end
105
105
 
106
106
  if attributes.key?(:'updated_at')
107
107
  self.updated_at = attributes[:'updated_at']
108
108
  end
109
109
 
110
+ if attributes.key?(:'use_threads')
111
+ self.use_threads = attributes[:'use_threads']
112
+ end
113
+
110
114
  if attributes.key?(:'user_id')
111
115
  self.user_id = attributes[:'user_id']
112
116
  end
117
+
118
+ if attributes.key?(:'verified_email_address')
119
+ self.verified_email_address = attributes[:'verified_email_address']
120
+ end
113
121
  end
114
122
 
115
123
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -120,14 +128,18 @@ module MailSlurpClient
120
128
  invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
121
129
  end
122
130
 
123
- if @email_address.nil?
124
- invalid_properties.push('invalid value for "email_address", email_address cannot be nil.')
131
+ if @inbox_id.nil?
132
+ invalid_properties.push('invalid value for "inbox_id", inbox_id cannot be nil.')
125
133
  end
126
134
 
127
135
  if @updated_at.nil?
128
136
  invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
129
137
  end
130
138
 
139
+ if @user_id.nil?
140
+ invalid_properties.push('invalid value for "user_id", user_id cannot be nil.')
141
+ end
142
+
131
143
  invalid_properties
132
144
  end
133
145
 
@@ -135,8 +147,9 @@ module MailSlurpClient
135
147
  # @return true if the model is valid
136
148
  def valid?
137
149
  return false if @created_at.nil?
138
- return false if @email_address.nil?
150
+ return false if @inbox_id.nil?
139
151
  return false if @updated_at.nil?
152
+ return false if @user_id.nil?
140
153
  true
141
154
  end
142
155
 
@@ -146,13 +159,14 @@ module MailSlurpClient
146
159
  return true if self.equal?(o)
147
160
  self.class == o.class &&
148
161
  created_at == o.created_at &&
149
- email_address == o.email_address &&
150
162
  id == o.id &&
151
163
  inbox_id == o.inbox_id &&
152
164
  name == o.name &&
153
- proxied == o.proxied &&
165
+ pending_email_address == o.pending_email_address &&
154
166
  updated_at == o.updated_at &&
155
- user_id == o.user_id
167
+ use_threads == o.use_threads &&
168
+ user_id == o.user_id &&
169
+ verified_email_address == o.verified_email_address
156
170
  end
157
171
 
158
172
  # @see the `==` method
@@ -164,7 +178,7 @@ module MailSlurpClient
164
178
  # Calculates hash code according to all attributes.
165
179
  # @return [Integer] Hash code
166
180
  def hash
167
- [created_at, email_address, id, inbox_id, name, proxied, updated_at, user_id].hash
181
+ [created_at, id, inbox_id, name, pending_email_address, updated_at, use_threads, user_id, verified_email_address].hash
168
182
  end
169
183
 
170
184
  # Builds the object from hash
@@ -57,7 +57,7 @@ module MailSlurpClient
57
57
  # Attribute type mapping.
58
58
  def self.openapi_types
59
59
  {
60
- :'content' => :'Array<ModelAlias>',
60
+ :'content' => :'Array<AliasProjection>',
61
61
  :'empty' => :'Boolean',
62
62
  :'first' => :'Boolean',
63
63
  :'last' => :'Boolean',
@@ -0,0 +1,313 @@
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 ReplyToEmailOptions
17
+ # List of uploaded attachments to send with the reply. Optional.
18
+ attr_accessor :attachments
19
+
20
+ # Body of the reply email you want to send
21
+ attr_accessor :body
22
+
23
+ # The charset that your message should be sent with. Optional. Default is UTF-8
24
+ attr_accessor :charset
25
+
26
+ # Is the reply HTML
27
+ attr_accessor :is_html
28
+
29
+ # The replyTo header that should be used. Optional
30
+ attr_accessor :reply_to
31
+
32
+ # When to send the email. Typically immediately
33
+ attr_accessor :send_strategy
34
+
35
+ # Template ID to use instead of body. Will use template variable map to fill defined variable slots.
36
+ attr_accessor :template
37
+
38
+ # Template variables if using a template
39
+ attr_accessor :template_variables
40
+
41
+ class EnumAttributeValidator
42
+ attr_reader :datatype
43
+ attr_reader :allowable_values
44
+
45
+ def initialize(datatype, allowable_values)
46
+ @allowable_values = allowable_values.map do |value|
47
+ case datatype.to_s
48
+ when /Integer/i
49
+ value.to_i
50
+ when /Float/i
51
+ value.to_f
52
+ else
53
+ value
54
+ end
55
+ end
56
+ end
57
+
58
+ def valid?(value)
59
+ !value || allowable_values.include?(value)
60
+ end
61
+ end
62
+
63
+ # Attribute mapping from ruby-style variable name to JSON key.
64
+ def self.attribute_map
65
+ {
66
+ :'attachments' => :'attachments',
67
+ :'body' => :'body',
68
+ :'charset' => :'charset',
69
+ :'is_html' => :'isHTML',
70
+ :'reply_to' => :'replyTo',
71
+ :'send_strategy' => :'sendStrategy',
72
+ :'template' => :'template',
73
+ :'template_variables' => :'templateVariables'
74
+ }
75
+ end
76
+
77
+ # Attribute type mapping.
78
+ def self.openapi_types
79
+ {
80
+ :'attachments' => :'Array<String>',
81
+ :'body' => :'String',
82
+ :'charset' => :'String',
83
+ :'is_html' => :'Boolean',
84
+ :'reply_to' => :'String',
85
+ :'send_strategy' => :'String',
86
+ :'template' => :'String',
87
+ :'template_variables' => :'Object'
88
+ }
89
+ end
90
+
91
+ # List of attributes with nullable: true
92
+ def self.openapi_nullable
93
+ Set.new([
94
+ ])
95
+ end
96
+
97
+ # Initializes the object
98
+ # @param [Hash] attributes Model attributes in the form of hash
99
+ def initialize(attributes = {})
100
+ if (!attributes.is_a?(Hash))
101
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::ReplyToEmailOptions` initialize method"
102
+ end
103
+
104
+ # check to see if the attribute exists and convert string to symbol for hash key
105
+ attributes = attributes.each_with_object({}) { |(k, v), h|
106
+ if (!self.class.attribute_map.key?(k.to_sym))
107
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::ReplyToEmailOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
108
+ end
109
+ h[k.to_sym] = v
110
+ }
111
+
112
+ if attributes.key?(:'attachments')
113
+ if (value = attributes[:'attachments']).is_a?(Array)
114
+ self.attachments = value
115
+ end
116
+ end
117
+
118
+ if attributes.key?(:'body')
119
+ self.body = attributes[:'body']
120
+ end
121
+
122
+ if attributes.key?(:'charset')
123
+ self.charset = attributes[:'charset']
124
+ end
125
+
126
+ if attributes.key?(:'is_html')
127
+ self.is_html = attributes[:'is_html']
128
+ end
129
+
130
+ if attributes.key?(:'reply_to')
131
+ self.reply_to = attributes[:'reply_to']
132
+ end
133
+
134
+ if attributes.key?(:'send_strategy')
135
+ self.send_strategy = attributes[:'send_strategy']
136
+ end
137
+
138
+ if attributes.key?(:'template')
139
+ self.template = attributes[:'template']
140
+ end
141
+
142
+ if attributes.key?(:'template_variables')
143
+ self.template_variables = attributes[:'template_variables']
144
+ end
145
+ end
146
+
147
+ # Show invalid properties with the reasons. Usually used together with valid?
148
+ # @return Array for valid properties with the reasons
149
+ def list_invalid_properties
150
+ invalid_properties = Array.new
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
+ send_strategy_validator = EnumAttributeValidator.new('String', ["SINGLE_MESSAGE"])
158
+ return false unless send_strategy_validator.valid?(@send_strategy)
159
+ true
160
+ end
161
+
162
+ # Custom attribute writer method checking allowed values (enum).
163
+ # @param [Object] send_strategy Object to be assigned
164
+ def send_strategy=(send_strategy)
165
+ validator = EnumAttributeValidator.new('String', ["SINGLE_MESSAGE"])
166
+ unless validator.valid?(send_strategy)
167
+ fail ArgumentError, "invalid value for \"send_strategy\", must be one of #{validator.allowable_values}."
168
+ end
169
+ @send_strategy = send_strategy
170
+ end
171
+
172
+ # Checks equality by comparing each attribute.
173
+ # @param [Object] Object to be compared
174
+ def ==(o)
175
+ return true if self.equal?(o)
176
+ self.class == o.class &&
177
+ attachments == o.attachments &&
178
+ body == o.body &&
179
+ charset == o.charset &&
180
+ is_html == o.is_html &&
181
+ reply_to == o.reply_to &&
182
+ send_strategy == o.send_strategy &&
183
+ template == o.template &&
184
+ template_variables == o.template_variables
185
+ end
186
+
187
+ # @see the `==` method
188
+ # @param [Object] Object to be compared
189
+ def eql?(o)
190
+ self == o
191
+ end
192
+
193
+ # Calculates hash code according to all attributes.
194
+ # @return [Integer] Hash code
195
+ def hash
196
+ [attachments, body, charset, is_html, reply_to, send_strategy, template, template_variables].hash
197
+ end
198
+
199
+ # Builds the object from hash
200
+ # @param [Hash] attributes Model attributes in the form of hash
201
+ # @return [Object] Returns the model itself
202
+ def self.build_from_hash(attributes)
203
+ new.build_from_hash(attributes)
204
+ end
205
+
206
+ # Builds the object from hash
207
+ # @param [Hash] attributes Model attributes in the form of hash
208
+ # @return [Object] Returns the model itself
209
+ def build_from_hash(attributes)
210
+ return nil unless attributes.is_a?(Hash)
211
+ self.class.openapi_types.each_pair do |key, type|
212
+ if type =~ /\AArray<(.*)>/i
213
+ # check to ensure the input is an array given that the attribute
214
+ # is documented as an array but the input is not
215
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
216
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
217
+ end
218
+ elsif !attributes[self.class.attribute_map[key]].nil?
219
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
220
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
221
+ end
222
+
223
+ self
224
+ end
225
+
226
+ # Deserializes the data based on type
227
+ # @param string type Data type
228
+ # @param string value Value to be deserialized
229
+ # @return [Object] Deserialized data
230
+ def _deserialize(type, value)
231
+ case type.to_sym
232
+ when :DateTime
233
+ DateTime.parse(value)
234
+ when :Date
235
+ Date.parse(value)
236
+ when :String
237
+ value.to_s
238
+ when :Integer
239
+ value.to_i
240
+ when :Float
241
+ value.to_f
242
+ when :Boolean
243
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
244
+ true
245
+ else
246
+ false
247
+ end
248
+ when :Object
249
+ # generic object (usually a Hash), return directly
250
+ value
251
+ when /\AArray<(?<inner_type>.+)>\z/
252
+ inner_type = Regexp.last_match[:inner_type]
253
+ value.map { |v| _deserialize(inner_type, v) }
254
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
255
+ k_type = Regexp.last_match[:k_type]
256
+ v_type = Regexp.last_match[:v_type]
257
+ {}.tap do |hash|
258
+ value.each do |k, v|
259
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
260
+ end
261
+ end
262
+ else # model
263
+ MailSlurpClient.const_get(type).build_from_hash(value)
264
+ end
265
+ end
266
+
267
+ # Returns the string representation of the object
268
+ # @return [String] String presentation of the object
269
+ def to_s
270
+ to_hash.to_s
271
+ end
272
+
273
+ # to_body is an alias to to_hash (backward compatibility)
274
+ # @return [Hash] Returns the object in the form of hash
275
+ def to_body
276
+ to_hash
277
+ end
278
+
279
+ # Returns the object in the form of hash
280
+ # @return [Hash] Returns the object in the form of hash
281
+ def to_hash
282
+ hash = {}
283
+ self.class.attribute_map.each_pair do |attr, param|
284
+ value = self.send(attr)
285
+ if value.nil?
286
+ is_nullable = self.class.openapi_nullable.include?(attr)
287
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
288
+ end
289
+
290
+ hash[param] = _to_hash(value)
291
+ end
292
+ hash
293
+ end
294
+
295
+ # Outputs non-array value in the form of hash
296
+ # For object, use to_hash. Otherwise, just return the value
297
+ # @param [Object] value Any valid value
298
+ # @return [Hash] Returns the value in the form of hash
299
+ def _to_hash(value)
300
+ if value.is_a?(Array)
301
+ value.compact.map { |v| _to_hash(v) }
302
+ elsif value.is_a?(Hash)
303
+ {}.tap do |hash|
304
+ value.each { |k, v| hash[k] = _to_hash(v) }
305
+ end
306
+ elsif value.respond_to? :to_hash
307
+ value.to_hash
308
+ else
309
+ value
310
+ end
311
+ end
312
+ end
313
+ end