mailslurp_client 15.21.0 → 16.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d8a0c5306f41dcd1ab333e4dc2ee75065e8c6e089f1df18c1ed3e3fa544b650
4
- data.tar.gz: 99477adcfc50ec1078d05bf6fba111674433cd9a94001cd53c81ae360486d5d5
3
+ metadata.gz: 8418a224ac9130e45b67e5dae9ecf460fee1ef4cbe130ca08ead41e60b1552fb
4
+ data.tar.gz: 531ff9cf7c5b6a9ee4416ccdd15aa863ed0760034827dc05bfc30df66ddd383f
5
5
  SHA512:
6
- metadata.gz: 7db5fa9fb1238be131d2b0d3452080187d4c6cec467117ccb7088c3ab9364ef3e938add14c37772c254996d89422a2d346333e081e96f79eede7edc6a3b6a23a
7
- data.tar.gz: f2dfc5d866bd13bddbd05a9c3f0ebb6badf5f71d9d756761562b13f92ebfc9c1148da19b9699cd31297459e5f7c86b09df17f23b427dd0dcd039c3035d1e5962
6
+ metadata.gz: 99f2e4bbd21a7698260a6619bb96a9292f5ebc2f1a4b94b82be8d1f8d8d39429f044d77dd2f3be57cb549b6fc637507318dd4efa539bf1fb1b4d315b10f8f53b
7
+ data.tar.gz: c64551c1eb51d5f730406bc98c1d4da01d841634b0251dd9205c9f012ca03f65ce8e850302e5424e1b5147da6fc66c81efafdaca1bb2d2d3384372e788343095
@@ -0,0 +1,86 @@
1
+ =begin
2
+ #MailSlurp API
3
+
4
+ #MailSlurp is an API for sending and receiving emails and SMS from dynamically allocated email addresses and phone numbers. It's designed for developers and QA teams to test applications, process inbound emails, send templated notifications, attachments, and more. ## Resources - [Homepage](https://www.mailslurp.com) - Get an [API KEY](https://app.mailslurp.com/sign-up/) - Generated [SDK Clients](https://docs.mailslurp.com/) - [Examples](https://github.com/mailslurp/examples) repository
5
+
6
+ The version of the OpenAPI document: 6.5.2
7
+ Contact: contact@mailslurp.dev
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module MailSlurpClient
16
+ class AIControllerApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Generate structured content for an email
23
+ # Use output schemas to extract data from an email using AI
24
+ # @param generate_structured_content_email_options [GenerateStructuredContentEmailOptions]
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [StructuredContentResult]
27
+ def generate_structured_content_from_email(generate_structured_content_email_options, opts = {})
28
+ data, _status_code, _headers = generate_structured_content_from_email_with_http_info(generate_structured_content_email_options, opts)
29
+ data
30
+ end
31
+
32
+ # Generate structured content for an email
33
+ # Use output schemas to extract data from an email using AI
34
+ # @param generate_structured_content_email_options [GenerateStructuredContentEmailOptions]
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(StructuredContentResult, Integer, Hash)>] StructuredContentResult data, response status code and response headers
37
+ def generate_structured_content_from_email_with_http_info(generate_structured_content_email_options, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: AIControllerApi.generate_structured_content_from_email ...'
40
+ end
41
+ # verify the required parameter 'generate_structured_content_email_options' is set
42
+ if @api_client.config.client_side_validation && generate_structured_content_email_options.nil?
43
+ fail ArgumentError, "Missing the required parameter 'generate_structured_content_email_options' when calling AIControllerApi.generate_structured_content_from_email"
44
+ end
45
+ # resource path
46
+ local_var_path = '/ai/structured-content/email'
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(['*/*'])
55
+ # HTTP header 'Content-Type'
56
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
57
+
58
+ # form parameters
59
+ form_params = opts[:form_params] || {}
60
+
61
+ # http body (model)
62
+ post_body = opts[:body] || @api_client.object_to_http_body(generate_structured_content_email_options)
63
+
64
+ # return_type
65
+ return_type = opts[:return_type] || 'StructuredContentResult'
66
+
67
+ # auth_names
68
+ auth_names = opts[:auth_names] || ['API_KEY']
69
+
70
+ new_options = opts.merge(
71
+ :header_params => header_params,
72
+ :query_params => query_params,
73
+ :form_params => form_params,
74
+ :body => post_body,
75
+ :auth_names => auth_names,
76
+ :return_type => return_type
77
+ )
78
+
79
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
80
+ if @api_client.config.debugging
81
+ @api_client.config.logger.debug "API called: AIControllerApi#generate_structured_content_from_email\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
82
+ end
83
+ return data, status_code, headers
84
+ end
85
+ end
86
+ end
@@ -709,6 +709,132 @@ module MailSlurpClient
709
709
  return data, status_code, headers
710
710
  end
711
711
 
712
+ # Get a phone number by name
713
+ # Get a phone number by name
714
+ # @param name [String]
715
+ # @param [Hash] opts the optional parameters
716
+ # @return [PhoneNumberDto]
717
+ def get_phone_number_by_name(name, opts = {})
718
+ data, _status_code, _headers = get_phone_number_by_name_with_http_info(name, opts)
719
+ data
720
+ end
721
+
722
+ # Get a phone number by name
723
+ # Get a phone number by name
724
+ # @param name [String]
725
+ # @param [Hash] opts the optional parameters
726
+ # @return [Array<(PhoneNumberDto, Integer, Hash)>] PhoneNumberDto data, response status code and response headers
727
+ def get_phone_number_by_name_with_http_info(name, opts = {})
728
+ if @api_client.config.debugging
729
+ @api_client.config.logger.debug 'Calling API: PhoneControllerApi.get_phone_number_by_name ...'
730
+ end
731
+ # verify the required parameter 'name' is set
732
+ if @api_client.config.client_side_validation && name.nil?
733
+ fail ArgumentError, "Missing the required parameter 'name' when calling PhoneControllerApi.get_phone_number_by_name"
734
+ end
735
+ # resource path
736
+ local_var_path = '/phone/numbers/by-name'
737
+
738
+ # query parameters
739
+ query_params = opts[:query_params] || {}
740
+ query_params[:'name'] = name
741
+
742
+ # header parameters
743
+ header_params = opts[:header_params] || {}
744
+ # HTTP header 'Accept' (if needed)
745
+ header_params['Accept'] = @api_client.select_header_accept(['*/*'])
746
+
747
+ # form parameters
748
+ form_params = opts[:form_params] || {}
749
+
750
+ # http body (model)
751
+ post_body = opts[:body]
752
+
753
+ # return_type
754
+ return_type = opts[:return_type] || 'PhoneNumberDto'
755
+
756
+ # auth_names
757
+ auth_names = opts[:auth_names] || ['API_KEY']
758
+
759
+ new_options = opts.merge(
760
+ :header_params => header_params,
761
+ :query_params => query_params,
762
+ :form_params => form_params,
763
+ :body => post_body,
764
+ :auth_names => auth_names,
765
+ :return_type => return_type
766
+ )
767
+
768
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
769
+ if @api_client.config.debugging
770
+ @api_client.config.logger.debug "API called: PhoneControllerApi#get_phone_number_by_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
771
+ end
772
+ return data, status_code, headers
773
+ end
774
+
775
+ # Get a phone number by phone number
776
+ # Get a phone number by phone number
777
+ # @param phone_number [String]
778
+ # @param [Hash] opts the optional parameters
779
+ # @return [PhoneNumberDto]
780
+ def get_phone_number_by_phone_number(phone_number, opts = {})
781
+ data, _status_code, _headers = get_phone_number_by_phone_number_with_http_info(phone_number, opts)
782
+ data
783
+ end
784
+
785
+ # Get a phone number by phone number
786
+ # Get a phone number by phone number
787
+ # @param phone_number [String]
788
+ # @param [Hash] opts the optional parameters
789
+ # @return [Array<(PhoneNumberDto, Integer, Hash)>] PhoneNumberDto data, response status code and response headers
790
+ def get_phone_number_by_phone_number_with_http_info(phone_number, opts = {})
791
+ if @api_client.config.debugging
792
+ @api_client.config.logger.debug 'Calling API: PhoneControllerApi.get_phone_number_by_phone_number ...'
793
+ end
794
+ # verify the required parameter 'phone_number' is set
795
+ if @api_client.config.client_side_validation && phone_number.nil?
796
+ fail ArgumentError, "Missing the required parameter 'phone_number' when calling PhoneControllerApi.get_phone_number_by_phone_number"
797
+ end
798
+ # resource path
799
+ local_var_path = '/phone/numbers/by-phone-number'
800
+
801
+ # query parameters
802
+ query_params = opts[:query_params] || {}
803
+ query_params[:'phoneNumber'] = phone_number
804
+
805
+ # header parameters
806
+ header_params = opts[:header_params] || {}
807
+ # HTTP header 'Accept' (if needed)
808
+ header_params['Accept'] = @api_client.select_header_accept(['*/*'])
809
+
810
+ # form parameters
811
+ form_params = opts[:form_params] || {}
812
+
813
+ # http body (model)
814
+ post_body = opts[:body]
815
+
816
+ # return_type
817
+ return_type = opts[:return_type] || 'PhoneNumberDto'
818
+
819
+ # auth_names
820
+ auth_names = opts[:auth_names] || ['API_KEY']
821
+
822
+ new_options = opts.merge(
823
+ :header_params => header_params,
824
+ :query_params => query_params,
825
+ :form_params => form_params,
826
+ :body => post_body,
827
+ :auth_names => auth_names,
828
+ :return_type => return_type
829
+ )
830
+
831
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
832
+ if @api_client.config.debugging
833
+ @api_client.config.logger.debug "API called: PhoneControllerApi#get_phone_number_by_phone_number\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
834
+ end
835
+ return data, status_code, headers
836
+ end
837
+
712
838
  # Get phone numbers
713
839
  # List phone numbers for account
714
840
  # @param [Hash] opts the optional parameters
@@ -43,9 +43,6 @@ module MailSlurpClient
43
43
  # Has attachments
44
44
  attr_accessor :has_attachments
45
45
 
46
- # Has unread
47
- attr_accessor :unread
48
-
49
46
  # Number of messages in the thread
50
47
  attr_accessor :message_count
51
48
 
@@ -63,6 +60,9 @@ module MailSlurpClient
63
60
 
64
61
  attr_accessor :last_sender
65
62
 
63
+ # Has unread
64
+ attr_accessor :unread
65
+
66
66
  # Thread topic subject
67
67
  attr_accessor :subject
68
68
 
@@ -85,13 +85,13 @@ module MailSlurpClient
85
85
  :'cc' => :'cc',
86
86
  :'bcc' => :'bcc',
87
87
  :'has_attachments' => :'hasAttachments',
88
- :'unread' => :'unread',
89
88
  :'message_count' => :'messageCount',
90
89
  :'last_body_excerpt' => :'lastBodyExcerpt',
91
90
  :'last_text_excerpt' => :'lastTextExcerpt',
92
91
  :'last_created_at' => :'lastCreatedAt',
93
92
  :'last_from' => :'lastFrom',
94
93
  :'last_sender' => :'lastSender',
94
+ :'unread' => :'unread',
95
95
  :'subject' => :'subject',
96
96
  :'id' => :'id',
97
97
  :'from' => :'from'
@@ -111,13 +111,13 @@ module MailSlurpClient
111
111
  :'cc' => :'Array<String>',
112
112
  :'bcc' => :'Array<String>',
113
113
  :'has_attachments' => :'Boolean',
114
- :'unread' => :'Boolean',
115
114
  :'message_count' => :'Integer',
116
115
  :'last_body_excerpt' => :'String',
117
116
  :'last_text_excerpt' => :'String',
118
117
  :'last_created_at' => :'DateTime',
119
118
  :'last_from' => :'String',
120
119
  :'last_sender' => :'SenderProjection',
120
+ :'unread' => :'Boolean',
121
121
  :'subject' => :'String',
122
122
  :'id' => :'String',
123
123
  :'from' => :'String'
@@ -191,10 +191,6 @@ module MailSlurpClient
191
191
  self.has_attachments = attributes[:'has_attachments']
192
192
  end
193
193
 
194
- if attributes.key?(:'unread')
195
- self.unread = attributes[:'unread']
196
- end
197
-
198
194
  if attributes.key?(:'message_count')
199
195
  self.message_count = attributes[:'message_count']
200
196
  end
@@ -219,6 +215,10 @@ module MailSlurpClient
219
215
  self.last_sender = attributes[:'last_sender']
220
216
  end
221
217
 
218
+ if attributes.key?(:'unread')
219
+ self.unread = attributes[:'unread']
220
+ end
221
+
222
222
  if attributes.key?(:'subject')
223
223
  self.subject = attributes[:'subject']
224
224
  end
@@ -256,14 +256,14 @@ module MailSlurpClient
256
256
  invalid_properties.push('invalid value for "has_attachments", has_attachments cannot be nil.')
257
257
  end
258
258
 
259
- if @unread.nil?
260
- invalid_properties.push('invalid value for "unread", unread cannot be nil.')
261
- end
262
-
263
259
  if @message_count.nil?
264
260
  invalid_properties.push('invalid value for "message_count", message_count cannot be nil.')
265
261
  end
266
262
 
263
+ if @unread.nil?
264
+ invalid_properties.push('invalid value for "unread", unread cannot be nil.')
265
+ end
266
+
267
267
  if @id.nil?
268
268
  invalid_properties.push('invalid value for "id", id cannot be nil.')
269
269
  end
@@ -279,8 +279,8 @@ module MailSlurpClient
279
279
  return false if @created_at.nil?
280
280
  return false if @to.nil?
281
281
  return false if @has_attachments.nil?
282
- return false if @unread.nil?
283
282
  return false if @message_count.nil?
283
+ return false if @unread.nil?
284
284
  return false if @id.nil?
285
285
  true
286
286
  end
@@ -300,13 +300,13 @@ module MailSlurpClient
300
300
  cc == o.cc &&
301
301
  bcc == o.bcc &&
302
302
  has_attachments == o.has_attachments &&
303
- unread == o.unread &&
304
303
  message_count == o.message_count &&
305
304
  last_body_excerpt == o.last_body_excerpt &&
306
305
  last_text_excerpt == o.last_text_excerpt &&
307
306
  last_created_at == o.last_created_at &&
308
307
  last_from == o.last_from &&
309
308
  last_sender == o.last_sender &&
309
+ unread == o.unread &&
310
310
  subject == o.subject &&
311
311
  id == o.id &&
312
312
  from == o.from
@@ -321,7 +321,7 @@ module MailSlurpClient
321
321
  # Calculates hash code according to all attributes.
322
322
  # @return [Integer] Hash code
323
323
  def hash
324
- [sender, recipients, user_id, inbox_id, updated_at, created_at, to, cc, bcc, has_attachments, unread, message_count, last_body_excerpt, last_text_excerpt, last_created_at, last_from, last_sender, subject, id, from].hash
324
+ [sender, recipients, user_id, inbox_id, updated_at, created_at, to, cc, bcc, has_attachments, message_count, last_body_excerpt, last_text_excerpt, last_created_at, last_from, last_sender, unread, subject, id, from].hash
325
325
  end
326
326
 
327
327
  # Builds the object from hash
@@ -0,0 +1,281 @@
1
+ =begin
2
+ #MailSlurp API
3
+
4
+ #MailSlurp is an API for sending and receiving emails and SMS from dynamically allocated email addresses and phone numbers. It's designed for developers and QA teams to test applications, process inbound emails, send templated notifications, attachments, and more. ## Resources - [Homepage](https://www.mailslurp.com) - Get an [API KEY](https://app.mailslurp.com/sign-up/) - Generated [SDK Clients](https://docs.mailslurp.com/) - [Examples](https://github.com/mailslurp/examples) repository
5
+
6
+ The version of the OpenAPI document: 6.5.2
7
+ Contact: contact@mailslurp.dev
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module MailSlurpClient
16
+ # Options for generating structured content output from an email
17
+ class GenerateStructuredContentEmailOptions
18
+ # Email ID to read and pass to AI
19
+ attr_accessor :email_id
20
+
21
+ # Content selector to select part of email to operate on
22
+ attr_accessor :content_selector
23
+
24
+ # Optional instructions for the AI to follow. Try to be precise and clear. You can include examples and hints.
25
+ attr_accessor :instructions
26
+
27
+ attr_accessor :output_schema
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
+ :'email_id' => :'emailId',
55
+ :'content_selector' => :'contentSelector',
56
+ :'instructions' => :'instructions',
57
+ :'output_schema' => :'outputSchema'
58
+ }
59
+ end
60
+
61
+ # Attribute type mapping.
62
+ def self.openapi_types
63
+ {
64
+ :'email_id' => :'String',
65
+ :'content_selector' => :'String',
66
+ :'instructions' => :'String',
67
+ :'output_schema' => :'StructuredOutputSchema'
68
+ }
69
+ end
70
+
71
+ # List of attributes with nullable: true
72
+ def self.openapi_nullable
73
+ Set.new([
74
+ ])
75
+ end
76
+
77
+ # Initializes the object
78
+ # @param [Hash] attributes Model attributes in the form of hash
79
+ def initialize(attributes = {})
80
+ if (!attributes.is_a?(Hash))
81
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::GenerateStructuredContentEmailOptions` initialize method"
82
+ end
83
+
84
+ # check to see if the attribute exists and convert string to symbol for hash key
85
+ attributes = attributes.each_with_object({}) { |(k, v), h|
86
+ if (!self.class.attribute_map.key?(k.to_sym))
87
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::GenerateStructuredContentEmailOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
88
+ end
89
+ h[k.to_sym] = v
90
+ }
91
+
92
+ if attributes.key?(:'email_id')
93
+ self.email_id = attributes[:'email_id']
94
+ end
95
+
96
+ if attributes.key?(:'content_selector')
97
+ self.content_selector = attributes[:'content_selector']
98
+ end
99
+
100
+ if attributes.key?(:'instructions')
101
+ self.instructions = attributes[:'instructions']
102
+ end
103
+
104
+ if attributes.key?(:'output_schema')
105
+ self.output_schema = attributes[:'output_schema']
106
+ end
107
+ end
108
+
109
+ # Show invalid properties with the reasons. Usually used together with valid?
110
+ # @return Array for valid properties with the reasons
111
+ def list_invalid_properties
112
+ invalid_properties = Array.new
113
+ if @email_id.nil?
114
+ invalid_properties.push('invalid value for "email_id", email_id cannot be nil.')
115
+ end
116
+
117
+ if @output_schema.nil?
118
+ invalid_properties.push('invalid value for "output_schema", output_schema cannot be nil.')
119
+ end
120
+
121
+ invalid_properties
122
+ end
123
+
124
+ # Check to see if the all the properties in the model are valid
125
+ # @return true if the model is valid
126
+ def valid?
127
+ return false if @email_id.nil?
128
+ content_selector_validator = EnumAttributeValidator.new('String', ["RAW", "BODY"])
129
+ return false unless content_selector_validator.valid?(@content_selector)
130
+ return false if @output_schema.nil?
131
+ true
132
+ end
133
+
134
+ # Custom attribute writer method checking allowed values (enum).
135
+ # @param [Object] content_selector Object to be assigned
136
+ def content_selector=(content_selector)
137
+ validator = EnumAttributeValidator.new('String', ["RAW", "BODY"])
138
+ unless validator.valid?(content_selector)
139
+ fail ArgumentError, "invalid value for \"content_selector\", must be one of #{validator.allowable_values}."
140
+ end
141
+ @content_selector = content_selector
142
+ end
143
+
144
+ # Checks equality by comparing each attribute.
145
+ # @param [Object] Object to be compared
146
+ def ==(o)
147
+ return true if self.equal?(o)
148
+ self.class == o.class &&
149
+ email_id == o.email_id &&
150
+ content_selector == o.content_selector &&
151
+ instructions == o.instructions &&
152
+ output_schema == o.output_schema
153
+ end
154
+
155
+ # @see the `==` method
156
+ # @param [Object] Object to be compared
157
+ def eql?(o)
158
+ self == o
159
+ end
160
+
161
+ # Calculates hash code according to all attributes.
162
+ # @return [Integer] Hash code
163
+ def hash
164
+ [email_id, content_selector, instructions, output_schema].hash
165
+ end
166
+
167
+ # Builds the object from hash
168
+ # @param [Hash] attributes Model attributes in the form of hash
169
+ # @return [Object] Returns the model itself
170
+ def self.build_from_hash(attributes)
171
+ new.build_from_hash(attributes)
172
+ end
173
+
174
+ # Builds the object from hash
175
+ # @param [Hash] attributes Model attributes in the form of hash
176
+ # @return [Object] Returns the model itself
177
+ def build_from_hash(attributes)
178
+ return nil unless attributes.is_a?(Hash)
179
+ self.class.openapi_types.each_pair do |key, type|
180
+ if type =~ /\AArray<(.*)>/i
181
+ # check to ensure the input is an array given that the attribute
182
+ # is documented as an array but the input is not
183
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
184
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
185
+ end
186
+ elsif !attributes[self.class.attribute_map[key]].nil?
187
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
188
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
189
+ end
190
+
191
+ self
192
+ end
193
+
194
+ # Deserializes the data based on type
195
+ # @param string type Data type
196
+ # @param string value Value to be deserialized
197
+ # @return [Object] Deserialized data
198
+ def _deserialize(type, value)
199
+ case type.to_sym
200
+ when :DateTime
201
+ DateTime.parse(value)
202
+ when :Date
203
+ Date.parse(value)
204
+ when :String
205
+ value.to_s
206
+ when :Integer
207
+ value.to_i
208
+ when :Float
209
+ value.to_f
210
+ when :Boolean
211
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
212
+ true
213
+ else
214
+ false
215
+ end
216
+ when :Object
217
+ # generic object (usually a Hash), return directly
218
+ value
219
+ when /\AArray<(?<inner_type>.+)>\z/
220
+ inner_type = Regexp.last_match[:inner_type]
221
+ value.map { |v| _deserialize(inner_type, v) }
222
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
223
+ k_type = Regexp.last_match[:k_type]
224
+ v_type = Regexp.last_match[:v_type]
225
+ {}.tap do |hash|
226
+ value.each do |k, v|
227
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
228
+ end
229
+ end
230
+ else # model
231
+ MailSlurpClient.const_get(type).build_from_hash(value)
232
+ end
233
+ end
234
+
235
+ # Returns the string representation of the object
236
+ # @return [String] String presentation of the object
237
+ def to_s
238
+ to_hash.to_s
239
+ end
240
+
241
+ # to_body is an alias to to_hash (backward compatibility)
242
+ # @return [Hash] Returns the object in the form of hash
243
+ def to_body
244
+ to_hash
245
+ end
246
+
247
+ # Returns the object in the form of hash
248
+ # @return [Hash] Returns the object in the form of hash
249
+ def to_hash
250
+ hash = {}
251
+ self.class.attribute_map.each_pair do |attr, param|
252
+ value = self.send(attr)
253
+ if value.nil?
254
+ is_nullable = self.class.openapi_nullable.include?(attr)
255
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
256
+ end
257
+
258
+ hash[param] = _to_hash(value)
259
+ end
260
+ hash
261
+ end
262
+
263
+ # Outputs non-array value in the form of hash
264
+ # For object, use to_hash. Otherwise, just return the value
265
+ # @param [Object] value Any valid value
266
+ # @return [Hash] Returns the value in the form of hash
267
+ def _to_hash(value)
268
+ if value.is_a?(Array)
269
+ value.compact.map { |v| _to_hash(v) }
270
+ elsif value.is_a?(Hash)
271
+ {}.tap do |hash|
272
+ value.each { |k, v| hash[k] = _to_hash(v) }
273
+ end
274
+ elsif value.respond_to? :to_hash
275
+ value.to_hash
276
+ else
277
+ value
278
+ end
279
+ end
280
+ end
281
+ end