mailslurp_client 12.5.0 → 12.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mailslurp_client.rb +17 -2
  3. data/lib/mailslurp_client/api/contact_controller_api.rb +4 -4
  4. data/lib/mailslurp_client/api/email_controller_api.rb +71 -5
  5. data/lib/mailslurp_client/api/group_controller_api.rb +4 -4
  6. data/lib/mailslurp_client/api/inbox_controller_api.rb +107 -22
  7. data/lib/mailslurp_client/api/inbox_forwarder_controller_api.rb +548 -0
  8. data/lib/mailslurp_client/api/inbox_ruleset_controller_api.rb +211 -3
  9. data/lib/mailslurp_client/api/missed_email_controller_api.rb +75 -7
  10. data/lib/mailslurp_client/api/sent_emails_controller_api.rb +150 -4
  11. data/lib/mailslurp_client/api/template_controller_api.rb +4 -4
  12. data/lib/mailslurp_client/api/tracking_controller_api.rb +218 -0
  13. data/lib/mailslurp_client/api/wait_for_controller_api.rb +2 -2
  14. data/lib/mailslurp_client/api/webhook_controller_api.rb +55 -1
  15. data/lib/mailslurp_client/models/abstract_webhook_payload.rb +3 -3
  16. data/lib/mailslurp_client/models/create_inbox_forwarder_options.rb +275 -0
  17. data/lib/mailslurp_client/models/create_inbox_ruleset_options.rb +4 -4
  18. data/lib/mailslurp_client/models/create_tracking_pixel_options.rb +215 -0
  19. data/lib/mailslurp_client/models/create_webhook_options.rb +3 -3
  20. data/lib/mailslurp_client/models/domain_preview.rb +66 -4
  21. data/lib/mailslurp_client/models/email.rb +11 -1
  22. data/lib/mailslurp_client/models/email_projection.rb +10 -1
  23. data/lib/mailslurp_client/models/{inbox_ruleset_projection.rb → inbox_forwarder_dto.rb} +55 -78
  24. data/lib/mailslurp_client/models/inbox_forwarder_test_options.rb +211 -0
  25. data/lib/mailslurp_client/models/inbox_forwarder_test_result.rb +227 -0
  26. data/lib/mailslurp_client/models/inbox_ruleset_dto.rb +17 -3
  27. data/lib/mailslurp_client/models/inbox_ruleset_test_options.rb +211 -0
  28. data/lib/mailslurp_client/models/inbox_ruleset_test_result.rb +223 -0
  29. data/lib/mailslurp_client/models/page_inbox_forwarder_dto.rb +299 -0
  30. data/lib/mailslurp_client/models/{page_inbox_ruleset_projection.rb → page_inbox_ruleset_dto.rb} +4 -4
  31. data/lib/mailslurp_client/models/page_tracking_pixel_projection.rb +299 -0
  32. data/lib/mailslurp_client/models/send_email_options.rb +11 -1
  33. data/lib/mailslurp_client/models/sent_email_dto.rb +12 -1
  34. data/lib/mailslurp_client/models/test_new_inbox_forwarder_options.rb +225 -0
  35. data/lib/mailslurp_client/models/test_new_inbox_ruleset_options.rb +225 -0
  36. data/lib/mailslurp_client/models/tracking_pixel_dto.rb +303 -0
  37. data/lib/mailslurp_client/models/tracking_pixel_projection.rb +289 -0
  38. data/lib/mailslurp_client/models/webhook_dto.rb +2 -2
  39. data/lib/mailslurp_client/models/webhook_email_opened_payload.rb +322 -0
  40. data/lib/mailslurp_client/models/webhook_new_attachment_payload.rb +2 -2
  41. data/lib/mailslurp_client/models/webhook_new_contact_payload.rb +2 -2
  42. data/lib/mailslurp_client/models/webhook_new_email_payload.rb +2 -2
  43. data/lib/mailslurp_client/models/webhook_result_entity.rb +2 -2
  44. data/lib/mailslurp_client/version.rb +1 -1
  45. metadata +19 -4
@@ -141,8 +141,8 @@ module MailSlurpClient
141
141
 
142
142
  # Get all Templates in paginated format
143
143
  # @param [Hash] opts the optional parameters
144
- # @option opts [Integer] :page Optional page index in inbox list pagination (default to 0)
145
- # @option opts [Integer] :size Optional page size in inbox list pagination (default to 20)
144
+ # @option opts [Integer] :page Optional page index in list pagination (default to 0)
145
+ # @option opts [Integer] :size Optional page size in list pagination (default to 20)
146
146
  # @option opts [String] :sort Optional createdAt sort direction ASC or DESC (default to 'ASC')
147
147
  # @return [PageTemplateProjection]
148
148
  def get_all_templates(opts = {})
@@ -152,8 +152,8 @@ module MailSlurpClient
152
152
 
153
153
  # Get all Templates in paginated format
154
154
  # @param [Hash] opts the optional parameters
155
- # @option opts [Integer] :page Optional page index in inbox list pagination
156
- # @option opts [Integer] :size Optional page size in inbox list pagination
155
+ # @option opts [Integer] :page Optional page index in list pagination
156
+ # @option opts [Integer] :size Optional page size in list pagination
157
157
  # @option opts [String] :sort Optional createdAt sort direction ASC or DESC
158
158
  # @return [Array<(PageTemplateProjection, Integer, Hash)>] PageTemplateProjection data, response status code and response headers
159
159
  def get_all_templates_with_http_info(opts = {})
@@ -0,0 +1,218 @@
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 TrackingControllerApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Create tracking pixel
23
+ # Create a tracking pixel. A tracking pixel is an image that can be embedded in an email. When the email is viewed and the image is seen MailSlurp will mark the pixel as seen. Use tracking pixels to monitor email open events. You can receive open notifications via webhook or by fetching the pixel.
24
+ # @param create_tracking_pixel_options [CreateTrackingPixelOptions] createTrackingPixelOptions
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [TrackingPixelDto]
27
+ def create_tracking_pixel(create_tracking_pixel_options, opts = {})
28
+ data, _status_code, _headers = create_tracking_pixel_with_http_info(create_tracking_pixel_options, opts)
29
+ data
30
+ end
31
+
32
+ # Create tracking pixel
33
+ # Create a tracking pixel. A tracking pixel is an image that can be embedded in an email. When the email is viewed and the image is seen MailSlurp will mark the pixel as seen. Use tracking pixels to monitor email open events. You can receive open notifications via webhook or by fetching the pixel.
34
+ # @param create_tracking_pixel_options [CreateTrackingPixelOptions] createTrackingPixelOptions
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(TrackingPixelDto, Integer, Hash)>] TrackingPixelDto data, response status code and response headers
37
+ def create_tracking_pixel_with_http_info(create_tracking_pixel_options, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: TrackingControllerApi.create_tracking_pixel ...'
40
+ end
41
+ # verify the required parameter 'create_tracking_pixel_options' is set
42
+ if @api_client.config.client_side_validation && create_tracking_pixel_options.nil?
43
+ fail ArgumentError, "Missing the required parameter 'create_tracking_pixel_options' when calling TrackingControllerApi.create_tracking_pixel"
44
+ end
45
+ # resource path
46
+ local_var_path = '/tracking/pixels'
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
+ # 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(create_tracking_pixel_options)
63
+
64
+ # return_type
65
+ return_type = opts[:return_type] || 'TrackingPixelDto'
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: TrackingControllerApi#create_tracking_pixel\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
82
+ end
83
+ return data, status_code, headers
84
+ end
85
+
86
+ # Get tracking pixels
87
+ # List tracking pixels in paginated form
88
+ # @param [Hash] opts the optional parameters
89
+ # @option opts [Integer] :page Optional page index in list pagination (default to 0)
90
+ # @option opts [String] :search_filter Optional search filter
91
+ # @option opts [Integer] :size Optional page size in list pagination (default to 20)
92
+ # @option opts [String] :sort Optional createdAt sort direction ASC or DESC (default to 'ASC')
93
+ # @return [PageTrackingPixelProjection]
94
+ def get_all_tracking_pixels(opts = {})
95
+ data, _status_code, _headers = get_all_tracking_pixels_with_http_info(opts)
96
+ data
97
+ end
98
+
99
+ # Get tracking pixels
100
+ # List tracking pixels in paginated form
101
+ # @param [Hash] opts the optional parameters
102
+ # @option opts [Integer] :page Optional page index in list pagination
103
+ # @option opts [String] :search_filter Optional search filter
104
+ # @option opts [Integer] :size Optional page size in list pagination
105
+ # @option opts [String] :sort Optional createdAt sort direction ASC or DESC
106
+ # @return [Array<(PageTrackingPixelProjection, Integer, Hash)>] PageTrackingPixelProjection data, response status code and response headers
107
+ def get_all_tracking_pixels_with_http_info(opts = {})
108
+ if @api_client.config.debugging
109
+ @api_client.config.logger.debug 'Calling API: TrackingControllerApi.get_all_tracking_pixels ...'
110
+ end
111
+ allowable_values = ["ASC", "DESC"]
112
+ if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
113
+ fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
114
+ end
115
+ # resource path
116
+ local_var_path = '/tracking/pixels'
117
+
118
+ # query parameters
119
+ query_params = opts[:query_params] || {}
120
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
121
+ query_params[:'searchFilter'] = opts[:'search_filter'] if !opts[:'search_filter'].nil?
122
+ query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
123
+ query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
124
+
125
+ # header parameters
126
+ header_params = opts[:header_params] || {}
127
+ # HTTP header 'Accept' (if needed)
128
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
129
+
130
+ # form parameters
131
+ form_params = opts[:form_params] || {}
132
+
133
+ # http body (model)
134
+ post_body = opts[:body]
135
+
136
+ # return_type
137
+ return_type = opts[:return_type] || 'PageTrackingPixelProjection'
138
+
139
+ # auth_names
140
+ auth_names = opts[:auth_names] || ['API_KEY']
141
+
142
+ new_options = opts.merge(
143
+ :header_params => header_params,
144
+ :query_params => query_params,
145
+ :form_params => form_params,
146
+ :body => post_body,
147
+ :auth_names => auth_names,
148
+ :return_type => return_type
149
+ )
150
+
151
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
152
+ if @api_client.config.debugging
153
+ @api_client.config.logger.debug "API called: TrackingControllerApi#get_all_tracking_pixels\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
154
+ end
155
+ return data, status_code, headers
156
+ end
157
+
158
+ # Get pixel
159
+ # @param id [String] id
160
+ # @param [Hash] opts the optional parameters
161
+ # @return [TrackingPixelDto]
162
+ def get_tracking_pixel(id, opts = {})
163
+ data, _status_code, _headers = get_tracking_pixel_with_http_info(id, opts)
164
+ data
165
+ end
166
+
167
+ # Get pixel
168
+ # @param id [String] id
169
+ # @param [Hash] opts the optional parameters
170
+ # @return [Array<(TrackingPixelDto, Integer, Hash)>] TrackingPixelDto data, response status code and response headers
171
+ def get_tracking_pixel_with_http_info(id, opts = {})
172
+ if @api_client.config.debugging
173
+ @api_client.config.logger.debug 'Calling API: TrackingControllerApi.get_tracking_pixel ...'
174
+ end
175
+ # verify the required parameter 'id' is set
176
+ if @api_client.config.client_side_validation && id.nil?
177
+ fail ArgumentError, "Missing the required parameter 'id' when calling TrackingControllerApi.get_tracking_pixel"
178
+ end
179
+ # resource path
180
+ local_var_path = '/tracking/pixels/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
181
+
182
+ # query parameters
183
+ query_params = opts[:query_params] || {}
184
+
185
+ # header parameters
186
+ header_params = opts[:header_params] || {}
187
+ # HTTP header 'Accept' (if needed)
188
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
189
+
190
+ # form parameters
191
+ form_params = opts[:form_params] || {}
192
+
193
+ # http body (model)
194
+ post_body = opts[:body]
195
+
196
+ # return_type
197
+ return_type = opts[:return_type] || 'TrackingPixelDto'
198
+
199
+ # auth_names
200
+ auth_names = opts[:auth_names] || ['API_KEY']
201
+
202
+ new_options = opts.merge(
203
+ :header_params => header_params,
204
+ :query_params => query_params,
205
+ :form_params => form_params,
206
+ :body => post_body,
207
+ :auth_names => auth_names,
208
+ :return_type => return_type
209
+ )
210
+
211
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
212
+ if @api_client.config.debugging
213
+ @api_client.config.logger.debug "API called: TrackingControllerApi#get_tracking_pixel\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
214
+ end
215
+ return data, status_code, headers
216
+ end
217
+ end
218
+ end
@@ -361,7 +361,7 @@ module MailSlurpClient
361
361
  return data, status_code, headers
362
362
  end
363
363
 
364
- # Wait for or fetch the email with a given index in the inbox specified. IF indx doesn't exist waits for it to exist or timeout to occur.
364
+ # Wait for or fetch the email with a given index in the inbox specified. If index doesn't exist waits for it to exist or timeout to occur.
365
365
  # If nth email is already present in inbox then return it. If not hold the connection open until timeout expires or the nth email is received and returned.
366
366
  # @param [Hash] opts the optional parameters
367
367
  # @option opts [String] :inbox_id Id of the inbox you are fetching emails from
@@ -374,7 +374,7 @@ module MailSlurpClient
374
374
  data
375
375
  end
376
376
 
377
- # Wait for or fetch the email with a given index in the inbox specified. IF indx doesn&#39;t exist waits for it to exist or timeout to occur.
377
+ # Wait for or fetch the email with a given index in the inbox specified. If index doesn&#39;t exist waits for it to exist or timeout to occur.
378
378
  # If nth email is already present in inbox then return it. If not hold the connection open until timeout expires or the nth email is received and returned.
379
379
  # @param [Hash] opts the optional parameters
380
380
  # @option opts [String] :inbox_id Id of the inbox you are fetching emails from
@@ -388,7 +388,7 @@ module MailSlurpClient
388
388
  if @api_client.config.debugging
389
389
  @api_client.config.logger.debug 'Calling API: WebhookControllerApi.get_test_webhook_payload ...'
390
390
  end
391
- allowable_values = ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT"]
391
+ allowable_values = ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT", "EMAIL_OPENED"]
392
392
  if @api_client.config.client_side_validation && opts[:'event_name'] && !allowable_values.include?(opts[:'event_name'])
393
393
  fail ArgumentError, "invalid value for \"event_name\", must be one of #{allowable_values}"
394
394
  end
@@ -432,6 +432,60 @@ module MailSlurpClient
432
432
  return data, status_code, headers
433
433
  end
434
434
 
435
+ # Get webhook test payload for email opened event
436
+ # @param [Hash] opts the optional parameters
437
+ # @return [WebhookEmailOpenedPayload]
438
+ def get_test_webhook_payload_email_opened(opts = {})
439
+ data, _status_code, _headers = get_test_webhook_payload_email_opened_with_http_info(opts)
440
+ data
441
+ end
442
+
443
+ # Get webhook test payload for email opened event
444
+ # @param [Hash] opts the optional parameters
445
+ # @return [Array<(WebhookEmailOpenedPayload, Integer, Hash)>] WebhookEmailOpenedPayload data, response status code and response headers
446
+ def get_test_webhook_payload_email_opened_with_http_info(opts = {})
447
+ if @api_client.config.debugging
448
+ @api_client.config.logger.debug 'Calling API: WebhookControllerApi.get_test_webhook_payload_email_opened ...'
449
+ end
450
+ # resource path
451
+ local_var_path = '/webhooks/test/email-opened-payload'
452
+
453
+ # query parameters
454
+ query_params = opts[:query_params] || {}
455
+
456
+ # header parameters
457
+ header_params = opts[:header_params] || {}
458
+ # HTTP header 'Accept' (if needed)
459
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
460
+
461
+ # form parameters
462
+ form_params = opts[:form_params] || {}
463
+
464
+ # http body (model)
465
+ post_body = opts[:body]
466
+
467
+ # return_type
468
+ return_type = opts[:return_type] || 'WebhookEmailOpenedPayload'
469
+
470
+ # auth_names
471
+ auth_names = opts[:auth_names] || ['API_KEY']
472
+
473
+ new_options = opts.merge(
474
+ :header_params => header_params,
475
+ :query_params => query_params,
476
+ :form_params => form_params,
477
+ :body => post_body,
478
+ :auth_names => auth_names,
479
+ :return_type => return_type
480
+ )
481
+
482
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
483
+ if @api_client.config.debugging
484
+ @api_client.config.logger.debug "API called: WebhookControllerApi#get_test_webhook_payload_email_opened\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
485
+ end
486
+ return data, status_code, headers
487
+ end
488
+
435
489
  # Get webhook test payload for new attachment event
436
490
  # @param [Hash] opts the optional parameters
437
491
  # @return [WebhookNewAttachmentPayload]
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.3.1
13
13
  require 'date'
14
14
 
15
15
  module MailSlurpClient
16
- # Abstract webhook payload. Use the correct payload type for your webhook event type in order to access all the specific properties for that event. See the `NEW_EMAIL`,`NEW_CONTACT` and `NEW_ATTACHMENT` payloads for the properties available for those events.
16
+ # Abstract webhook payload. Use the correct payload type for your webhook event type in order to access all the specific properties for that event. See the `NEW_EMAIL`,`NEW_CONTACT`, `NEW_ATTACHMENT` and `EMAIL_OPENED` payloads for the properties available for those events.
17
17
  class AbstractWebhookPayload
18
18
  attr_accessor :event_name
19
19
 
@@ -126,7 +126,7 @@ module MailSlurpClient
126
126
  # @return true if the model is valid
127
127
  def valid?
128
128
  return false if @event_name.nil?
129
- event_name_validator = EnumAttributeValidator.new('String', ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT"])
129
+ event_name_validator = EnumAttributeValidator.new('String', ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT", "EMAIL_OPENED"])
130
130
  return false unless event_name_validator.valid?(@event_name)
131
131
  return false if @message_id.nil?
132
132
  return false if @webhook_id.nil?
@@ -136,7 +136,7 @@ module MailSlurpClient
136
136
  # Custom attribute writer method checking allowed values (enum).
137
137
  # @param [Object] event_name Object to be assigned
138
138
  def event_name=(event_name)
139
- validator = EnumAttributeValidator.new('String', ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT"])
139
+ validator = EnumAttributeValidator.new('String', ["EMAIL_RECEIVED", "NEW_EMAIL", "NEW_CONTACT", "NEW_ATTACHMENT", "EMAIL_OPENED"])
140
140
  unless validator.valid?(event_name)
141
141
  fail ArgumentError, "invalid value for \"event_name\", must be one of #{validator.allowable_values}."
142
142
  end
@@ -0,0 +1,275 @@
1
+ =begin
2
+ #MailSlurp API
3
+
4
+ #MailSlurp is an API for sending and receiving emails from dynamically allocated email addresses. It's designed for developers and QA teams to test applications, process inbound emails, send templated notifications, attachments, and more. ## Resources - [Homepage](https://www.mailslurp.com) - Get an [API KEY](https://app.mailslurp.com/sign-up/) - Generated [SDK Clients](https://www.mailslurp.com/docs/) - [Examples](https://github.com/mailslurp/examples) repository
5
+
6
+ The version of the OpenAPI document: 6.5.2
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module MailSlurpClient
16
+ class CreateInboxForwarderOptions
17
+ attr_accessor :field
18
+
19
+ attr_accessor :match
20
+
21
+ attr_accessor :forward_to_recipients
22
+
23
+ class EnumAttributeValidator
24
+ attr_reader :datatype
25
+ attr_reader :allowable_values
26
+
27
+ def initialize(datatype, allowable_values)
28
+ @allowable_values = allowable_values.map do |value|
29
+ case datatype.to_s
30
+ when /Integer/i
31
+ value.to_i
32
+ when /Float/i
33
+ value.to_f
34
+ else
35
+ value
36
+ end
37
+ end
38
+ end
39
+
40
+ def valid?(value)
41
+ !value || allowable_values.include?(value)
42
+ end
43
+ end
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'field' => :'field',
49
+ :'match' => :'match',
50
+ :'forward_to_recipients' => :'forwardToRecipients'
51
+ }
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.openapi_types
56
+ {
57
+ :'field' => :'String',
58
+ :'match' => :'String',
59
+ :'forward_to_recipients' => :'Array<String>'
60
+ }
61
+ end
62
+
63
+ # List of attributes with nullable: true
64
+ def self.openapi_nullable
65
+ Set.new([
66
+ ])
67
+ end
68
+
69
+ # Initializes the object
70
+ # @param [Hash] attributes Model attributes in the form of hash
71
+ def initialize(attributes = {})
72
+ if (!attributes.is_a?(Hash))
73
+ fail ArgumentError, "The input argument (attributes) must be a hash in `MailSlurpClient::CreateInboxForwarderOptions` initialize method"
74
+ end
75
+
76
+ # check to see if the attribute exists and convert string to symbol for hash key
77
+ attributes = attributes.each_with_object({}) { |(k, v), h|
78
+ if (!self.class.attribute_map.key?(k.to_sym))
79
+ fail ArgumentError, "`#{k}` is not a valid attribute in `MailSlurpClient::CreateInboxForwarderOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
80
+ end
81
+ h[k.to_sym] = v
82
+ }
83
+
84
+ if attributes.key?(:'field')
85
+ self.field = attributes[:'field']
86
+ end
87
+
88
+ if attributes.key?(:'match')
89
+ self.match = attributes[:'match']
90
+ end
91
+
92
+ if attributes.key?(:'forward_to_recipients')
93
+ if (value = attributes[:'forward_to_recipients']).is_a?(Array)
94
+ self.forward_to_recipients = value
95
+ end
96
+ end
97
+ end
98
+
99
+ # Show invalid properties with the reasons. Usually used together with valid?
100
+ # @return Array for valid properties with the reasons
101
+ def list_invalid_properties
102
+ invalid_properties = Array.new
103
+ if @field.nil?
104
+ invalid_properties.push('invalid value for "field", field cannot be nil.')
105
+ end
106
+
107
+ if @match.nil?
108
+ invalid_properties.push('invalid value for "match", match cannot be nil.')
109
+ end
110
+
111
+ if @forward_to_recipients.nil?
112
+ invalid_properties.push('invalid value for "forward_to_recipients", forward_to_recipients cannot be nil.')
113
+ end
114
+
115
+ invalid_properties
116
+ end
117
+
118
+ # Check to see if the all the properties in the model are valid
119
+ # @return true if the model is valid
120
+ def valid?
121
+ return false if @field.nil?
122
+ field_validator = EnumAttributeValidator.new('String', ["RECIPIENTS", "SENDER", "SUBJECT", "ATTACHMENTS"])
123
+ return false unless field_validator.valid?(@field)
124
+ return false if @match.nil?
125
+ return false if @forward_to_recipients.nil?
126
+ true
127
+ end
128
+
129
+ # Custom attribute writer method checking allowed values (enum).
130
+ # @param [Object] field Object to be assigned
131
+ def field=(field)
132
+ validator = EnumAttributeValidator.new('String', ["RECIPIENTS", "SENDER", "SUBJECT", "ATTACHMENTS"])
133
+ unless validator.valid?(field)
134
+ fail ArgumentError, "invalid value for \"field\", must be one of #{validator.allowable_values}."
135
+ end
136
+ @field = field
137
+ end
138
+
139
+ # Checks equality by comparing each attribute.
140
+ # @param [Object] Object to be compared
141
+ def ==(o)
142
+ return true if self.equal?(o)
143
+ self.class == o.class &&
144
+ field == o.field &&
145
+ match == o.match &&
146
+ forward_to_recipients == o.forward_to_recipients
147
+ end
148
+
149
+ # @see the `==` method
150
+ # @param [Object] Object to be compared
151
+ def eql?(o)
152
+ self == o
153
+ end
154
+
155
+ # Calculates hash code according to all attributes.
156
+ # @return [Integer] Hash code
157
+ def hash
158
+ [field, match, forward_to_recipients].hash
159
+ end
160
+
161
+ # Builds the object from hash
162
+ # @param [Hash] attributes Model attributes in the form of hash
163
+ # @return [Object] Returns the model itself
164
+ def self.build_from_hash(attributes)
165
+ new.build_from_hash(attributes)
166
+ end
167
+
168
+ # Builds the object from hash
169
+ # @param [Hash] attributes Model attributes in the form of hash
170
+ # @return [Object] Returns the model itself
171
+ def build_from_hash(attributes)
172
+ return nil unless attributes.is_a?(Hash)
173
+ self.class.openapi_types.each_pair do |key, type|
174
+ if type =~ /\AArray<(.*)>/i
175
+ # check to ensure the input is an array given that the attribute
176
+ # is documented as an array but the input is not
177
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
178
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
179
+ end
180
+ elsif !attributes[self.class.attribute_map[key]].nil?
181
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
182
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
183
+ end
184
+
185
+ self
186
+ end
187
+
188
+ # Deserializes the data based on type
189
+ # @param string type Data type
190
+ # @param string value Value to be deserialized
191
+ # @return [Object] Deserialized data
192
+ def _deserialize(type, value)
193
+ case type.to_sym
194
+ when :DateTime
195
+ DateTime.parse(value)
196
+ when :Date
197
+ Date.parse(value)
198
+ when :String
199
+ value.to_s
200
+ when :Integer
201
+ value.to_i
202
+ when :Float
203
+ value.to_f
204
+ when :Boolean
205
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
206
+ true
207
+ else
208
+ false
209
+ end
210
+ when :Object
211
+ # generic object (usually a Hash), return directly
212
+ value
213
+ when /\AArray<(?<inner_type>.+)>\z/
214
+ inner_type = Regexp.last_match[:inner_type]
215
+ value.map { |v| _deserialize(inner_type, v) }
216
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
217
+ k_type = Regexp.last_match[:k_type]
218
+ v_type = Regexp.last_match[:v_type]
219
+ {}.tap do |hash|
220
+ value.each do |k, v|
221
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
222
+ end
223
+ end
224
+ else # model
225
+ MailSlurpClient.const_get(type).build_from_hash(value)
226
+ end
227
+ end
228
+
229
+ # Returns the string representation of the object
230
+ # @return [String] String presentation of the object
231
+ def to_s
232
+ to_hash.to_s
233
+ end
234
+
235
+ # to_body is an alias to to_hash (backward compatibility)
236
+ # @return [Hash] Returns the object in the form of hash
237
+ def to_body
238
+ to_hash
239
+ end
240
+
241
+ # Returns the object in the form of hash
242
+ # @return [Hash] Returns the object in the form of hash
243
+ def to_hash
244
+ hash = {}
245
+ self.class.attribute_map.each_pair do |attr, param|
246
+ value = self.send(attr)
247
+ if value.nil?
248
+ is_nullable = self.class.openapi_nullable.include?(attr)
249
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
250
+ end
251
+
252
+ hash[param] = _to_hash(value)
253
+ end
254
+ hash
255
+ end
256
+
257
+ # Outputs non-array value in the form of hash
258
+ # For object, use to_hash. Otherwise, just return the value
259
+ # @param [Object] value Any valid value
260
+ # @return [Hash] Returns the value in the form of hash
261
+ def _to_hash(value)
262
+ if value.is_a?(Array)
263
+ value.compact.map { |v| _to_hash(v) }
264
+ elsif value.is_a?(Hash)
265
+ {}.tap do |hash|
266
+ value.each { |k, v| hash[k] = _to_hash(v) }
267
+ end
268
+ elsif value.respond_to? :to_hash
269
+ value.to_hash
270
+ else
271
+ value
272
+ end
273
+ end
274
+ end
275
+ end