mailslurp_client 8.2.16 → 8.2.17

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: c260595fb22734fe08c4bc9dde162a503cfdf5453db89b406da327d7ea742b3c
4
- data.tar.gz: 278762360ddbfce4bd7aba024dadbc30c22a9a5cf6f371a34289b42d1cd5c443
3
+ metadata.gz: 881dae0965a313cf4e679fc47e998a276e07d3061765332c5ce6e383b5b837c9
4
+ data.tar.gz: 37bc815bc87386f28781283cc8188d67eaff8e064017f5dcf9c13b61a6e79206
5
5
  SHA512:
6
- metadata.gz: 3282107ccdd4d938bc19e7c86d18c1114d3e1e725afbce084329f66730f8c8b9568a6fd9240c0c0b19ea516465478e4265e22f92b6f90488b36d3d3b761e08a7
7
- data.tar.gz: d99dcf7ad1e8fc78bf1894e1dc76c867c63e6b48de715ff6f54d188d357aa6802a810ea840f12f7f0b407261c034301a9c5cb4a96a5bc2f76c7d283aca7ab3a0
6
+ metadata.gz: 8f96ca7c6b8e8576577ab457784427bd827f6c2168ca80baf22d979107aac4ab9491643e6f06172fb002e0583ac34c58efa2796f35d800bd6717ea9216902fb5
7
+ data.tar.gz: 1210557bf09554f787242009ef9d604c4ce4565ec3bc0a3b72f605c484869a5707cc5e4e93f8d9fb8f5267e7e45294102f9609464ebc3197a0004cd44ea62ec0
@@ -30,6 +30,9 @@ require 'mailslurp_client/models/create_group_options'
30
30
  require 'mailslurp_client/models/create_owned_alias_options'
31
31
  require 'mailslurp_client/models/create_template_options'
32
32
  require 'mailslurp_client/models/create_webhook_options'
33
+ require 'mailslurp_client/models/dns_lookup_options'
34
+ require 'mailslurp_client/models/dns_lookup_result'
35
+ require 'mailslurp_client/models/dns_lookup_results'
33
36
  require 'mailslurp_client/models/describe_domain_options'
34
37
  require 'mailslurp_client/models/describe_mail_server_domain_result'
35
38
  require 'mailslurp_client/models/domain_dto'
@@ -46,6 +49,7 @@ require 'mailslurp_client/models/group_contacts_dto'
46
49
  require 'mailslurp_client/models/group_dto'
47
50
  require 'mailslurp_client/models/group_projection'
48
51
  require 'mailslurp_client/models/html_validation_result'
52
+ require 'mailslurp_client/models/ip_address_result'
49
53
  require 'mailslurp_client/models/inbox'
50
54
  require 'mailslurp_client/models/inbox_projection'
51
55
  require 'mailslurp_client/models/match_option'
@@ -675,7 +675,7 @@ module MailSlurpClient
675
675
  # @param [Hash] opts the optional parameters
676
676
  # @option opts [Array<String>] :inbox_id Optional inbox ids to filter by. Can be repeated. By default will use all inboxes belonging to your account.
677
677
  # @option opts [Integer] :page Optional page index in email list pagination (default to 0)
678
- # @option opts [Integer] :size Optional page size in email list pagination (default to 20)
678
+ # @option opts [Integer] :size Optional page size in email list pagination. Maximum size is 100. Use page index and sort to page through larger results (default to 20)
679
679
  # @option opts [String] :sort Optional createdAt sort direction ASC or DESC (default to 'ASC')
680
680
  # @option opts [Boolean] :unread_only Optional filter for unread emails only. All emails are considered unread until they are viewed in the dashboard or requested directly (default to false)
681
681
  # @return [PageEmailProjection]
@@ -689,7 +689,7 @@ module MailSlurpClient
689
689
  # @param [Hash] opts the optional parameters
690
690
  # @option opts [Array<String>] :inbox_id Optional inbox ids to filter by. Can be repeated. By default will use all inboxes belonging to your account.
691
691
  # @option opts [Integer] :page Optional page index in email list pagination
692
- # @option opts [Integer] :size Optional page size in email list pagination
692
+ # @option opts [Integer] :size Optional page size in email list pagination. Maximum size is 100. Use page index and sort to page through larger results
693
693
  # @option opts [String] :sort Optional createdAt sort direction ASC or DESC
694
694
  # @option opts [Boolean] :unread_only Optional filter for unread emails only. All emails are considered unread until they are viewed in the dashboard or requested directly
695
695
  # @return [Array<(PageEmailProjection, Integer, Hash)>] PageEmailProjection data, response status code and response headers
@@ -207,8 +207,8 @@ module MailSlurpClient
207
207
  return data, status_code, headers
208
208
  end
209
209
 
210
- # List Inboxes Paginated
211
- # List inboxes in paginated form. Allows for page index, page size, and sort direction. Can also filter by favourited or email address like pattern.
210
+ # List All Inboxes Paginated
211
+ # List inboxes in paginated form. The results are available on the `content` property of the returned object. This method allows for page index (zero based), page size (how many results to return(, and a sort direction (based on createdAt time). You Can also filter by whether an inbox is favorited or use email address pattern. This method is the recommended way to query inboxes. The alternative `getInboxes` method returns a full list of inboxes but is limited to 100 results.
212
212
  # @param [Hash] opts the optional parameters
213
213
  # @option opts [Boolean] :favourite Optionally filter results for favourites only (default to false)
214
214
  # @option opts [Integer] :page Optional page index in inbox list pagination (default to 0)
@@ -222,8 +222,8 @@ module MailSlurpClient
222
222
  data
223
223
  end
224
224
 
225
- # List Inboxes Paginated
226
- # List inboxes in paginated form. Allows for page index, page size, and sort direction. Can also filter by favourited or email address like pattern.
225
+ # List All Inboxes Paginated
226
+ # List inboxes in paginated form. The results are available on the &#x60;content&#x60; property of the returned object. This method allows for page index (zero based), page size (how many results to return(, and a sort direction (based on createdAt time). You Can also filter by whether an inbox is favorited or use email address pattern. This method is the recommended way to query inboxes. The alternative &#x60;getInboxes&#x60; method returns a full list of inboxes but is limited to 100 results.
227
227
  # @param [Hash] opts the optional parameters
228
228
  # @option opts [Boolean] :favourite Optionally filter results for favourites only
229
229
  # @option opts [Integer] :page Optional page index in inbox list pagination
@@ -285,14 +285,15 @@ module MailSlurpClient
285
285
  return data, status_code, headers
286
286
  end
287
287
 
288
- # Get emails in an Inbox
288
+ # Get emails in an Inbox. This method is not idempotent as it allows retries and waits if you want certain conditions to be met before returning. For simple listing and sorting of known emails use the email controller instead.
289
289
  # List emails that an inbox has received. Only emails that are sent to the inbox's email address will appear in the inbox. It may take several seconds for any email you send to an inbox's email address to appear in the inbox. To make this endpoint wait for a minimum number of emails use the `minCount` parameter. The server will retry the inbox database until the `minCount` is satisfied or the `retryTimeout` is reached
290
290
  # @param inbox_id [String] Id of inbox that emails belongs to
291
291
  # @param [Hash] opts the optional parameters
292
- # @option opts [Integer] :limit Limit the result set, ordered by received date time sort direction
292
+ # @option opts [Integer] :limit Limit the result set, ordered by received date time sort direction. Maximum 100. For more listing options see the email controller
293
293
  # @option opts [Integer] :min_count Minimum acceptable email count. Will cause request to hang (and retry) until minCount is satisfied or retryTimeout is reached.
294
294
  # @option opts [Integer] :retry_timeout Maximum milliseconds to spend retrying inbox database until minCount emails are returned
295
295
  # @option opts [DateTime] :since Exclude emails received before this ISO 8601 date time
296
+ # @option opts [Integer] :size Alias for limit. Assessed first before assessing any passed limit.
296
297
  # @option opts [String] :sort Sort the results by received date and direction ASC or DESC
297
298
  # @return [Array<EmailPreview>]
298
299
  def get_emails(inbox_id, opts = {})
@@ -300,14 +301,15 @@ module MailSlurpClient
300
301
  data
301
302
  end
302
303
 
303
- # Get emails in an Inbox
304
+ # Get emails in an Inbox. This method is not idempotent as it allows retries and waits if you want certain conditions to be met before returning. For simple listing and sorting of known emails use the email controller instead.
304
305
  # List emails that an inbox has received. Only emails that are sent to the inbox&#39;s email address will appear in the inbox. It may take several seconds for any email you send to an inbox&#39;s email address to appear in the inbox. To make this endpoint wait for a minimum number of emails use the &#x60;minCount&#x60; parameter. The server will retry the inbox database until the &#x60;minCount&#x60; is satisfied or the &#x60;retryTimeout&#x60; is reached
305
306
  # @param inbox_id [String] Id of inbox that emails belongs to
306
307
  # @param [Hash] opts the optional parameters
307
- # @option opts [Integer] :limit Limit the result set, ordered by received date time sort direction
308
+ # @option opts [Integer] :limit Limit the result set, ordered by received date time sort direction. Maximum 100. For more listing options see the email controller
308
309
  # @option opts [Integer] :min_count Minimum acceptable email count. Will cause request to hang (and retry) until minCount is satisfied or retryTimeout is reached.
309
310
  # @option opts [Integer] :retry_timeout Maximum milliseconds to spend retrying inbox database until minCount emails are returned
310
311
  # @option opts [DateTime] :since Exclude emails received before this ISO 8601 date time
312
+ # @option opts [Integer] :size Alias for limit. Assessed first before assessing any passed limit.
311
313
  # @option opts [String] :sort Sort the results by received date and direction ASC or DESC
312
314
  # @return [Array<(Array<EmailPreview>, Integer, Hash)>] Array<EmailPreview> data, response status code and response headers
313
315
  def get_emails_with_http_info(inbox_id, opts = {})
@@ -331,6 +333,7 @@ module MailSlurpClient
331
333
  query_params[:'minCount'] = opts[:'min_count'] if !opts[:'min_count'].nil?
332
334
  query_params[:'retryTimeout'] = opts[:'retry_timeout'] if !opts[:'retry_timeout'].nil?
333
335
  query_params[:'since'] = opts[:'since'] if !opts[:'since'].nil?
336
+ query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
334
337
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
335
338
 
336
339
  # header parameters
@@ -635,8 +638,10 @@ module MailSlurpClient
635
638
  end
636
639
 
637
640
  # List Inboxes / Email Addresses
638
- # List the inboxes you have created
641
+ # List the inboxes you have created. Note use of the more advanced `getAllEmails` is recommended. You can provide a limit and sort parameter.
639
642
  # @param [Hash] opts the optional parameters
643
+ # @option opts [Integer] :size Optional result size limit. Note an automatic limit of 100 results is applied. See the paginated &#x60;getAllEmails&#x60; for larger queries. (default to 100)
644
+ # @option opts [String] :sort Optional createdAt sort direction ASC or DESC (default to 'ASC')
640
645
  # @return [Array<Inbox>]
641
646
  def get_inboxes(opts = {})
642
647
  data, _status_code, _headers = get_inboxes_with_http_info(opts)
@@ -644,18 +649,26 @@ module MailSlurpClient
644
649
  end
645
650
 
646
651
  # List Inboxes / Email Addresses
647
- # List the inboxes you have created
652
+ # List the inboxes you have created. Note use of the more advanced &#x60;getAllEmails&#x60; is recommended. You can provide a limit and sort parameter.
648
653
  # @param [Hash] opts the optional parameters
654
+ # @option opts [Integer] :size Optional result size limit. Note an automatic limit of 100 results is applied. See the paginated &#x60;getAllEmails&#x60; for larger queries.
655
+ # @option opts [String] :sort Optional createdAt sort direction ASC or DESC
649
656
  # @return [Array<(Array<Inbox>, Integer, Hash)>] Array<Inbox> data, response status code and response headers
650
657
  def get_inboxes_with_http_info(opts = {})
651
658
  if @api_client.config.debugging
652
659
  @api_client.config.logger.debug 'Calling API: InboxControllerApi.get_inboxes ...'
653
660
  end
661
+ allowable_values = ["ASC", "DESC"]
662
+ if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
663
+ fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
664
+ end
654
665
  # resource path
655
666
  local_var_path = '/inboxes'
656
667
 
657
668
  # query parameters
658
669
  query_params = opts[:query_params] || {}
670
+ query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
671
+ query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
659
672
 
660
673
  # header parameters
661
674
  header_params = opts[:header_params] || {}
@@ -81,6 +81,129 @@ module MailSlurpClient
81
81
  return data, status_code, headers
82
82
  end
83
83
 
84
+ # Lookup DNS records for a domain
85
+ # @param dns_lookup_options [DNSLookupOptions] dnsLookupOptions
86
+ # @param [Hash] opts the optional parameters
87
+ # @return [DNSLookupResults]
88
+ def get_dns_lookup(dns_lookup_options, opts = {})
89
+ data, _status_code, _headers = get_dns_lookup_with_http_info(dns_lookup_options, opts)
90
+ data
91
+ end
92
+
93
+ # Lookup DNS records for a domain
94
+ # @param dns_lookup_options [DNSLookupOptions] dnsLookupOptions
95
+ # @param [Hash] opts the optional parameters
96
+ # @return [Array<(DNSLookupResults, Integer, Hash)>] DNSLookupResults data, response status code and response headers
97
+ def get_dns_lookup_with_http_info(dns_lookup_options, opts = {})
98
+ if @api_client.config.debugging
99
+ @api_client.config.logger.debug 'Calling API: MailServerControllerApi.get_dns_lookup ...'
100
+ end
101
+ # verify the required parameter 'dns_lookup_options' is set
102
+ if @api_client.config.client_side_validation && dns_lookup_options.nil?
103
+ fail ArgumentError, "Missing the required parameter 'dns_lookup_options' when calling MailServerControllerApi.get_dns_lookup"
104
+ end
105
+ # resource path
106
+ local_var_path = '/mail-server/describe/dns-lookup'
107
+
108
+ # query parameters
109
+ query_params = opts[:query_params] || {}
110
+
111
+ # header parameters
112
+ header_params = opts[:header_params] || {}
113
+ # HTTP header 'Accept' (if needed)
114
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
115
+ # HTTP header 'Content-Type'
116
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
117
+
118
+ # form parameters
119
+ form_params = opts[:form_params] || {}
120
+
121
+ # http body (model)
122
+ post_body = opts[:body] || @api_client.object_to_http_body(dns_lookup_options)
123
+
124
+ # return_type
125
+ return_type = opts[:return_type] || 'DNSLookupResults'
126
+
127
+ # auth_names
128
+ auth_names = opts[:auth_names] || ['API_KEY']
129
+
130
+ new_options = opts.merge(
131
+ :header_params => header_params,
132
+ :query_params => query_params,
133
+ :form_params => form_params,
134
+ :body => post_body,
135
+ :auth_names => auth_names,
136
+ :return_type => return_type
137
+ )
138
+
139
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
140
+ if @api_client.config.debugging
141
+ @api_client.config.logger.debug "API called: MailServerControllerApi#get_dns_lookup\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
142
+ end
143
+ return data, status_code, headers
144
+ end
145
+
146
+ # Get IP address for a domain
147
+ # @param name [String] name
148
+ # @param [Hash] opts the optional parameters
149
+ # @return [IPAddressResult]
150
+ def get_ip_address(name, opts = {})
151
+ data, _status_code, _headers = get_ip_address_with_http_info(name, opts)
152
+ data
153
+ end
154
+
155
+ # Get IP address for a domain
156
+ # @param name [String] name
157
+ # @param [Hash] opts the optional parameters
158
+ # @return [Array<(IPAddressResult, Integer, Hash)>] IPAddressResult data, response status code and response headers
159
+ def get_ip_address_with_http_info(name, opts = {})
160
+ if @api_client.config.debugging
161
+ @api_client.config.logger.debug 'Calling API: MailServerControllerApi.get_ip_address ...'
162
+ end
163
+ # verify the required parameter 'name' is set
164
+ if @api_client.config.client_side_validation && name.nil?
165
+ fail ArgumentError, "Missing the required parameter 'name' when calling MailServerControllerApi.get_ip_address"
166
+ end
167
+ # resource path
168
+ local_var_path = '/mail-server/describe/ip-address'
169
+
170
+ # query parameters
171
+ query_params = opts[:query_params] || {}
172
+ query_params[:'name'] = name
173
+
174
+ # header parameters
175
+ header_params = opts[:header_params] || {}
176
+ # HTTP header 'Accept' (if needed)
177
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
178
+
179
+ # form parameters
180
+ form_params = opts[:form_params] || {}
181
+
182
+ # http body (model)
183
+ post_body = opts[:body]
184
+
185
+ # return_type
186
+ return_type = opts[:return_type] || 'IPAddressResult'
187
+
188
+ # auth_names
189
+ auth_names = opts[:auth_names] || ['API_KEY']
190
+
191
+ new_options = opts.merge(
192
+ :header_params => header_params,
193
+ :query_params => query_params,
194
+ :form_params => form_params,
195
+ :body => post_body,
196
+ :auth_names => auth_names,
197
+ :return_type => return_type
198
+ )
199
+
200
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
201
+ if @api_client.config.debugging
202
+ @api_client.config.logger.debug "API called: MailServerControllerApi#get_ip_address\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
203
+ end
204
+ return data, status_code, headers
205
+ end
206
+
84
207
  # Verify the existence of an email address at a given mail server.
85
208
  # @param verify_options [VerifyEmailAddressOptions] verifyOptions
86
209
  # @param [Hash] opts the optional parameters
@@ -0,0 +1,252 @@
1
+ =begin
2
+ #MailSlurp API
3
+
4
+ #MailSlurp is an API for sending and receiving emails from dynamically allocated email addresses. It's designed for developers and QA teams to test applications, process inbound emails, send templated notifications, attachments, and more. ## Resources - [Homepage](https://www.mailslurp.com) - Get an [API KEY](https://app.mailslurp.com/sign-up/) - Generated [SDK Clients](https://www.mailslurp.com/docs/) - [Examples](https://github.com/mailslurp/examples) repository
5
+
6
+ The version of the OpenAPI document: 6.5.2
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module MailSlurpClient
16
+ # Options for DNS query.
17
+ class DNSLookupOptions
18
+ # List of record types you wish to query such as MX, DNS, TXT, NS, A etc.
19
+ attr_accessor :hostname
20
+
21
+ # Optionally control whether to omit the final dot in full DNS name values.
22
+ attr_accessor :omit_final_dns_dot
23
+
24
+ # List of record types you wish to query such as MX, DNS, TXT, NS, A etc.
25
+ attr_accessor :record_types
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
+ :'hostname' => :'hostname',
53
+ :'omit_final_dns_dot' => :'omitFinalDNSDot',
54
+ :'record_types' => :'recordTypes'
55
+ }
56
+ end
57
+
58
+ # Attribute type mapping.
59
+ def self.openapi_types
60
+ {
61
+ :'hostname' => :'String',
62
+ :'omit_final_dns_dot' => :'Boolean',
63
+ :'record_types' => :'Array<String>'
64
+ }
65
+ end
66
+
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ ])
71
+ end
72
+
73
+ # Initializes the object
74
+ # @param [Hash] attributes Model attributes in the form of hash
75
+ def initialize(attributes = {})
76
+ if (!attributes.is_a?(Hash))
77
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::DNSLookupOptions` initialize method"
78
+ end
79
+
80
+ # check to see if the attribute exists and convert string to symbol for hash key
81
+ attributes = attributes.each_with_object({}) { |(k, v), h|
82
+ if (!self.class.attribute_map.key?(k.to_sym))
83
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::DNSLookupOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
84
+ end
85
+ h[k.to_sym] = v
86
+ }
87
+
88
+ if attributes.key?(:'hostname')
89
+ self.hostname = attributes[:'hostname']
90
+ end
91
+
92
+ if attributes.key?(:'omit_final_dns_dot')
93
+ self.omit_final_dns_dot = attributes[:'omit_final_dns_dot']
94
+ end
95
+
96
+ if attributes.key?(:'record_types')
97
+ if (value = attributes[:'record_types']).is_a?(Array)
98
+ self.record_types = value
99
+ end
100
+ end
101
+ end
102
+
103
+ # Show invalid properties with the reasons. Usually used together with valid?
104
+ # @return Array for valid properties with the reasons
105
+ def list_invalid_properties
106
+ invalid_properties = Array.new
107
+ invalid_properties
108
+ end
109
+
110
+ # Check to see if the all the properties in the model are valid
111
+ # @return true if the model is valid
112
+ def valid?
113
+ true
114
+ end
115
+
116
+ # Checks equality by comparing each attribute.
117
+ # @param [Object] Object to be compared
118
+ def ==(o)
119
+ return true if self.equal?(o)
120
+ self.class == o.class &&
121
+ hostname == o.hostname &&
122
+ omit_final_dns_dot == o.omit_final_dns_dot &&
123
+ record_types == o.record_types
124
+ end
125
+
126
+ # @see the `==` method
127
+ # @param [Object] Object to be compared
128
+ def eql?(o)
129
+ self == o
130
+ end
131
+
132
+ # Calculates hash code according to all attributes.
133
+ # @return [Integer] Hash code
134
+ def hash
135
+ [hostname, omit_final_dns_dot, record_types].hash
136
+ end
137
+
138
+ # Builds the object from hash
139
+ # @param [Hash] attributes Model attributes in the form of hash
140
+ # @return [Object] Returns the model itself
141
+ def self.build_from_hash(attributes)
142
+ new.build_from_hash(attributes)
143
+ end
144
+
145
+ # Builds the object from hash
146
+ # @param [Hash] attributes Model attributes in the form of hash
147
+ # @return [Object] Returns the model itself
148
+ def build_from_hash(attributes)
149
+ return nil unless attributes.is_a?(Hash)
150
+ self.class.openapi_types.each_pair do |key, type|
151
+ if type =~ /\AArray<(.*)>/i
152
+ # check to ensure the input is an array given that the attribute
153
+ # is documented as an array but the input is not
154
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
155
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
156
+ end
157
+ elsif !attributes[self.class.attribute_map[key]].nil?
158
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
159
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
160
+ end
161
+
162
+ self
163
+ end
164
+
165
+ # Deserializes the data based on type
166
+ # @param string type Data type
167
+ # @param string value Value to be deserialized
168
+ # @return [Object] Deserialized data
169
+ def _deserialize(type, value)
170
+ case type.to_sym
171
+ when :DateTime
172
+ DateTime.parse(value)
173
+ when :Date
174
+ Date.parse(value)
175
+ when :String
176
+ value.to_s
177
+ when :Integer
178
+ value.to_i
179
+ when :Float
180
+ value.to_f
181
+ when :Boolean
182
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
183
+ true
184
+ else
185
+ false
186
+ end
187
+ when :Object
188
+ # generic object (usually a Hash), return directly
189
+ value
190
+ when /\AArray<(?<inner_type>.+)>\z/
191
+ inner_type = Regexp.last_match[:inner_type]
192
+ value.map { |v| _deserialize(inner_type, v) }
193
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
194
+ k_type = Regexp.last_match[:k_type]
195
+ v_type = Regexp.last_match[:v_type]
196
+ {}.tap do |hash|
197
+ value.each do |k, v|
198
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
199
+ end
200
+ end
201
+ else # model
202
+ MailSlurpClient.const_get(type).build_from_hash(value)
203
+ end
204
+ end
205
+
206
+ # Returns the string representation of the object
207
+ # @return [String] String presentation of the object
208
+ def to_s
209
+ to_hash.to_s
210
+ end
211
+
212
+ # to_body is an alias to to_hash (backward compatibility)
213
+ # @return [Hash] Returns the object in the form of hash
214
+ def to_body
215
+ to_hash
216
+ end
217
+
218
+ # Returns the object in the form of hash
219
+ # @return [Hash] Returns the object in the form of hash
220
+ def to_hash
221
+ hash = {}
222
+ self.class.attribute_map.each_pair do |attr, param|
223
+ value = self.send(attr)
224
+ if value.nil?
225
+ is_nullable = self.class.openapi_nullable.include?(attr)
226
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
227
+ end
228
+
229
+ hash[param] = _to_hash(value)
230
+ end
231
+ hash
232
+ end
233
+
234
+ # Outputs non-array value in the form of hash
235
+ # For object, use to_hash. Otherwise, just return the value
236
+ # @param [Object] value Any valid value
237
+ # @return [Hash] Returns the value in the form of hash
238
+ def _to_hash(value)
239
+ if value.is_a?(Array)
240
+ value.compact.map { |v| _to_hash(v) }
241
+ elsif value.is_a?(Hash)
242
+ {}.tap do |hash|
243
+ value.each { |k, v| hash[k] = _to_hash(v) }
244
+ end
245
+ elsif value.respond_to? :to_hash
246
+ value.to_hash
247
+ else
248
+ value
249
+ end
250
+ end
251
+ end
252
+ end