mailslurp_client 12.4.5 → 12.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mailslurp_client.rb +12 -0
  3. data/lib/mailslurp_client/api/contact_controller_api.rb +4 -4
  4. data/lib/mailslurp_client/api/email_controller_api.rb +64 -0
  5. data/lib/mailslurp_client/api/group_controller_api.rb +4 -4
  6. data/lib/mailslurp_client/api/inbox_controller_api.rb +152 -8
  7. data/lib/mailslurp_client/api/inbox_ruleset_controller_api.rb +548 -0
  8. data/lib/mailslurp_client/api/missed_email_controller_api.rb +81 -7
  9. data/lib/mailslurp_client/api/template_controller_api.rb +4 -4
  10. data/lib/mailslurp_client/api/tracking_controller_api.rb +215 -0
  11. data/lib/mailslurp_client/api/wait_for_controller_api.rb +2 -2
  12. data/lib/mailslurp_client/models/create_inbox_ruleset_options.rb +274 -0
  13. data/lib/mailslurp_client/models/create_tracking_pixel_options.rb +215 -0
  14. data/lib/mailslurp_client/models/inbox_ruleset_dto.rb +353 -0
  15. data/lib/mailslurp_client/models/inbox_ruleset_test_options.rb +211 -0
  16. data/lib/mailslurp_client/models/inbox_ruleset_test_result.rb +223 -0
  17. data/lib/mailslurp_client/models/page_inbox_ruleset_dto.rb +299 -0
  18. data/lib/mailslurp_client/models/page_tracking_pixel_projection.rb +299 -0
  19. data/lib/mailslurp_client/models/send_email_options.rb +11 -1
  20. data/lib/mailslurp_client/models/sent_email_dto.rb +12 -1
  21. data/lib/mailslurp_client/models/test_new_inbox_ruleset_options.rb +225 -0
  22. data/lib/mailslurp_client/models/tracking_pixel_dto.rb +262 -0
  23. data/lib/mailslurp_client/models/tracking_pixel_projection.rb +262 -0
  24. data/lib/mailslurp_client/version.rb +1 -1
  25. metadata +14 -2
@@ -21,9 +21,10 @@ module MailSlurpClient
21
21
  end
22
22
  # Get all MissedEmails in paginated format
23
23
  # @param [Hash] opts the optional parameters
24
- # @option opts [Integer] :page Optional page index in inbox list pagination (default to 0)
24
+ # @option opts [String] :inbox_id Optional inbox ID filter
25
+ # @option opts [Integer] :page Optional page index in list pagination (default to 0)
25
26
  # @option opts [String] :search_filter Optional search filter
26
- # @option opts [Integer] :size Optional page size in inbox list pagination (default to 20)
27
+ # @option opts [Integer] :size Optional page size in list pagination (default to 20)
27
28
  # @option opts [String] :sort Optional createdAt sort direction ASC or DESC (default to 'ASC')
28
29
  # @return [PageMissedEmailProjection]
29
30
  def get_all_missed_emails(opts = {})
@@ -33,9 +34,10 @@ module MailSlurpClient
33
34
 
34
35
  # Get all MissedEmails in paginated format
35
36
  # @param [Hash] opts the optional parameters
36
- # @option opts [Integer] :page Optional page index in inbox list pagination
37
+ # @option opts [String] :inbox_id Optional inbox ID filter
38
+ # @option opts [Integer] :page Optional page index in list pagination
37
39
  # @option opts [String] :search_filter Optional search filter
38
- # @option opts [Integer] :size Optional page size in inbox list pagination
40
+ # @option opts [Integer] :size Optional page size in list pagination
39
41
  # @option opts [String] :sort Optional createdAt sort direction ASC or DESC
40
42
  # @return [Array<(PageMissedEmailProjection, Integer, Hash)>] PageMissedEmailProjection data, response status code and response headers
41
43
  def get_all_missed_emails_with_http_info(opts = {})
@@ -51,6 +53,7 @@ module MailSlurpClient
51
53
 
52
54
  # query parameters
53
55
  query_params = opts[:query_params] || {}
56
+ query_params[:'inboxId'] = opts[:'inbox_id'] if !opts[:'inbox_id'].nil?
54
57
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
55
58
  query_params[:'searchFilter'] = opts[:'search_filter'] if !opts[:'search_filter'].nil?
56
59
  query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
@@ -90,7 +93,7 @@ module MailSlurpClient
90
93
  end
91
94
 
92
95
  # Get MissedEmail
93
- # @param missed_email_id [String] MissedEmailId
96
+ # @param missed_email_id [String] missedEmailId
94
97
  # @param [Hash] opts the optional parameters
95
98
  # @return [MissedEmail]
96
99
  def get_missed_email(missed_email_id, opts = {})
@@ -99,7 +102,7 @@ module MailSlurpClient
99
102
  end
100
103
 
101
104
  # Get MissedEmail
102
- # @param missed_email_id [String] MissedEmailId
105
+ # @param missed_email_id [String] missedEmailId
103
106
  # @param [Hash] opts the optional parameters
104
107
  # @return [Array<(MissedEmail, Integer, Hash)>] MissedEmail data, response status code and response headers
105
108
  def get_missed_email_with_http_info(missed_email_id, opts = {})
@@ -111,7 +114,7 @@ module MailSlurpClient
111
114
  fail ArgumentError, "Missing the required parameter 'missed_email_id' when calling MissedEmailControllerApi.get_missed_email"
112
115
  end
113
116
  # resource path
114
- local_var_path = '/missed-emails/{MissedEmailId}'.sub('{' + 'MissedEmailId' + '}', CGI.escape(missed_email_id.to_s))
117
+ local_var_path = '/missed-emails/{missedEmailId}'.sub('{' + 'missedEmailId' + '}', CGI.escape(missed_email_id.to_s))
115
118
 
116
119
  # query parameters
117
120
  query_params = opts[:query_params] || {}
@@ -148,5 +151,76 @@ module MailSlurpClient
148
151
  end
149
152
  return data, status_code, headers
150
153
  end
154
+
155
+ # Wait for Nth missed email
156
+ # Wait for 0 based index missed email
157
+ # @param inbox_id [String] Optional inbox ID filter
158
+ # @param timeout [Integer] Optional timeout milliseconds
159
+ # @param [Hash] opts the optional parameters
160
+ # @option opts [Integer] :index Zero based index of the email to wait for. If 1 missed email already and you want to wait for the 2nd email pass index&#x3D;1
161
+ # @return [MissedEmail]
162
+ def wait_for_nth_missed_email(inbox_id, timeout, opts = {})
163
+ data, _status_code, _headers = wait_for_nth_missed_email_with_http_info(inbox_id, timeout, opts)
164
+ data
165
+ end
166
+
167
+ # Wait for Nth missed email
168
+ # Wait for 0 based index missed email
169
+ # @param inbox_id [String] Optional inbox ID filter
170
+ # @param timeout [Integer] Optional timeout milliseconds
171
+ # @param [Hash] opts the optional parameters
172
+ # @option opts [Integer] :index Zero based index of the email to wait for. If 1 missed email already and you want to wait for the 2nd email pass index&#x3D;1
173
+ # @return [Array<(MissedEmail, Integer, Hash)>] MissedEmail data, response status code and response headers
174
+ def wait_for_nth_missed_email_with_http_info(inbox_id, timeout, opts = {})
175
+ if @api_client.config.debugging
176
+ @api_client.config.logger.debug 'Calling API: MissedEmailControllerApi.wait_for_nth_missed_email ...'
177
+ end
178
+ # verify the required parameter 'inbox_id' is set
179
+ if @api_client.config.client_side_validation && inbox_id.nil?
180
+ fail ArgumentError, "Missing the required parameter 'inbox_id' when calling MissedEmailControllerApi.wait_for_nth_missed_email"
181
+ end
182
+ # verify the required parameter 'timeout' is set
183
+ if @api_client.config.client_side_validation && timeout.nil?
184
+ fail ArgumentError, "Missing the required parameter 'timeout' when calling MissedEmailControllerApi.wait_for_nth_missed_email"
185
+ end
186
+ # resource path
187
+ local_var_path = '/missed-emails/waitForNthMissedEmail'.sub('{' + 'inboxId' + '}', CGI.escape(inbox_id.to_s)).sub('{' + 'timeout' + '}', CGI.escape(timeout.to_s))
188
+
189
+ # query parameters
190
+ query_params = opts[:query_params] || {}
191
+ query_params[:'index'] = opts[:'index'] if !opts[:'index'].nil?
192
+
193
+ # header parameters
194
+ header_params = opts[:header_params] || {}
195
+ # HTTP header 'Accept' (if needed)
196
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
197
+
198
+ # form parameters
199
+ form_params = opts[:form_params] || {}
200
+
201
+ # http body (model)
202
+ post_body = opts[:body]
203
+
204
+ # return_type
205
+ return_type = opts[:return_type] || 'MissedEmail'
206
+
207
+ # auth_names
208
+ auth_names = opts[:auth_names] || ['API_KEY']
209
+
210
+ new_options = opts.merge(
211
+ :header_params => header_params,
212
+ :query_params => query_params,
213
+ :form_params => form_params,
214
+ :body => post_body,
215
+ :auth_names => auth_names,
216
+ :return_type => return_type
217
+ )
218
+
219
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
220
+ if @api_client.config.debugging
221
+ @api_client.config.logger.debug "API called: MissedEmailControllerApi#wait_for_nth_missed_email\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
222
+ end
223
+ return data, status_code, headers
224
+ end
151
225
  end
152
226
  end
@@ -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,215 @@
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
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
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 [Integer] :size Optional page size in list pagination (default to 20)
91
+ # @option opts [String] :sort Optional createdAt sort direction ASC or DESC (default to 'ASC')
92
+ # @return [PageTrackingPixelProjection]
93
+ def get_all_tracking_pixels(opts = {})
94
+ data, _status_code, _headers = get_all_tracking_pixels_with_http_info(opts)
95
+ data
96
+ end
97
+
98
+ # Get tracking pixels
99
+ # List tracking pixels in paginated form
100
+ # @param [Hash] opts the optional parameters
101
+ # @option opts [Integer] :page Optional page index in list pagination
102
+ # @option opts [Integer] :size Optional page size in list pagination
103
+ # @option opts [String] :sort Optional createdAt sort direction ASC or DESC
104
+ # @return [Array<(PageTrackingPixelProjection, Integer, Hash)>] PageTrackingPixelProjection data, response status code and response headers
105
+ def get_all_tracking_pixels_with_http_info(opts = {})
106
+ if @api_client.config.debugging
107
+ @api_client.config.logger.debug 'Calling API: TrackingControllerApi.get_all_tracking_pixels ...'
108
+ end
109
+ allowable_values = ["ASC", "DESC"]
110
+ if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
111
+ fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
112
+ end
113
+ # resource path
114
+ local_var_path = '/tracking/pixels'
115
+
116
+ # query parameters
117
+ query_params = opts[:query_params] || {}
118
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
119
+ query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?
120
+ query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
121
+
122
+ # header parameters
123
+ header_params = opts[:header_params] || {}
124
+ # HTTP header 'Accept' (if needed)
125
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
126
+
127
+ # form parameters
128
+ form_params = opts[:form_params] || {}
129
+
130
+ # http body (model)
131
+ post_body = opts[:body]
132
+
133
+ # return_type
134
+ return_type = opts[:return_type] || 'PageTrackingPixelProjection'
135
+
136
+ # auth_names
137
+ auth_names = opts[:auth_names] || ['API_KEY']
138
+
139
+ new_options = opts.merge(
140
+ :header_params => header_params,
141
+ :query_params => query_params,
142
+ :form_params => form_params,
143
+ :body => post_body,
144
+ :auth_names => auth_names,
145
+ :return_type => return_type
146
+ )
147
+
148
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
149
+ if @api_client.config.debugging
150
+ @api_client.config.logger.debug "API called: TrackingControllerApi#get_all_tracking_pixels\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
151
+ end
152
+ return data, status_code, headers
153
+ end
154
+
155
+ # Get pixel
156
+ # @param id [String] id
157
+ # @param [Hash] opts the optional parameters
158
+ # @return [TrackingPixelDto]
159
+ def get_tracking_pixel(id, opts = {})
160
+ data, _status_code, _headers = get_tracking_pixel_with_http_info(id, opts)
161
+ data
162
+ end
163
+
164
+ # Get pixel
165
+ # @param id [String] id
166
+ # @param [Hash] opts the optional parameters
167
+ # @return [Array<(TrackingPixelDto, Integer, Hash)>] TrackingPixelDto data, response status code and response headers
168
+ def get_tracking_pixel_with_http_info(id, opts = {})
169
+ if @api_client.config.debugging
170
+ @api_client.config.logger.debug 'Calling API: TrackingControllerApi.get_tracking_pixel ...'
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 TrackingControllerApi.get_tracking_pixel"
175
+ end
176
+ # resource path
177
+ local_var_path = '/tracking/pixels/{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] || 'TrackingPixelDto'
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: TrackingControllerApi#get_tracking_pixel\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
211
+ end
212
+ return data, status_code, headers
213
+ end
214
+ end
215
+ 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
@@ -0,0 +1,274 @@
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 creating inbox rulesets. Inbox rulesets can be used to block, allow, filter, or forward emails when sending or receiving using the inbox.
17
+ class CreateInboxRulesetOptions
18
+ # Action to be taken when the ruleset matches an email for the given scope. For example: `BLOCK` action with target `*` and scope `SENDING_EMAILS` blocks sending to all recipients. Note `ALLOW` takes precedent over `BLOCK`. `FILTER_REMOVE` is like block but will remove offending email addresses during a send or receive event instead of blocking the action.
19
+ attr_accessor :action
20
+
21
+ # What type of emails actions to apply ruleset to. Either `SENDING_EMAILS` or `RECEIVING_EMAILS` will apply action and target to any sending or receiving of emails respectively.
22
+ attr_accessor :scope
23
+
24
+ # Target to match emails with. Can be a wild-card type pattern or a valid email address. For instance `*@gmail.com` matches all gmail addresses while `test@gmail.com` matches one address exactly. The target is applied to every recipient field email address when `SENDING_EMAILS` is the scope and is applied to sender of email when `RECEIVING_EMAILS`.
25
+ attr_accessor :target
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
+ :'action' => :'action',
53
+ :'scope' => :'scope',
54
+ :'target' => :'target'
55
+ }
56
+ end
57
+
58
+ # Attribute type mapping.
59
+ def self.openapi_types
60
+ {
61
+ :'action' => :'String',
62
+ :'scope' => :'String',
63
+ :'target' => :'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::CreateInboxRulesetOptions` 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::CreateInboxRulesetOptions`. 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?(:'action')
89
+ self.action = attributes[:'action']
90
+ end
91
+
92
+ if attributes.key?(:'scope')
93
+ self.scope = attributes[:'scope']
94
+ end
95
+
96
+ if attributes.key?(:'target')
97
+ self.target = attributes[:'target']
98
+ end
99
+ end
100
+
101
+ # Show invalid properties with the reasons. Usually used together with valid?
102
+ # @return Array for valid properties with the reasons
103
+ def list_invalid_properties
104
+ invalid_properties = Array.new
105
+ invalid_properties
106
+ end
107
+
108
+ # Check to see if the all the properties in the model are valid
109
+ # @return true if the model is valid
110
+ def valid?
111
+ action_validator = EnumAttributeValidator.new('String', ["BLOCK", "ALLOW", "FILTER_REMOVE"])
112
+ return false unless action_validator.valid?(@action)
113
+ scope_validator = EnumAttributeValidator.new('String', ["RECEIVING_EMAILS", "SENDING_EMAILS"])
114
+ return false unless scope_validator.valid?(@scope)
115
+ true
116
+ end
117
+
118
+ # Custom attribute writer method checking allowed values (enum).
119
+ # @param [Object] action Object to be assigned
120
+ def action=(action)
121
+ validator = EnumAttributeValidator.new('String', ["BLOCK", "ALLOW", "FILTER_REMOVE"])
122
+ unless validator.valid?(action)
123
+ fail ArgumentError, "invalid value for \"action\", must be one of #{validator.allowable_values}."
124
+ end
125
+ @action = action
126
+ end
127
+
128
+ # Custom attribute writer method checking allowed values (enum).
129
+ # @param [Object] scope Object to be assigned
130
+ def scope=(scope)
131
+ validator = EnumAttributeValidator.new('String', ["RECEIVING_EMAILS", "SENDING_EMAILS"])
132
+ unless validator.valid?(scope)
133
+ fail ArgumentError, "invalid value for \"scope\", must be one of #{validator.allowable_values}."
134
+ end
135
+ @scope = scope
136
+ end
137
+
138
+ # Checks equality by comparing each attribute.
139
+ # @param [Object] Object to be compared
140
+ def ==(o)
141
+ return true if self.equal?(o)
142
+ self.class == o.class &&
143
+ action == o.action &&
144
+ scope == o.scope &&
145
+ target == o.target
146
+ end
147
+
148
+ # @see the `==` method
149
+ # @param [Object] Object to be compared
150
+ def eql?(o)
151
+ self == o
152
+ end
153
+
154
+ # Calculates hash code according to all attributes.
155
+ # @return [Integer] Hash code
156
+ def hash
157
+ [action, scope, target].hash
158
+ end
159
+
160
+ # Builds the object from hash
161
+ # @param [Hash] attributes Model attributes in the form of hash
162
+ # @return [Object] Returns the model itself
163
+ def self.build_from_hash(attributes)
164
+ new.build_from_hash(attributes)
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 build_from_hash(attributes)
171
+ return nil unless attributes.is_a?(Hash)
172
+ self.class.openapi_types.each_pair do |key, type|
173
+ if type =~ /\AArray<(.*)>/i
174
+ # check to ensure the input is an array given that the attribute
175
+ # is documented as an array but the input is not
176
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
177
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
178
+ end
179
+ elsif !attributes[self.class.attribute_map[key]].nil?
180
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
181
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
182
+ end
183
+
184
+ self
185
+ end
186
+
187
+ # Deserializes the data based on type
188
+ # @param string type Data type
189
+ # @param string value Value to be deserialized
190
+ # @return [Object] Deserialized data
191
+ def _deserialize(type, value)
192
+ case type.to_sym
193
+ when :DateTime
194
+ DateTime.parse(value)
195
+ when :Date
196
+ Date.parse(value)
197
+ when :String
198
+ value.to_s
199
+ when :Integer
200
+ value.to_i
201
+ when :Float
202
+ value.to_f
203
+ when :Boolean
204
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
205
+ true
206
+ else
207
+ false
208
+ end
209
+ when :Object
210
+ # generic object (usually a Hash), return directly
211
+ value
212
+ when /\AArray<(?<inner_type>.+)>\z/
213
+ inner_type = Regexp.last_match[:inner_type]
214
+ value.map { |v| _deserialize(inner_type, v) }
215
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
216
+ k_type = Regexp.last_match[:k_type]
217
+ v_type = Regexp.last_match[:v_type]
218
+ {}.tap do |hash|
219
+ value.each do |k, v|
220
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
221
+ end
222
+ end
223
+ else # model
224
+ MailSlurpClient.const_get(type).build_from_hash(value)
225
+ end
226
+ end
227
+
228
+ # Returns the string representation of the object
229
+ # @return [String] String presentation of the object
230
+ def to_s
231
+ to_hash.to_s
232
+ end
233
+
234
+ # to_body is an alias to to_hash (backward compatibility)
235
+ # @return [Hash] Returns the object in the form of hash
236
+ def to_body
237
+ to_hash
238
+ end
239
+
240
+ # Returns the object in the form of hash
241
+ # @return [Hash] Returns the object in the form of hash
242
+ def to_hash
243
+ hash = {}
244
+ self.class.attribute_map.each_pair do |attr, param|
245
+ value = self.send(attr)
246
+ if value.nil?
247
+ is_nullable = self.class.openapi_nullable.include?(attr)
248
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
249
+ end
250
+
251
+ hash[param] = _to_hash(value)
252
+ end
253
+ hash
254
+ end
255
+
256
+ # Outputs non-array value in the form of hash
257
+ # For object, use to_hash. Otherwise, just return the value
258
+ # @param [Object] value Any valid value
259
+ # @return [Hash] Returns the value in the form of hash
260
+ def _to_hash(value)
261
+ if value.is_a?(Array)
262
+ value.compact.map { |v| _to_hash(v) }
263
+ elsif value.is_a?(Hash)
264
+ {}.tap do |hash|
265
+ value.each { |k, v| hash[k] = _to_hash(v) }
266
+ end
267
+ elsif value.respond_to? :to_hash
268
+ value.to_hash
269
+ else
270
+ value
271
+ end
272
+ end
273
+ end
274
+ end