mailslurp_client 12.7.0 → 12.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d907fe29af9707e86cda64ddeb8374eda666440f3bb1e22e3d198393659bf00
4
- data.tar.gz: 33fb186e151fb3e226050b3c011826cdbb78913dea7535d260e106e1b91fa5dd
3
+ metadata.gz: 9631374b4be566eabd7d85aa8bdc05f9b27d3904be856e85a6eb70df08ec272f
4
+ data.tar.gz: 660a9a5e1d6af82ee9213085f06acf469f2d5f396ac61d43d09f10fc14bafc7d
5
5
  SHA512:
6
- metadata.gz: 2b6866210153496dd4fc9426b14b64875e12ca827d552dbc99290aaa1a11a1480ab82313704992dcfa27299cc0b8fec934acc71bea734655a347f99881308a49
7
- data.tar.gz: 156ad05851da940c8a3fd122456c99ccc5ecaf611062361e5eb372b632733a1c7aff4641db6011b151ed324070f484369a4d3e616dba9455f502c1601aa021aa
6
+ metadata.gz: 871cd565c92d7ec331543bc40e44a250cb5b5ef81af8ba8c9a0ce5a0790aba35c3e925eb2eafb179eed3aee194e825ee064ad0bf773ff00ae19d836cb76adfff
7
+ data.tar.gz: 709bbd3304bc4092f49c02054ac726f5ce6de43abf4edb804d60f0feb292e35cc909f5bb62323fb51fab6a22eb07f917ea16c15f63f99922ccf3f8f042338776
@@ -23,6 +23,10 @@ require 'mailslurp_client/models/alias_projection'
23
23
  require 'mailslurp_client/models/attachment_meta_data'
24
24
  require 'mailslurp_client/models/attachment_projection'
25
25
  require 'mailslurp_client/models/basic_auth_options'
26
+ require 'mailslurp_client/models/bounce_projection'
27
+ require 'mailslurp_client/models/bounce_recipient'
28
+ require 'mailslurp_client/models/bounced_email_dto'
29
+ require 'mailslurp_client/models/bounced_recipient_dto'
26
30
  require 'mailslurp_client/models/bulk_send_email_options'
27
31
  require 'mailslurp_client/models/condition_option'
28
32
  require 'mailslurp_client/models/contact_dto'
@@ -82,6 +86,8 @@ require 'mailslurp_client/models/name_server_record'
82
86
  require 'mailslurp_client/models/organization_inbox_projection'
83
87
  require 'mailslurp_client/models/page_alias'
84
88
  require 'mailslurp_client/models/page_attachment_entity'
89
+ require 'mailslurp_client/models/page_bounced_email'
90
+ require 'mailslurp_client/models/page_bounced_recipients'
85
91
  require 'mailslurp_client/models/page_contact_projection'
86
92
  require 'mailslurp_client/models/page_email_preview'
87
93
  require 'mailslurp_client/models/page_email_projection'
@@ -140,6 +146,7 @@ require 'mailslurp_client/models/webhook_test_result'
140
146
  # APIs
141
147
  require 'mailslurp_client/api/alias_controller_api'
142
148
  require 'mailslurp_client/api/attachment_controller_api'
149
+ require 'mailslurp_client/api/bounce_controller_api'
143
150
  require 'mailslurp_client/api/bulk_actions_controller_api'
144
151
  require 'mailslurp_client/api/common_actions_controller_api'
145
152
  require 'mailslurp_client/api/contact_controller_api'
@@ -0,0 +1,284 @@
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 'cgi'
14
+
15
+ module MailSlurpClient
16
+ class BounceControllerApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Get a bounced email.
23
+ # Bounced emails are email you have sent that were rejected by a recipient
24
+ # @param id [String] ID of the bounced email to fetch
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [BouncedEmailDto]
27
+ def get_bounced_email(id, opts = {})
28
+ data, _status_code, _headers = get_bounced_email_with_http_info(id, opts)
29
+ data
30
+ end
31
+
32
+ # Get a bounced email.
33
+ # Bounced emails are email you have sent that were rejected by a recipient
34
+ # @param id [String] ID of the bounced email to fetch
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(BouncedEmailDto, Integer, Hash)>] BouncedEmailDto data, response status code and response headers
37
+ def get_bounced_email_with_http_info(id, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: BounceControllerApi.get_bounced_email ...'
40
+ end
41
+ # verify the required parameter 'id' is set
42
+ if @api_client.config.client_side_validation && id.nil?
43
+ fail ArgumentError, "Missing the required parameter 'id' when calling BounceControllerApi.get_bounced_email"
44
+ end
45
+ # resource path
46
+ local_var_path = '/bounce/emails/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
47
+
48
+ # query parameters
49
+ query_params = opts[:query_params] || {}
50
+
51
+ # header parameters
52
+ header_params = opts[:header_params] || {}
53
+ # HTTP header 'Accept' (if needed)
54
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
55
+
56
+ # form parameters
57
+ form_params = opts[:form_params] || {}
58
+
59
+ # http body (model)
60
+ post_body = opts[:body]
61
+
62
+ # return_type
63
+ return_type = opts[:return_type] || 'BouncedEmailDto'
64
+
65
+ # auth_names
66
+ auth_names = opts[:auth_names] || ['API_KEY']
67
+
68
+ new_options = opts.merge(
69
+ :header_params => header_params,
70
+ :query_params => query_params,
71
+ :form_params => form_params,
72
+ :body => post_body,
73
+ :auth_names => auth_names,
74
+ :return_type => return_type
75
+ )
76
+
77
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
78
+ if @api_client.config.debugging
79
+ @api_client.config.logger.debug "API called: BounceControllerApi#get_bounced_email\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
80
+ end
81
+ return data, status_code, headers
82
+ end
83
+
84
+ # Get paginated list of bounced emails.
85
+ # Bounced emails are email you have sent that were rejected by a recipient
86
+ # @param [Hash] opts the optional parameters
87
+ # @option opts [Integer] :page Optional page index (default to 0)
88
+ # @option opts [Integer] :size Optional page size (default to 20)
89
+ # @option opts [String] :sort Optional createdAt sort direction ASC or DESC (default to 'ASC')
90
+ # @return [PageBouncedEmail]
91
+ def get_bounced_emails(opts = {})
92
+ data, _status_code, _headers = get_bounced_emails_with_http_info(opts)
93
+ data
94
+ end
95
+
96
+ # Get paginated list of bounced emails.
97
+ # Bounced emails are email you have sent that were rejected by a recipient
98
+ # @param [Hash] opts the optional parameters
99
+ # @option opts [Integer] :page Optional page index
100
+ # @option opts [Integer] :size Optional page size
101
+ # @option opts [String] :sort Optional createdAt sort direction ASC or DESC
102
+ # @return [Array<(PageBouncedEmail, Integer, Hash)>] PageBouncedEmail data, response status code and response headers
103
+ def get_bounced_emails_with_http_info(opts = {})
104
+ if @api_client.config.debugging
105
+ @api_client.config.logger.debug 'Calling API: BounceControllerApi.get_bounced_emails ...'
106
+ end
107
+ allowable_values = ["ASC", "DESC"]
108
+ if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
109
+ fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
110
+ end
111
+ # resource path
112
+ local_var_path = '/bounce/emails'
113
+
114
+ # query parameters
115
+ query_params = opts[:query_params] || {}
116
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
117
+ query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
118
+ query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
119
+
120
+ # header parameters
121
+ header_params = opts[:header_params] || {}
122
+ # HTTP header 'Accept' (if needed)
123
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
124
+
125
+ # form parameters
126
+ form_params = opts[:form_params] || {}
127
+
128
+ # http body (model)
129
+ post_body = opts[:body]
130
+
131
+ # return_type
132
+ return_type = opts[:return_type] || 'PageBouncedEmail'
133
+
134
+ # auth_names
135
+ auth_names = opts[:auth_names] || ['API_KEY']
136
+
137
+ new_options = opts.merge(
138
+ :header_params => header_params,
139
+ :query_params => query_params,
140
+ :form_params => form_params,
141
+ :body => post_body,
142
+ :auth_names => auth_names,
143
+ :return_type => return_type
144
+ )
145
+
146
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
147
+ if @api_client.config.debugging
148
+ @api_client.config.logger.debug "API called: BounceControllerApi#get_bounced_emails\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
149
+ end
150
+ return data, status_code, headers
151
+ end
152
+
153
+ # Get a bounced email.
154
+ # Bounced emails are email you have sent that were rejected by a recipient
155
+ # @param id [String] ID of the bounced recipient
156
+ # @param [Hash] opts the optional parameters
157
+ # @return [BouncedRecipientDto]
158
+ def get_bounced_recipient(id, opts = {})
159
+ data, _status_code, _headers = get_bounced_recipient_with_http_info(id, opts)
160
+ data
161
+ end
162
+
163
+ # Get a bounced email.
164
+ # Bounced emails are email you have sent that were rejected by a recipient
165
+ # @param id [String] ID of the bounced recipient
166
+ # @param [Hash] opts the optional parameters
167
+ # @return [Array<(BouncedRecipientDto, Integer, Hash)>] BouncedRecipientDto data, response status code and response headers
168
+ def get_bounced_recipient_with_http_info(id, opts = {})
169
+ if @api_client.config.debugging
170
+ @api_client.config.logger.debug 'Calling API: BounceControllerApi.get_bounced_recipient ...'
171
+ end
172
+ # verify the required parameter 'id' is set
173
+ if @api_client.config.client_side_validation && id.nil?
174
+ fail ArgumentError, "Missing the required parameter 'id' when calling BounceControllerApi.get_bounced_recipient"
175
+ end
176
+ # resource path
177
+ local_var_path = '/bounce/recipients/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
178
+
179
+ # query parameters
180
+ query_params = opts[:query_params] || {}
181
+
182
+ # header parameters
183
+ header_params = opts[:header_params] || {}
184
+ # HTTP header 'Accept' (if needed)
185
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
186
+
187
+ # form parameters
188
+ form_params = opts[:form_params] || {}
189
+
190
+ # http body (model)
191
+ post_body = opts[:body]
192
+
193
+ # return_type
194
+ return_type = opts[:return_type] || 'BouncedRecipientDto'
195
+
196
+ # auth_names
197
+ auth_names = opts[:auth_names] || ['API_KEY']
198
+
199
+ new_options = opts.merge(
200
+ :header_params => header_params,
201
+ :query_params => query_params,
202
+ :form_params => form_params,
203
+ :body => post_body,
204
+ :auth_names => auth_names,
205
+ :return_type => return_type
206
+ )
207
+
208
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
209
+ if @api_client.config.debugging
210
+ @api_client.config.logger.debug "API called: BounceControllerApi#get_bounced_recipient\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
211
+ end
212
+ return data, status_code, headers
213
+ end
214
+
215
+ # Get paginated list of bounced recipients.
216
+ # Bounced recipients are email addresses that you have sent emails to that did not accept the sent email. Once a recipient is bounced you cannot send emails to that address.
217
+ # @param [Hash] opts the optional parameters
218
+ # @option opts [Integer] :page Optional page index (default to 0)
219
+ # @option opts [Integer] :size Optional page size (default to 20)
220
+ # @option opts [String] :sort Optional createdAt sort direction ASC or DESC (default to 'ASC')
221
+ # @return [PageBouncedRecipients]
222
+ def get_bounced_recipients(opts = {})
223
+ data, _status_code, _headers = get_bounced_recipients_with_http_info(opts)
224
+ data
225
+ end
226
+
227
+ # Get paginated list of bounced recipients.
228
+ # Bounced recipients are email addresses that you have sent emails to that did not accept the sent email. Once a recipient is bounced you cannot send emails to that address.
229
+ # @param [Hash] opts the optional parameters
230
+ # @option opts [Integer] :page Optional page index
231
+ # @option opts [Integer] :size Optional page size
232
+ # @option opts [String] :sort Optional createdAt sort direction ASC or DESC
233
+ # @return [Array<(PageBouncedRecipients, Integer, Hash)>] PageBouncedRecipients data, response status code and response headers
234
+ def get_bounced_recipients_with_http_info(opts = {})
235
+ if @api_client.config.debugging
236
+ @api_client.config.logger.debug 'Calling API: BounceControllerApi.get_bounced_recipients ...'
237
+ end
238
+ allowable_values = ["ASC", "DESC"]
239
+ if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
240
+ fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
241
+ end
242
+ # resource path
243
+ local_var_path = '/bounce/recipients'
244
+
245
+ # query parameters
246
+ query_params = opts[:query_params] || {}
247
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
248
+ query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
249
+ query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
250
+
251
+ # header parameters
252
+ header_params = opts[:header_params] || {}
253
+ # HTTP header 'Accept' (if needed)
254
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
255
+
256
+ # form parameters
257
+ form_params = opts[:form_params] || {}
258
+
259
+ # http body (model)
260
+ post_body = opts[:body]
261
+
262
+ # return_type
263
+ return_type = opts[:return_type] || 'PageBouncedRecipients'
264
+
265
+ # auth_names
266
+ auth_names = opts[:auth_names] || ['API_KEY']
267
+
268
+ new_options = opts.merge(
269
+ :header_params => header_params,
270
+ :query_params => query_params,
271
+ :form_params => form_params,
272
+ :body => post_body,
273
+ :auth_names => auth_names,
274
+ :return_type => return_type
275
+ )
276
+
277
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
278
+ if @api_client.config.debugging
279
+ @api_client.config.logger.debug "API called: BounceControllerApi#get_bounced_recipients\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
280
+ end
281
+ return data, status_code, headers
282
+ end
283
+ end
284
+ end
@@ -149,6 +149,66 @@ module MailSlurpClient
149
149
  return data, status_code, headers
150
150
  end
151
151
 
152
+ # Get sent email HTML content
153
+ # @param id [String] id
154
+ # @param [Hash] opts the optional parameters
155
+ # @return [String]
156
+ def get_sent_email_html_content(id, opts = {})
157
+ data, _status_code, _headers = get_sent_email_html_content_with_http_info(id, opts)
158
+ data
159
+ end
160
+
161
+ # Get sent email HTML content
162
+ # @param id [String] id
163
+ # @param [Hash] opts the optional parameters
164
+ # @return [Array<(String, Integer, Hash)>] String data, response status code and response headers
165
+ def get_sent_email_html_content_with_http_info(id, opts = {})
166
+ if @api_client.config.debugging
167
+ @api_client.config.logger.debug 'Calling API: SentEmailsControllerApi.get_sent_email_html_content ...'
168
+ end
169
+ # verify the required parameter 'id' is set
170
+ if @api_client.config.client_side_validation && id.nil?
171
+ fail ArgumentError, "Missing the required parameter 'id' when calling SentEmailsControllerApi.get_sent_email_html_content"
172
+ end
173
+ # resource path
174
+ local_var_path = '/sent/{id}/html'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
175
+
176
+ # query parameters
177
+ query_params = opts[:query_params] || {}
178
+
179
+ # header parameters
180
+ header_params = opts[:header_params] || {}
181
+ # HTTP header 'Accept' (if needed)
182
+ header_params['Accept'] = @api_client.select_header_accept(['text/html'])
183
+
184
+ # form parameters
185
+ form_params = opts[:form_params] || {}
186
+
187
+ # http body (model)
188
+ post_body = opts[:body]
189
+
190
+ # return_type
191
+ return_type = opts[:return_type] || 'String'
192
+
193
+ # auth_names
194
+ auth_names = opts[:auth_names] || ['API_KEY']
195
+
196
+ new_options = opts.merge(
197
+ :header_params => header_params,
198
+ :query_params => query_params,
199
+ :form_params => form_params,
200
+ :body => post_body,
201
+ :auth_names => auth_names,
202
+ :return_type => return_type
203
+ )
204
+
205
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
206
+ if @api_client.config.debugging
207
+ @api_client.config.logger.debug "API called: SentEmailsControllerApi#get_sent_email_html_content\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
208
+ end
209
+ return data, status_code, headers
210
+ end
211
+
152
212
  # Get all tracking pixels for a sent email in paginated form
153
213
  # @param id [String] id
154
214
  # @param [Hash] opts the optional parameters
@@ -0,0 +1,234 @@
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 BounceProjection
17
+ attr_accessor :created_at
18
+
19
+ attr_accessor :id
20
+
21
+ attr_accessor :sender
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'created_at' => :'createdAt',
27
+ :'id' => :'id',
28
+ :'sender' => :'sender'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.openapi_types
34
+ {
35
+ :'created_at' => :'DateTime',
36
+ :'id' => :'String',
37
+ :'sender' => :'String'
38
+ }
39
+ end
40
+
41
+ # List of attributes with nullable: true
42
+ def self.openapi_nullable
43
+ Set.new([
44
+ ])
45
+ end
46
+
47
+ # Initializes the object
48
+ # @param [Hash] attributes Model attributes in the form of hash
49
+ def initialize(attributes = {})
50
+ if (!attributes.is_a?(Hash))
51
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::BounceProjection` initialize method"
52
+ end
53
+
54
+ # check to see if the attribute exists and convert string to symbol for hash key
55
+ attributes = attributes.each_with_object({}) { |(k, v), h|
56
+ if (!self.class.attribute_map.key?(k.to_sym))
57
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::BounceProjection`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
58
+ end
59
+ h[k.to_sym] = v
60
+ }
61
+
62
+ if attributes.key?(:'created_at')
63
+ self.created_at = attributes[:'created_at']
64
+ end
65
+
66
+ if attributes.key?(:'id')
67
+ self.id = attributes[:'id']
68
+ end
69
+
70
+ if attributes.key?(:'sender')
71
+ self.sender = attributes[:'sender']
72
+ end
73
+ end
74
+
75
+ # Show invalid properties with the reasons. Usually used together with valid?
76
+ # @return Array for valid properties with the reasons
77
+ def list_invalid_properties
78
+ invalid_properties = Array.new
79
+ if @created_at.nil?
80
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
81
+ end
82
+
83
+ if @sender.nil?
84
+ invalid_properties.push('invalid value for "sender", sender cannot be nil.')
85
+ end
86
+
87
+ invalid_properties
88
+ end
89
+
90
+ # Check to see if the all the properties in the model are valid
91
+ # @return true if the model is valid
92
+ def valid?
93
+ return false if @created_at.nil?
94
+ return false if @sender.nil?
95
+ true
96
+ end
97
+
98
+ # Checks equality by comparing each attribute.
99
+ # @param [Object] Object to be compared
100
+ def ==(o)
101
+ return true if self.equal?(o)
102
+ self.class == o.class &&
103
+ created_at == o.created_at &&
104
+ id == o.id &&
105
+ sender == o.sender
106
+ end
107
+
108
+ # @see the `==` method
109
+ # @param [Object] Object to be compared
110
+ def eql?(o)
111
+ self == o
112
+ end
113
+
114
+ # Calculates hash code according to all attributes.
115
+ # @return [Integer] Hash code
116
+ def hash
117
+ [created_at, id, sender].hash
118
+ end
119
+
120
+ # Builds the object from hash
121
+ # @param [Hash] attributes Model attributes in the form of hash
122
+ # @return [Object] Returns the model itself
123
+ def self.build_from_hash(attributes)
124
+ new.build_from_hash(attributes)
125
+ end
126
+
127
+ # Builds the object from hash
128
+ # @param [Hash] attributes Model attributes in the form of hash
129
+ # @return [Object] Returns the model itself
130
+ def build_from_hash(attributes)
131
+ return nil unless attributes.is_a?(Hash)
132
+ self.class.openapi_types.each_pair do |key, type|
133
+ if type =~ /\AArray<(.*)>/i
134
+ # check to ensure the input is an array given that the attribute
135
+ # is documented as an array but the input is not
136
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
137
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
138
+ end
139
+ elsif !attributes[self.class.attribute_map[key]].nil?
140
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
141
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
142
+ end
143
+
144
+ self
145
+ end
146
+
147
+ # Deserializes the data based on type
148
+ # @param string type Data type
149
+ # @param string value Value to be deserialized
150
+ # @return [Object] Deserialized data
151
+ def _deserialize(type, value)
152
+ case type.to_sym
153
+ when :DateTime
154
+ DateTime.parse(value)
155
+ when :Date
156
+ Date.parse(value)
157
+ when :String
158
+ value.to_s
159
+ when :Integer
160
+ value.to_i
161
+ when :Float
162
+ value.to_f
163
+ when :Boolean
164
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
165
+ true
166
+ else
167
+ false
168
+ end
169
+ when :Object
170
+ # generic object (usually a Hash), return directly
171
+ value
172
+ when /\AArray<(?<inner_type>.+)>\z/
173
+ inner_type = Regexp.last_match[:inner_type]
174
+ value.map { |v| _deserialize(inner_type, v) }
175
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
176
+ k_type = Regexp.last_match[:k_type]
177
+ v_type = Regexp.last_match[:v_type]
178
+ {}.tap do |hash|
179
+ value.each do |k, v|
180
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
181
+ end
182
+ end
183
+ else # model
184
+ MailSlurpClient.const_get(type).build_from_hash(value)
185
+ end
186
+ end
187
+
188
+ # Returns the string representation of the object
189
+ # @return [String] String presentation of the object
190
+ def to_s
191
+ to_hash.to_s
192
+ end
193
+
194
+ # to_body is an alias to to_hash (backward compatibility)
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_body
197
+ to_hash
198
+ end
199
+
200
+ # Returns the object in the form of hash
201
+ # @return [Hash] Returns the object in the form of hash
202
+ def to_hash
203
+ hash = {}
204
+ self.class.attribute_map.each_pair do |attr, param|
205
+ value = self.send(attr)
206
+ if value.nil?
207
+ is_nullable = self.class.openapi_nullable.include?(attr)
208
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
209
+ end
210
+
211
+ hash[param] = _to_hash(value)
212
+ end
213
+ hash
214
+ end
215
+
216
+ # Outputs non-array value in the form of hash
217
+ # For object, use to_hash. Otherwise, just return the value
218
+ # @param [Object] value Any valid value
219
+ # @return [Hash] Returns the value in the form of hash
220
+ def _to_hash(value)
221
+ if value.is_a?(Array)
222
+ value.compact.map { |v| _to_hash(v) }
223
+ elsif value.is_a?(Hash)
224
+ {}.tap do |hash|
225
+ value.each { |k, v| hash[k] = _to_hash(v) }
226
+ end
227
+ elsif value.respond_to? :to_hash
228
+ value.to_hash
229
+ else
230
+ value
231
+ end
232
+ end
233
+ end
234
+ end