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,274 @@
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 Attachment < ApiModelBase
18
+ # Base64-encoded file content
19
+ attr_accessor :content
20
+
21
+ attr_accessor :encoding
22
+
23
+ # Filename with allowed extension
24
+ attr_accessor :filename
25
+
26
+ # MIME type override
27
+ attr_accessor :type
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
+ :'content' => :'content',
55
+ :'encoding' => :'encoding',
56
+ :'filename' => :'filename',
57
+ :'type' => :'type'
58
+ }
59
+ end
60
+
61
+ # Returns attribute mapping this model knows about
62
+ def self.acceptable_attribute_map
63
+ attribute_map
64
+ end
65
+
66
+ # Returns all the JSON keys this model knows about
67
+ def self.acceptable_attributes
68
+ acceptable_attribute_map.values
69
+ end
70
+
71
+ # Attribute type mapping.
72
+ def self.openapi_types
73
+ {
74
+ :'content' => :'String',
75
+ :'encoding' => :'String',
76
+ :'filename' => :'String',
77
+ :'type' => :'String'
78
+ }
79
+ end
80
+
81
+ # List of attributes with nullable: true
82
+ def self.openapi_nullable
83
+ Set.new([
84
+ ])
85
+ end
86
+
87
+ # Initializes the object
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ def initialize(attributes = {})
90
+ if (!attributes.is_a?(Hash))
91
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Sendmux::Sending::Generated::Attachment` initialize method"
92
+ end
93
+
94
+ # check to see if the attribute exists and convert string to symbol for hash key
95
+ acceptable_attribute_map = self.class.acceptable_attribute_map
96
+ attributes = attributes.each_with_object({}) { |(k, v), h|
97
+ if (!acceptable_attribute_map.key?(k.to_sym))
98
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendmux::Sending::Generated::Attachment`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
99
+ end
100
+ h[k.to_sym] = v
101
+ }
102
+
103
+ if attributes.key?(:'content')
104
+ self.content = attributes[:'content']
105
+ else
106
+ self.content = nil
107
+ end
108
+
109
+ if attributes.key?(:'encoding')
110
+ self.encoding = attributes[:'encoding']
111
+ else
112
+ self.encoding = 'base64'
113
+ end
114
+
115
+ if attributes.key?(:'filename')
116
+ self.filename = attributes[:'filename']
117
+ else
118
+ self.filename = nil
119
+ end
120
+
121
+ if attributes.key?(:'type')
122
+ self.type = attributes[:'type']
123
+ end
124
+ end
125
+
126
+ # Show invalid properties with the reasons. Usually used together with valid?
127
+ # @return Array for valid properties with the reasons
128
+ def list_invalid_properties
129
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
130
+ invalid_properties = Array.new
131
+ if @content.nil?
132
+ invalid_properties.push('invalid value for "content", content cannot be nil.')
133
+ end
134
+
135
+ if @content.to_s.length < 1
136
+ invalid_properties.push('invalid value for "content", the character length must be greater than or equal to 1.')
137
+ end
138
+
139
+ if @filename.nil?
140
+ invalid_properties.push('invalid value for "filename", filename cannot be nil.')
141
+ end
142
+
143
+ if @filename.to_s.length > 255
144
+ invalid_properties.push('invalid value for "filename", the character length must be smaller than or equal to 255.')
145
+ end
146
+
147
+ if @filename.to_s.length < 1
148
+ invalid_properties.push('invalid value for "filename", the character length must be greater than or equal to 1.')
149
+ end
150
+
151
+ invalid_properties
152
+ end
153
+
154
+ # Check to see if the all the properties in the model are valid
155
+ # @return true if the model is valid
156
+ def valid?
157
+ warn '[DEPRECATED] the `valid?` method is obsolete'
158
+ return false if @content.nil?
159
+ return false if @content.to_s.length < 1
160
+ encoding_validator = EnumAttributeValidator.new('String', ["base64", "unknown_default_open_api"])
161
+ return false unless encoding_validator.valid?(@encoding)
162
+ return false if @filename.nil?
163
+ return false if @filename.to_s.length > 255
164
+ return false if @filename.to_s.length < 1
165
+ true
166
+ end
167
+
168
+ # Custom attribute writer method with validation
169
+ # @param [Object] content Value to be assigned
170
+ def content=(content)
171
+ if content.nil?
172
+ fail ArgumentError, 'content cannot be nil'
173
+ end
174
+
175
+ if content.to_s.length < 1
176
+ fail ArgumentError, 'invalid value for "content", the character length must be greater than or equal to 1.'
177
+ end
178
+
179
+ @content = content
180
+ end
181
+
182
+ # Custom attribute writer method checking allowed values (enum).
183
+ # @param [Object] encoding Object to be assigned
184
+ def encoding=(encoding)
185
+ validator = EnumAttributeValidator.new('String', ["base64", "unknown_default_open_api"])
186
+ unless validator.valid?(encoding)
187
+ fail ArgumentError, "invalid value for \"encoding\", must be one of #{validator.allowable_values}."
188
+ end
189
+ @encoding = encoding
190
+ end
191
+
192
+ # Custom attribute writer method with validation
193
+ # @param [Object] filename Value to be assigned
194
+ def filename=(filename)
195
+ if filename.nil?
196
+ fail ArgumentError, 'filename cannot be nil'
197
+ end
198
+
199
+ if filename.to_s.length > 255
200
+ fail ArgumentError, 'invalid value for "filename", the character length must be smaller than or equal to 255.'
201
+ end
202
+
203
+ if filename.to_s.length < 1
204
+ fail ArgumentError, 'invalid value for "filename", the character length must be greater than or equal to 1.'
205
+ end
206
+
207
+ @filename = filename
208
+ end
209
+
210
+ # Checks equality by comparing each attribute.
211
+ # @param [Object] Object to be compared
212
+ def ==(o)
213
+ return true if self.equal?(o)
214
+ self.class == o.class &&
215
+ content == o.content &&
216
+ encoding == o.encoding &&
217
+ filename == o.filename &&
218
+ type == o.type
219
+ end
220
+
221
+ # @see the `==` method
222
+ # @param [Object] Object to be compared
223
+ def eql?(o)
224
+ self == o
225
+ end
226
+
227
+ # Calculates hash code according to all attributes.
228
+ # @return [Integer] Hash code
229
+ def hash
230
+ [content, encoding, filename, type].hash
231
+ end
232
+
233
+ # Builds the object from hash
234
+ # @param [Hash] attributes Model attributes in the form of hash
235
+ # @return [Object] Returns the model itself
236
+ def self.build_from_hash(attributes)
237
+ return nil unless attributes.is_a?(Hash)
238
+ attributes = attributes.transform_keys(&:to_sym)
239
+ transformed_hash = {}
240
+ openapi_types.each_pair do |key, type|
241
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
242
+ transformed_hash["#{key}"] = nil
243
+ elsif type =~ /\AArray<(.*)>/i
244
+ # check to ensure the input is an array given that the attribute
245
+ # is documented as an array but the input is not
246
+ if attributes[attribute_map[key]].is_a?(Array)
247
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
248
+ end
249
+ elsif !attributes[attribute_map[key]].nil?
250
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
251
+ end
252
+ end
253
+ new(transformed_hash)
254
+ end
255
+
256
+ # Returns the object in the form of hash
257
+ # @return [Hash] Returns the object in the form of hash
258
+ def to_hash
259
+ hash = {}
260
+ self.class.attribute_map.each_pair do |attr, param|
261
+ value = self.send(attr)
262
+ if value.nil?
263
+ is_nullable = self.class.openapi_nullable.include?(attr)
264
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
265
+ end
266
+
267
+ hash[param] = _to_hash(value)
268
+ end
269
+ hash
270
+ end
271
+
272
+ end
273
+
274
+ end
@@ -0,0 +1,256 @@
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 BatchResultItem < ApiModelBase
18
+ # Error details (only if failed)
19
+ attr_accessor :error
20
+
21
+ # Position in the input array
22
+ attr_accessor :index
23
+
24
+ # Message ID (null if failed)
25
+ attr_accessor :message_id
26
+
27
+ # Result status
28
+ attr_accessor :status
29
+
30
+ class EnumAttributeValidator
31
+ attr_reader :datatype
32
+ attr_reader :allowable_values
33
+
34
+ def initialize(datatype, allowable_values)
35
+ @allowable_values = allowable_values.map do |value|
36
+ case datatype.to_s
37
+ when /Integer/i
38
+ value.to_i
39
+ when /Float/i
40
+ value.to_f
41
+ else
42
+ value
43
+ end
44
+ end
45
+ end
46
+
47
+ def valid?(value)
48
+ !value || allowable_values.include?(value)
49
+ end
50
+ end
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'error' => :'error',
56
+ :'index' => :'index',
57
+ :'message_id' => :'message_id',
58
+ :'status' => :'status'
59
+ }
60
+ end
61
+
62
+ # Returns attribute mapping this model knows about
63
+ def self.acceptable_attribute_map
64
+ attribute_map
65
+ end
66
+
67
+ # Returns all the JSON keys this model knows about
68
+ def self.acceptable_attributes
69
+ acceptable_attribute_map.values
70
+ end
71
+
72
+ # Attribute type mapping.
73
+ def self.openapi_types
74
+ {
75
+ :'error' => :'ErrorDetail',
76
+ :'index' => :'Integer',
77
+ :'message_id' => :'String',
78
+ :'status' => :'String'
79
+ }
80
+ end
81
+
82
+ # List of attributes with nullable: true
83
+ def self.openapi_nullable
84
+ Set.new([
85
+ :'message_id',
86
+ ])
87
+ end
88
+
89
+ # Initializes the object
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ def initialize(attributes = {})
92
+ if (!attributes.is_a?(Hash))
93
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Sendmux::Sending::Generated::BatchResultItem` initialize method"
94
+ end
95
+
96
+ # check to see if the attribute exists and convert string to symbol for hash key
97
+ acceptable_attribute_map = self.class.acceptable_attribute_map
98
+ attributes = attributes.each_with_object({}) { |(k, v), h|
99
+ if (!acceptable_attribute_map.key?(k.to_sym))
100
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendmux::Sending::Generated::BatchResultItem`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
101
+ end
102
+ h[k.to_sym] = v
103
+ }
104
+
105
+ if attributes.key?(:'error')
106
+ self.error = attributes[:'error']
107
+ end
108
+
109
+ if attributes.key?(:'index')
110
+ self.index = attributes[:'index']
111
+ else
112
+ self.index = nil
113
+ end
114
+
115
+ if attributes.key?(:'message_id')
116
+ self.message_id = attributes[:'message_id']
117
+ else
118
+ self.message_id = nil
119
+ end
120
+
121
+ if attributes.key?(:'status')
122
+ self.status = attributes[:'status']
123
+ else
124
+ self.status = nil
125
+ end
126
+ end
127
+
128
+ # Show invalid properties with the reasons. Usually used together with valid?
129
+ # @return Array for valid properties with the reasons
130
+ def list_invalid_properties
131
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
132
+ invalid_properties = Array.new
133
+ if @index.nil?
134
+ invalid_properties.push('invalid value for "index", index cannot be nil.')
135
+ end
136
+
137
+ pattern = Regexp.new(/^eml_[a-z0-9]{24}$/)
138
+ if @message_id !~ pattern
139
+ invalid_properties.push("invalid value for \"message_id\", must conform to the pattern #{pattern}.")
140
+ end
141
+
142
+ if @status.nil?
143
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
144
+ end
145
+
146
+ invalid_properties
147
+ end
148
+
149
+ # Check to see if the all the properties in the model are valid
150
+ # @return true if the model is valid
151
+ def valid?
152
+ warn '[DEPRECATED] the `valid?` method is obsolete'
153
+ return false if @index.nil?
154
+ return false if @message_id !~ Regexp.new(/^eml_[a-z0-9]{24}$/)
155
+ return false if @status.nil?
156
+ status_validator = EnumAttributeValidator.new('String', ["queued", "failed", "unknown_default_open_api"])
157
+ return false unless status_validator.valid?(@status)
158
+ true
159
+ end
160
+
161
+ # Custom attribute writer method with validation
162
+ # @param [Object] index Value to be assigned
163
+ def index=(index)
164
+ if index.nil?
165
+ fail ArgumentError, 'index cannot be nil'
166
+ end
167
+
168
+ @index = index
169
+ end
170
+
171
+ # Custom attribute writer method with validation
172
+ # @param [Object] message_id Value to be assigned
173
+ def message_id=(message_id)
174
+ pattern = Regexp.new(/^eml_[a-z0-9]{24}$/)
175
+ if !message_id.nil? && message_id !~ pattern
176
+ fail ArgumentError, "invalid value for \"message_id\", must conform to the pattern #{pattern}."
177
+ end
178
+
179
+ @message_id = message_id
180
+ end
181
+
182
+ # Custom attribute writer method checking allowed values (enum).
183
+ # @param [Object] status Object to be assigned
184
+ def status=(status)
185
+ validator = EnumAttributeValidator.new('String', ["queued", "failed", "unknown_default_open_api"])
186
+ unless validator.valid?(status)
187
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
188
+ end
189
+ @status = status
190
+ end
191
+
192
+ # Checks equality by comparing each attribute.
193
+ # @param [Object] Object to be compared
194
+ def ==(o)
195
+ return true if self.equal?(o)
196
+ self.class == o.class &&
197
+ error == o.error &&
198
+ index == o.index &&
199
+ message_id == o.message_id &&
200
+ status == o.status
201
+ end
202
+
203
+ # @see the `==` method
204
+ # @param [Object] Object to be compared
205
+ def eql?(o)
206
+ self == o
207
+ end
208
+
209
+ # Calculates hash code according to all attributes.
210
+ # @return [Integer] Hash code
211
+ def hash
212
+ [error, index, message_id, status].hash
213
+ end
214
+
215
+ # Builds the object from hash
216
+ # @param [Hash] attributes Model attributes in the form of hash
217
+ # @return [Object] Returns the model itself
218
+ def self.build_from_hash(attributes)
219
+ return nil unless attributes.is_a?(Hash)
220
+ attributes = attributes.transform_keys(&:to_sym)
221
+ transformed_hash = {}
222
+ openapi_types.each_pair do |key, type|
223
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
224
+ transformed_hash["#{key}"] = nil
225
+ elsif type =~ /\AArray<(.*)>/i
226
+ # check to ensure the input is an array given that the attribute
227
+ # is documented as an array but the input is not
228
+ if attributes[attribute_map[key]].is_a?(Array)
229
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
230
+ end
231
+ elsif !attributes[attribute_map[key]].nil?
232
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
233
+ end
234
+ end
235
+ new(transformed_hash)
236
+ end
237
+
238
+ # Returns the object in the form of hash
239
+ # @return [Hash] Returns the object in the form of hash
240
+ def to_hash
241
+ hash = {}
242
+ self.class.attribute_map.each_pair do |attr, param|
243
+ value = self.send(attr)
244
+ if value.nil?
245
+ is_nullable = self.class.openapi_nullable.include?(attr)
246
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
247
+ end
248
+
249
+ hash[param] = _to_hash(value)
250
+ end
251
+ hash
252
+ end
253
+
254
+ end
255
+
256
+ end
@@ -0,0 +1,185 @@
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 BatchSendRequest < ApiModelBase
18
+ # Array of email messages to send (max 100)
19
+ attr_accessor :messages
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'messages' => :'messages'
25
+ }
26
+ end
27
+
28
+ # Returns attribute mapping this model knows about
29
+ def self.acceptable_attribute_map
30
+ attribute_map
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ acceptable_attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'messages' => :'Array<EmailSendRequest>'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Sendmux::Sending::Generated::BatchSendRequest` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ acceptable_attribute_map = self.class.acceptable_attribute_map
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!acceptable_attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendmux::Sending::Generated::BatchSendRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'messages')
68
+ if (value = attributes[:'messages']).is_a?(Array)
69
+ self.messages = value
70
+ end
71
+ else
72
+ self.messages = nil
73
+ end
74
+ end
75
+
76
+ # Show invalid properties with the reasons. Usually used together with valid?
77
+ # @return Array for valid properties with the reasons
78
+ def list_invalid_properties
79
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
80
+ invalid_properties = Array.new
81
+ if @messages.nil?
82
+ invalid_properties.push('invalid value for "messages", messages cannot be nil.')
83
+ end
84
+
85
+ if @messages.length > 100
86
+ invalid_properties.push('invalid value for "messages", number of items must be less than or equal to 100.')
87
+ end
88
+
89
+ if @messages.length < 1
90
+ invalid_properties.push('invalid value for "messages", number of items must be greater than or equal to 1.')
91
+ end
92
+
93
+ invalid_properties
94
+ end
95
+
96
+ # Check to see if the all the properties in the model are valid
97
+ # @return true if the model is valid
98
+ def valid?
99
+ warn '[DEPRECATED] the `valid?` method is obsolete'
100
+ return false if @messages.nil?
101
+ return false if @messages.length > 100
102
+ return false if @messages.length < 1
103
+ true
104
+ end
105
+
106
+ # Custom attribute writer method with validation
107
+ # @param [Object] messages Value to be assigned
108
+ def messages=(messages)
109
+ if messages.nil?
110
+ fail ArgumentError, 'messages cannot be nil'
111
+ end
112
+
113
+ if messages.length > 100
114
+ fail ArgumentError, 'invalid value for "messages", number of items must be less than or equal to 100.'
115
+ end
116
+
117
+ if messages.length < 1
118
+ fail ArgumentError, 'invalid value for "messages", number of items must be greater than or equal to 1.'
119
+ end
120
+
121
+ @messages = messages
122
+ end
123
+
124
+ # Checks equality by comparing each attribute.
125
+ # @param [Object] Object to be compared
126
+ def ==(o)
127
+ return true if self.equal?(o)
128
+ self.class == o.class &&
129
+ messages == o.messages
130
+ end
131
+
132
+ # @see the `==` method
133
+ # @param [Object] Object to be compared
134
+ def eql?(o)
135
+ self == o
136
+ end
137
+
138
+ # Calculates hash code according to all attributes.
139
+ # @return [Integer] Hash code
140
+ def hash
141
+ [messages].hash
142
+ end
143
+
144
+ # Builds the object from hash
145
+ # @param [Hash] attributes Model attributes in the form of hash
146
+ # @return [Object] Returns the model itself
147
+ def self.build_from_hash(attributes)
148
+ return nil unless attributes.is_a?(Hash)
149
+ attributes = attributes.transform_keys(&:to_sym)
150
+ transformed_hash = {}
151
+ openapi_types.each_pair do |key, type|
152
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
153
+ transformed_hash["#{key}"] = nil
154
+ elsif type =~ /\AArray<(.*)>/i
155
+ # check to ensure the input is an array given that the attribute
156
+ # is documented as an array but the input is not
157
+ if attributes[attribute_map[key]].is_a?(Array)
158
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
159
+ end
160
+ elsif !attributes[attribute_map[key]].nil?
161
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
162
+ end
163
+ end
164
+ new(transformed_hash)
165
+ end
166
+
167
+ # Returns the object in the form of hash
168
+ # @return [Hash] Returns the object in the form of hash
169
+ def to_hash
170
+ hash = {}
171
+ self.class.attribute_map.each_pair do |attr, param|
172
+ value = self.send(attr)
173
+ if value.nil?
174
+ is_nullable = self.class.openapi_nullable.include?(attr)
175
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
176
+ end
177
+
178
+ hash[param] = _to_hash(value)
179
+ end
180
+ hash
181
+ end
182
+
183
+ end
184
+
185
+ end