sendmux-sending 1.0.0

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.
Files changed (30) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +12 -0
  3. data/README.md +3 -0
  4. data/lib/sendmux/sending/client.rb +34 -0
  5. data/lib/sendmux/sending/version.rb +7 -0
  6. data/lib/sendmux/sending.rb +12 -0
  7. data/lib/sendmux_sending_generated/api/emails_api.rb +190 -0
  8. data/lib/sendmux_sending_generated/api_client.rb +441 -0
  9. data/lib/sendmux_sending_generated/api_error.rb +58 -0
  10. data/lib/sendmux_sending_generated/api_model_base.rb +88 -0
  11. data/lib/sendmux_sending_generated/configuration.rb +392 -0
  12. data/lib/sendmux_sending_generated/models/address.rb +215 -0
  13. data/lib/sendmux_sending_generated/models/attachment.rb +274 -0
  14. data/lib/sendmux_sending_generated/models/batch_result_item.rb +256 -0
  15. data/lib/sendmux_sending_generated/models/batch_send_request.rb +185 -0
  16. data/lib/sendmux_sending_generated/models/batch_send_success_data.rb +192 -0
  17. data/lib/sendmux_sending_generated/models/batch_send_success_response.rb +223 -0
  18. data/lib/sendmux_sending_generated/models/batch_summary.rb +219 -0
  19. data/lib/sendmux_sending_generated/models/email_send_request.rb +465 -0
  20. data/lib/sendmux_sending_generated/models/error_detail.rb +251 -0
  21. data/lib/sendmux_sending_generated/models/error_issue.rb +219 -0
  22. data/lib/sendmux_sending_generated/models/error_response.rb +216 -0
  23. data/lib/sendmux_sending_generated/models/meta.rb +165 -0
  24. data/lib/sendmux_sending_generated/models/recipient.rb +214 -0
  25. data/lib/sendmux_sending_generated/models/send_success_data.rb +227 -0
  26. data/lib/sendmux_sending_generated/models/send_success_response.rb +223 -0
  27. data/lib/sendmux_sending_generated/models/success_envelope.rb +190 -0
  28. data/lib/sendmux_sending_generated/version.rb +15 -0
  29. data/lib/sendmux_sending_generated.rb +57 -0
  30. metadata +146 -0
@@ -0,0 +1,465 @@
1
+ =begin
2
+ #SendMux Sending API
3
+
4
+ #Send emails programmatically via the SendMux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.22.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Sendmux::Sending::Generated
17
+ class EmailSendRequest < ApiModelBase
18
+ # File attachments (max 10)
19
+ attr_accessor :attachments
20
+
21
+ # BCC recipients (max 100)
22
+ attr_accessor :bcc
23
+
24
+ # CC recipients (max 100)
25
+ attr_accessor :cc
26
+
27
+ # Custom X-* headers to include in the email
28
+ attr_accessor :custom_headers
29
+
30
+ attr_accessor :from
31
+
32
+ # HTML email content (max 25MB)
33
+ attr_accessor :html_body
34
+
35
+ # Reply-To address
36
+ attr_accessor :reply_to
37
+
38
+ # Envelope sender for VERP support
39
+ attr_accessor :return_path
40
+
41
+ # Email subject line (max 998 chars, RFC 5322)
42
+ attr_accessor :subject
43
+
44
+ # Plain text alternative (max 25MB)
45
+ attr_accessor :text_body
46
+
47
+ # Primary recipient
48
+ attr_accessor :to
49
+
50
+ # Attribute mapping from ruby-style variable name to JSON key.
51
+ def self.attribute_map
52
+ {
53
+ :'attachments' => :'attachments',
54
+ :'bcc' => :'bcc',
55
+ :'cc' => :'cc',
56
+ :'custom_headers' => :'custom_headers',
57
+ :'from' => :'from',
58
+ :'html_body' => :'html_body',
59
+ :'reply_to' => :'reply_to',
60
+ :'return_path' => :'return_path',
61
+ :'subject' => :'subject',
62
+ :'text_body' => :'text_body',
63
+ :'to' => :'to'
64
+ }
65
+ end
66
+
67
+ # Returns attribute mapping this model knows about
68
+ def self.acceptable_attribute_map
69
+ attribute_map
70
+ end
71
+
72
+ # Returns all the JSON keys this model knows about
73
+ def self.acceptable_attributes
74
+ acceptable_attribute_map.values
75
+ end
76
+
77
+ # Attribute type mapping.
78
+ def self.openapi_types
79
+ {
80
+ :'attachments' => :'Array<Attachment>',
81
+ :'bcc' => :'Array<Recipient>',
82
+ :'cc' => :'Array<Recipient>',
83
+ :'custom_headers' => :'Hash<String, String>',
84
+ :'from' => :'Address',
85
+ :'html_body' => :'String',
86
+ :'reply_to' => :'Address',
87
+ :'return_path' => :'String',
88
+ :'subject' => :'String',
89
+ :'text_body' => :'String',
90
+ :'to' => :'Address'
91
+ }
92
+ end
93
+
94
+ # List of attributes with nullable: true
95
+ def self.openapi_nullable
96
+ Set.new([
97
+ ])
98
+ end
99
+
100
+ # Initializes the object
101
+ # @param [Hash] attributes Model attributes in the form of hash
102
+ def initialize(attributes = {})
103
+ if (!attributes.is_a?(Hash))
104
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Sendmux::Sending::Generated::EmailSendRequest` initialize method"
105
+ end
106
+
107
+ # check to see if the attribute exists and convert string to symbol for hash key
108
+ acceptable_attribute_map = self.class.acceptable_attribute_map
109
+ attributes = attributes.each_with_object({}) { |(k, v), h|
110
+ if (!acceptable_attribute_map.key?(k.to_sym))
111
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendmux::Sending::Generated::EmailSendRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
112
+ end
113
+ h[k.to_sym] = v
114
+ }
115
+
116
+ if attributes.key?(:'attachments')
117
+ if (value = attributes[:'attachments']).is_a?(Array)
118
+ self.attachments = value
119
+ end
120
+ end
121
+
122
+ if attributes.key?(:'bcc')
123
+ if (value = attributes[:'bcc']).is_a?(Array)
124
+ self.bcc = value
125
+ end
126
+ end
127
+
128
+ if attributes.key?(:'cc')
129
+ if (value = attributes[:'cc']).is_a?(Array)
130
+ self.cc = value
131
+ end
132
+ end
133
+
134
+ if attributes.key?(:'custom_headers')
135
+ if (value = attributes[:'custom_headers']).is_a?(Hash)
136
+ self.custom_headers = value
137
+ end
138
+ end
139
+
140
+ if attributes.key?(:'from')
141
+ self.from = attributes[:'from']
142
+ else
143
+ self.from = nil
144
+ end
145
+
146
+ if attributes.key?(:'html_body')
147
+ self.html_body = attributes[:'html_body']
148
+ else
149
+ self.html_body = nil
150
+ end
151
+
152
+ if attributes.key?(:'reply_to')
153
+ self.reply_to = attributes[:'reply_to']
154
+ end
155
+
156
+ if attributes.key?(:'return_path')
157
+ self.return_path = attributes[:'return_path']
158
+ end
159
+
160
+ if attributes.key?(:'subject')
161
+ self.subject = attributes[:'subject']
162
+ else
163
+ self.subject = nil
164
+ end
165
+
166
+ if attributes.key?(:'text_body')
167
+ self.text_body = attributes[:'text_body']
168
+ end
169
+
170
+ if attributes.key?(:'to')
171
+ self.to = attributes[:'to']
172
+ else
173
+ self.to = nil
174
+ end
175
+ end
176
+
177
+ # Show invalid properties with the reasons. Usually used together with valid?
178
+ # @return Array for valid properties with the reasons
179
+ def list_invalid_properties
180
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
181
+ invalid_properties = Array.new
182
+ if !@attachments.nil? && @attachments.length > 10
183
+ invalid_properties.push('invalid value for "attachments", number of items must be less than or equal to 10.')
184
+ end
185
+
186
+ if !@bcc.nil? && @bcc.length > 100
187
+ invalid_properties.push('invalid value for "bcc", number of items must be less than or equal to 100.')
188
+ end
189
+
190
+ if !@cc.nil? && @cc.length > 100
191
+ invalid_properties.push('invalid value for "cc", number of items must be less than or equal to 100.')
192
+ end
193
+
194
+ if @from.nil?
195
+ invalid_properties.push('invalid value for "from", from cannot be nil.')
196
+ end
197
+
198
+ if @html_body.nil?
199
+ invalid_properties.push('invalid value for "html_body", html_body cannot be nil.')
200
+ end
201
+
202
+ if @html_body.to_s.length > 26214400
203
+ invalid_properties.push('invalid value for "html_body", the character length must be smaller than or equal to 26214400.')
204
+ end
205
+
206
+ if @html_body.to_s.length < 1
207
+ invalid_properties.push('invalid value for "html_body", the character length must be greater than or equal to 1.')
208
+ end
209
+
210
+ if !@return_path.nil? && @return_path.to_s.length > 254
211
+ invalid_properties.push('invalid value for "return_path", the character length must be smaller than or equal to 254.')
212
+ end
213
+
214
+ if @subject.nil?
215
+ invalid_properties.push('invalid value for "subject", subject cannot be nil.')
216
+ end
217
+
218
+ if @subject.to_s.length > 998
219
+ invalid_properties.push('invalid value for "subject", the character length must be smaller than or equal to 998.')
220
+ end
221
+
222
+ if @subject.to_s.length < 1
223
+ invalid_properties.push('invalid value for "subject", the character length must be greater than or equal to 1.')
224
+ end
225
+
226
+ pattern = Regexp.new(/^[^\r\n]*$/)
227
+ if @subject !~ pattern
228
+ invalid_properties.push("invalid value for \"subject\", must conform to the pattern #{pattern}.")
229
+ end
230
+
231
+ if !@text_body.nil? && @text_body.to_s.length > 26214400
232
+ invalid_properties.push('invalid value for "text_body", the character length must be smaller than or equal to 26214400.')
233
+ end
234
+
235
+ if @to.nil?
236
+ invalid_properties.push('invalid value for "to", to cannot be nil.')
237
+ end
238
+
239
+ invalid_properties
240
+ end
241
+
242
+ # Check to see if the all the properties in the model are valid
243
+ # @return true if the model is valid
244
+ def valid?
245
+ warn '[DEPRECATED] the `valid?` method is obsolete'
246
+ return false if !@attachments.nil? && @attachments.length > 10
247
+ return false if !@bcc.nil? && @bcc.length > 100
248
+ return false if !@cc.nil? && @cc.length > 100
249
+ return false if @from.nil?
250
+ return false if @html_body.nil?
251
+ return false if @html_body.to_s.length > 26214400
252
+ return false if @html_body.to_s.length < 1
253
+ return false if !@return_path.nil? && @return_path.to_s.length > 254
254
+ return false if @subject.nil?
255
+ return false if @subject.to_s.length > 998
256
+ return false if @subject.to_s.length < 1
257
+ return false if @subject !~ Regexp.new(/^[^\r\n]*$/)
258
+ return false if !@text_body.nil? && @text_body.to_s.length > 26214400
259
+ return false if @to.nil?
260
+ true
261
+ end
262
+
263
+ # Custom attribute writer method with validation
264
+ # @param [Object] attachments Value to be assigned
265
+ def attachments=(attachments)
266
+ if attachments.nil?
267
+ fail ArgumentError, 'attachments cannot be nil'
268
+ end
269
+
270
+ if attachments.length > 10
271
+ fail ArgumentError, 'invalid value for "attachments", number of items must be less than or equal to 10.'
272
+ end
273
+
274
+ @attachments = attachments
275
+ end
276
+
277
+ # Custom attribute writer method with validation
278
+ # @param [Object] bcc Value to be assigned
279
+ def bcc=(bcc)
280
+ if bcc.nil?
281
+ fail ArgumentError, 'bcc cannot be nil'
282
+ end
283
+
284
+ if bcc.length > 100
285
+ fail ArgumentError, 'invalid value for "bcc", number of items must be less than or equal to 100.'
286
+ end
287
+
288
+ @bcc = bcc
289
+ end
290
+
291
+ # Custom attribute writer method with validation
292
+ # @param [Object] cc Value to be assigned
293
+ def cc=(cc)
294
+ if cc.nil?
295
+ fail ArgumentError, 'cc cannot be nil'
296
+ end
297
+
298
+ if cc.length > 100
299
+ fail ArgumentError, 'invalid value for "cc", number of items must be less than or equal to 100.'
300
+ end
301
+
302
+ @cc = cc
303
+ end
304
+
305
+ # Custom attribute writer method with validation
306
+ # @param [Object] from Value to be assigned
307
+ def from=(from)
308
+ if from.nil?
309
+ fail ArgumentError, 'from cannot be nil'
310
+ end
311
+
312
+ @from = from
313
+ end
314
+
315
+ # Custom attribute writer method with validation
316
+ # @param [Object] html_body Value to be assigned
317
+ def html_body=(html_body)
318
+ if html_body.nil?
319
+ fail ArgumentError, 'html_body cannot be nil'
320
+ end
321
+
322
+ if html_body.to_s.length > 26214400
323
+ fail ArgumentError, 'invalid value for "html_body", the character length must be smaller than or equal to 26214400.'
324
+ end
325
+
326
+ if html_body.to_s.length < 1
327
+ fail ArgumentError, 'invalid value for "html_body", the character length must be greater than or equal to 1.'
328
+ end
329
+
330
+ @html_body = html_body
331
+ end
332
+
333
+ # Custom attribute writer method with validation
334
+ # @param [Object] return_path Value to be assigned
335
+ def return_path=(return_path)
336
+ if return_path.nil?
337
+ fail ArgumentError, 'return_path cannot be nil'
338
+ end
339
+
340
+ if return_path.to_s.length > 254
341
+ fail ArgumentError, 'invalid value for "return_path", the character length must be smaller than or equal to 254.'
342
+ end
343
+
344
+ @return_path = return_path
345
+ end
346
+
347
+ # Custom attribute writer method with validation
348
+ # @param [Object] subject Value to be assigned
349
+ def subject=(subject)
350
+ if subject.nil?
351
+ fail ArgumentError, 'subject cannot be nil'
352
+ end
353
+
354
+ if subject.to_s.length > 998
355
+ fail ArgumentError, 'invalid value for "subject", the character length must be smaller than or equal to 998.'
356
+ end
357
+
358
+ if subject.to_s.length < 1
359
+ fail ArgumentError, 'invalid value for "subject", the character length must be greater than or equal to 1.'
360
+ end
361
+
362
+ pattern = Regexp.new(/^[^\r\n]*$/)
363
+ if subject !~ pattern
364
+ fail ArgumentError, "invalid value for \"subject\", must conform to the pattern #{pattern}."
365
+ end
366
+
367
+ @subject = subject
368
+ end
369
+
370
+ # Custom attribute writer method with validation
371
+ # @param [Object] text_body Value to be assigned
372
+ def text_body=(text_body)
373
+ if text_body.nil?
374
+ fail ArgumentError, 'text_body cannot be nil'
375
+ end
376
+
377
+ if text_body.to_s.length > 26214400
378
+ fail ArgumentError, 'invalid value for "text_body", the character length must be smaller than or equal to 26214400.'
379
+ end
380
+
381
+ @text_body = text_body
382
+ end
383
+
384
+ # Custom attribute writer method with validation
385
+ # @param [Object] to Value to be assigned
386
+ def to=(to)
387
+ if to.nil?
388
+ fail ArgumentError, 'to cannot be nil'
389
+ end
390
+
391
+ @to = to
392
+ end
393
+
394
+ # Checks equality by comparing each attribute.
395
+ # @param [Object] Object to be compared
396
+ def ==(o)
397
+ return true if self.equal?(o)
398
+ self.class == o.class &&
399
+ attachments == o.attachments &&
400
+ bcc == o.bcc &&
401
+ cc == o.cc &&
402
+ custom_headers == o.custom_headers &&
403
+ from == o.from &&
404
+ html_body == o.html_body &&
405
+ reply_to == o.reply_to &&
406
+ return_path == o.return_path &&
407
+ subject == o.subject &&
408
+ text_body == o.text_body &&
409
+ to == o.to
410
+ end
411
+
412
+ # @see the `==` method
413
+ # @param [Object] Object to be compared
414
+ def eql?(o)
415
+ self == o
416
+ end
417
+
418
+ # Calculates hash code according to all attributes.
419
+ # @return [Integer] Hash code
420
+ def hash
421
+ [attachments, bcc, cc, custom_headers, from, html_body, reply_to, return_path, subject, text_body, to].hash
422
+ end
423
+
424
+ # Builds the object from hash
425
+ # @param [Hash] attributes Model attributes in the form of hash
426
+ # @return [Object] Returns the model itself
427
+ def self.build_from_hash(attributes)
428
+ return nil unless attributes.is_a?(Hash)
429
+ attributes = attributes.transform_keys(&:to_sym)
430
+ transformed_hash = {}
431
+ openapi_types.each_pair do |key, type|
432
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
433
+ transformed_hash["#{key}"] = nil
434
+ elsif type =~ /\AArray<(.*)>/i
435
+ # check to ensure the input is an array given that the attribute
436
+ # is documented as an array but the input is not
437
+ if attributes[attribute_map[key]].is_a?(Array)
438
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
439
+ end
440
+ elsif !attributes[attribute_map[key]].nil?
441
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
442
+ end
443
+ end
444
+ new(transformed_hash)
445
+ end
446
+
447
+ # Returns the object in the form of hash
448
+ # @return [Hash] Returns the object in the form of hash
449
+ def to_hash
450
+ hash = {}
451
+ self.class.attribute_map.each_pair do |attr, param|
452
+ value = self.send(attr)
453
+ if value.nil?
454
+ is_nullable = self.class.openapi_nullable.include?(attr)
455
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
456
+ end
457
+
458
+ hash[param] = _to_hash(value)
459
+ end
460
+ hash
461
+ end
462
+
463
+ end
464
+
465
+ end
@@ -0,0 +1,251 @@
1
+ =begin
2
+ #SendMux Sending API
3
+
4
+ #Send emails programmatically via the SendMux email infrastructure. Every response carries an `X-Request-Id` header; errors include a `retryable` flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept an `Idempotency-Key` header for safe retries.
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.22.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Sendmux::Sending::Generated
17
+ class ErrorDetail < ApiModelBase
18
+ # Machine-readable error code
19
+ attr_accessor :code
20
+
21
+ # Link to error documentation
22
+ attr_accessor :doc_url
23
+
24
+ # Accumulated per-field issues (validation errors)
25
+ attr_accessor :errors
26
+
27
+ # Human-readable error description
28
+ attr_accessor :message
29
+
30
+ # Parameter that caused the error
31
+ attr_accessor :param
32
+
33
+ # True when the client may safely retry the same request. 429 and 5xx default true; 4xx default false.
34
+ attr_accessor :retryable
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'code' => :'code',
40
+ :'doc_url' => :'doc_url',
41
+ :'errors' => :'errors',
42
+ :'message' => :'message',
43
+ :'param' => :'param',
44
+ :'retryable' => :'retryable'
45
+ }
46
+ end
47
+
48
+ # Returns attribute mapping this model knows about
49
+ def self.acceptable_attribute_map
50
+ attribute_map
51
+ end
52
+
53
+ # Returns all the JSON keys this model knows about
54
+ def self.acceptable_attributes
55
+ acceptable_attribute_map.values
56
+ end
57
+
58
+ # Attribute type mapping.
59
+ def self.openapi_types
60
+ {
61
+ :'code' => :'String',
62
+ :'doc_url' => :'String',
63
+ :'errors' => :'Array<ErrorIssue>',
64
+ :'message' => :'String',
65
+ :'param' => :'String',
66
+ :'retryable' => :'Boolean'
67
+ }
68
+ end
69
+
70
+ # List of attributes with nullable: true
71
+ def self.openapi_nullable
72
+ Set.new([
73
+ ])
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Sendmux::Sending::Generated::ErrorDetail` initialize method"
81
+ end
82
+
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ acceptable_attribute_map = self.class.acceptable_attribute_map
85
+ attributes = attributes.each_with_object({}) { |(k, v), h|
86
+ if (!acceptable_attribute_map.key?(k.to_sym))
87
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendmux::Sending::Generated::ErrorDetail`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
88
+ end
89
+ h[k.to_sym] = v
90
+ }
91
+
92
+ if attributes.key?(:'code')
93
+ self.code = attributes[:'code']
94
+ else
95
+ self.code = nil
96
+ end
97
+
98
+ if attributes.key?(:'doc_url')
99
+ self.doc_url = attributes[:'doc_url']
100
+ end
101
+
102
+ if attributes.key?(:'errors')
103
+ if (value = attributes[:'errors']).is_a?(Array)
104
+ self.errors = value
105
+ end
106
+ end
107
+
108
+ if attributes.key?(:'message')
109
+ self.message = attributes[:'message']
110
+ else
111
+ self.message = nil
112
+ end
113
+
114
+ if attributes.key?(:'param')
115
+ self.param = attributes[:'param']
116
+ end
117
+
118
+ if attributes.key?(:'retryable')
119
+ self.retryable = attributes[:'retryable']
120
+ else
121
+ self.retryable = nil
122
+ end
123
+ end
124
+
125
+ # Show invalid properties with the reasons. Usually used together with valid?
126
+ # @return Array for valid properties with the reasons
127
+ def list_invalid_properties
128
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
129
+ invalid_properties = Array.new
130
+ if @code.nil?
131
+ invalid_properties.push('invalid value for "code", code cannot be nil.')
132
+ end
133
+
134
+ if @message.nil?
135
+ invalid_properties.push('invalid value for "message", message cannot be nil.')
136
+ end
137
+
138
+ if @retryable.nil?
139
+ invalid_properties.push('invalid value for "retryable", retryable cannot be nil.')
140
+ end
141
+
142
+ invalid_properties
143
+ end
144
+
145
+ # Check to see if the all the properties in the model are valid
146
+ # @return true if the model is valid
147
+ def valid?
148
+ warn '[DEPRECATED] the `valid?` method is obsolete'
149
+ return false if @code.nil?
150
+ return false if @message.nil?
151
+ return false if @retryable.nil?
152
+ true
153
+ end
154
+
155
+ # Custom attribute writer method with validation
156
+ # @param [Object] code Value to be assigned
157
+ def code=(code)
158
+ if code.nil?
159
+ fail ArgumentError, 'code cannot be nil'
160
+ end
161
+
162
+ @code = code
163
+ end
164
+
165
+ # Custom attribute writer method with validation
166
+ # @param [Object] message Value to be assigned
167
+ def message=(message)
168
+ if message.nil?
169
+ fail ArgumentError, 'message cannot be nil'
170
+ end
171
+
172
+ @message = message
173
+ end
174
+
175
+ # Custom attribute writer method with validation
176
+ # @param [Object] retryable Value to be assigned
177
+ def retryable=(retryable)
178
+ if retryable.nil?
179
+ fail ArgumentError, 'retryable cannot be nil'
180
+ end
181
+
182
+ @retryable = retryable
183
+ end
184
+
185
+ # Checks equality by comparing each attribute.
186
+ # @param [Object] Object to be compared
187
+ def ==(o)
188
+ return true if self.equal?(o)
189
+ self.class == o.class &&
190
+ code == o.code &&
191
+ doc_url == o.doc_url &&
192
+ errors == o.errors &&
193
+ message == o.message &&
194
+ param == o.param &&
195
+ retryable == o.retryable
196
+ end
197
+
198
+ # @see the `==` method
199
+ # @param [Object] Object to be compared
200
+ def eql?(o)
201
+ self == o
202
+ end
203
+
204
+ # Calculates hash code according to all attributes.
205
+ # @return [Integer] Hash code
206
+ def hash
207
+ [code, doc_url, errors, message, param, retryable].hash
208
+ end
209
+
210
+ # Builds the object from hash
211
+ # @param [Hash] attributes Model attributes in the form of hash
212
+ # @return [Object] Returns the model itself
213
+ def self.build_from_hash(attributes)
214
+ return nil unless attributes.is_a?(Hash)
215
+ attributes = attributes.transform_keys(&:to_sym)
216
+ transformed_hash = {}
217
+ openapi_types.each_pair do |key, type|
218
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
219
+ transformed_hash["#{key}"] = nil
220
+ elsif type =~ /\AArray<(.*)>/i
221
+ # check to ensure the input is an array given that the attribute
222
+ # is documented as an array but the input is not
223
+ if attributes[attribute_map[key]].is_a?(Array)
224
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
225
+ end
226
+ elsif !attributes[attribute_map[key]].nil?
227
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
228
+ end
229
+ end
230
+ new(transformed_hash)
231
+ end
232
+
233
+ # Returns the object in the form of hash
234
+ # @return [Hash] Returns the object in the form of hash
235
+ def to_hash
236
+ hash = {}
237
+ self.class.attribute_map.each_pair do |attr, param|
238
+ value = self.send(attr)
239
+ if value.nil?
240
+ is_nullable = self.class.openapi_nullable.include?(attr)
241
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
242
+ end
243
+
244
+ hash[param] = _to_hash(value)
245
+ end
246
+ hash
247
+ end
248
+
249
+ end
250
+
251
+ end