sendmux-sending 1.1.0 → 1.2.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.
@@ -0,0 +1,337 @@
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 AttachmentUploadIntentData < ApiModelBase
18
+ # ISO timestamp when the upload URL expires.
19
+ attr_accessor :expires_at
20
+
21
+ # Headers that must be sent with the PUT upload request.
22
+ attr_accessor :headers
23
+
24
+ # Maximum upload size in bytes
25
+ attr_accessor :max_size_bytes
26
+
27
+ # HTTP method for upload_url
28
+ attr_accessor :method
29
+
30
+ # Temporary upload intent ID.
31
+ attr_accessor :upload_id
32
+
33
+ # Short-lived URL that accepts a binary PUT with the returned headers.
34
+ attr_accessor :upload_url
35
+
36
+ class EnumAttributeValidator
37
+ attr_reader :datatype
38
+ attr_reader :allowable_values
39
+
40
+ def initialize(datatype, allowable_values)
41
+ @allowable_values = allowable_values.map do |value|
42
+ case datatype.to_s
43
+ when /Integer/i
44
+ value.to_i
45
+ when /Float/i
46
+ value.to_f
47
+ else
48
+ value
49
+ end
50
+ end
51
+ end
52
+
53
+ def valid?(value)
54
+ !value || allowable_values.include?(value)
55
+ end
56
+ end
57
+
58
+ # Attribute mapping from ruby-style variable name to JSON key.
59
+ def self.attribute_map
60
+ {
61
+ :'expires_at' => :'expires_at',
62
+ :'headers' => :'headers',
63
+ :'max_size_bytes' => :'max_size_bytes',
64
+ :'method' => :'method',
65
+ :'upload_id' => :'upload_id',
66
+ :'upload_url' => :'upload_url'
67
+ }
68
+ end
69
+
70
+ # Returns attribute mapping this model knows about
71
+ def self.acceptable_attribute_map
72
+ attribute_map
73
+ end
74
+
75
+ # Returns all the JSON keys this model knows about
76
+ def self.acceptable_attributes
77
+ acceptable_attribute_map.values
78
+ end
79
+
80
+ # Attribute type mapping.
81
+ def self.openapi_types
82
+ {
83
+ :'expires_at' => :'Time',
84
+ :'headers' => :'Hash<String, String>',
85
+ :'max_size_bytes' => :'Integer',
86
+ :'method' => :'String',
87
+ :'upload_id' => :'String',
88
+ :'upload_url' => :'String'
89
+ }
90
+ end
91
+
92
+ # List of attributes with nullable: true
93
+ def self.openapi_nullable
94
+ Set.new([
95
+ ])
96
+ end
97
+
98
+ # Initializes the object
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ def initialize(attributes = {})
101
+ if (!attributes.is_a?(Hash))
102
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Sendmux::Sending::Generated::AttachmentUploadIntentData` initialize method"
103
+ end
104
+
105
+ # check to see if the attribute exists and convert string to symbol for hash key
106
+ acceptable_attribute_map = self.class.acceptable_attribute_map
107
+ attributes = attributes.each_with_object({}) { |(k, v), h|
108
+ if (!acceptable_attribute_map.key?(k.to_sym))
109
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendmux::Sending::Generated::AttachmentUploadIntentData`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
110
+ end
111
+ h[k.to_sym] = v
112
+ }
113
+
114
+ if attributes.key?(:'expires_at')
115
+ self.expires_at = attributes[:'expires_at']
116
+ else
117
+ self.expires_at = nil
118
+ end
119
+
120
+ if attributes.key?(:'headers')
121
+ if (value = attributes[:'headers']).is_a?(Hash)
122
+ self.headers = value
123
+ end
124
+ else
125
+ self.headers = nil
126
+ end
127
+
128
+ if attributes.key?(:'max_size_bytes')
129
+ self.max_size_bytes = attributes[:'max_size_bytes']
130
+ else
131
+ self.max_size_bytes = nil
132
+ end
133
+
134
+ if attributes.key?(:'method')
135
+ self.method = attributes[:'method']
136
+ else
137
+ self.method = nil
138
+ end
139
+
140
+ if attributes.key?(:'upload_id')
141
+ self.upload_id = attributes[:'upload_id']
142
+ else
143
+ self.upload_id = nil
144
+ end
145
+
146
+ if attributes.key?(:'upload_url')
147
+ self.upload_url = attributes[:'upload_url']
148
+ else
149
+ self.upload_url = nil
150
+ end
151
+ end
152
+
153
+ # Show invalid properties with the reasons. Usually used together with valid?
154
+ # @return Array for valid properties with the reasons
155
+ def list_invalid_properties
156
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
157
+ invalid_properties = Array.new
158
+ if @expires_at.nil?
159
+ invalid_properties.push('invalid value for "expires_at", expires_at cannot be nil.')
160
+ end
161
+
162
+ if @headers.nil?
163
+ invalid_properties.push('invalid value for "headers", headers cannot be nil.')
164
+ end
165
+
166
+ if @max_size_bytes.nil?
167
+ invalid_properties.push('invalid value for "max_size_bytes", max_size_bytes cannot be nil.')
168
+ end
169
+
170
+ if @method.nil?
171
+ invalid_properties.push('invalid value for "method", method cannot be nil.')
172
+ end
173
+
174
+ if @upload_id.nil?
175
+ invalid_properties.push('invalid value for "upload_id", upload_id cannot be nil.')
176
+ end
177
+
178
+ pattern = Regexp.new(/^upl_[a-z0-9]{24}$/)
179
+ if @upload_id !~ pattern
180
+ invalid_properties.push("invalid value for \"upload_id\", must conform to the pattern #{pattern}.")
181
+ end
182
+
183
+ if @upload_url.nil?
184
+ invalid_properties.push('invalid value for "upload_url", upload_url cannot be nil.')
185
+ end
186
+
187
+ invalid_properties
188
+ end
189
+
190
+ # Check to see if the all the properties in the model are valid
191
+ # @return true if the model is valid
192
+ def valid?
193
+ warn '[DEPRECATED] the `valid?` method is obsolete'
194
+ return false if @expires_at.nil?
195
+ return false if @headers.nil?
196
+ return false if @max_size_bytes.nil?
197
+ return false if @method.nil?
198
+ method_validator = EnumAttributeValidator.new('String', ["PUT", "unknown_default_open_api"])
199
+ return false unless method_validator.valid?(@method)
200
+ return false if @upload_id.nil?
201
+ return false if @upload_id !~ Regexp.new(/^upl_[a-z0-9]{24}$/)
202
+ return false if @upload_url.nil?
203
+ true
204
+ end
205
+
206
+ # Custom attribute writer method with validation
207
+ # @param [Object] expires_at Value to be assigned
208
+ def expires_at=(expires_at)
209
+ if expires_at.nil?
210
+ fail ArgumentError, 'expires_at cannot be nil'
211
+ end
212
+
213
+ @expires_at = expires_at
214
+ end
215
+
216
+ # Custom attribute writer method with validation
217
+ # @param [Object] headers Value to be assigned
218
+ def headers=(headers)
219
+ if headers.nil?
220
+ fail ArgumentError, 'headers cannot be nil'
221
+ end
222
+
223
+ @headers = headers
224
+ end
225
+
226
+ # Custom attribute writer method with validation
227
+ # @param [Object] max_size_bytes Value to be assigned
228
+ def max_size_bytes=(max_size_bytes)
229
+ if max_size_bytes.nil?
230
+ fail ArgumentError, 'max_size_bytes cannot be nil'
231
+ end
232
+
233
+ @max_size_bytes = max_size_bytes
234
+ end
235
+
236
+ # Custom attribute writer method checking allowed values (enum).
237
+ # @param [Object] method Object to be assigned
238
+ def method=(method)
239
+ validator = EnumAttributeValidator.new('String', ["PUT", "unknown_default_open_api"])
240
+ unless validator.valid?(method)
241
+ fail ArgumentError, "invalid value for \"method\", must be one of #{validator.allowable_values}."
242
+ end
243
+ @method = method
244
+ end
245
+
246
+ # Custom attribute writer method with validation
247
+ # @param [Object] upload_id Value to be assigned
248
+ def upload_id=(upload_id)
249
+ if upload_id.nil?
250
+ fail ArgumentError, 'upload_id cannot be nil'
251
+ end
252
+
253
+ pattern = Regexp.new(/^upl_[a-z0-9]{24}$/)
254
+ if upload_id !~ pattern
255
+ fail ArgumentError, "invalid value for \"upload_id\", must conform to the pattern #{pattern}."
256
+ end
257
+
258
+ @upload_id = upload_id
259
+ end
260
+
261
+ # Custom attribute writer method with validation
262
+ # @param [Object] upload_url Value to be assigned
263
+ def upload_url=(upload_url)
264
+ if upload_url.nil?
265
+ fail ArgumentError, 'upload_url cannot be nil'
266
+ end
267
+
268
+ @upload_url = upload_url
269
+ end
270
+
271
+ # Checks equality by comparing each attribute.
272
+ # @param [Object] Object to be compared
273
+ def ==(o)
274
+ return true if self.equal?(o)
275
+ self.class == o.class &&
276
+ expires_at == o.expires_at &&
277
+ headers == o.headers &&
278
+ max_size_bytes == o.max_size_bytes &&
279
+ method == o.method &&
280
+ upload_id == o.upload_id &&
281
+ upload_url == o.upload_url
282
+ end
283
+
284
+ # @see the `==` method
285
+ # @param [Object] Object to be compared
286
+ def eql?(o)
287
+ self == o
288
+ end
289
+
290
+ # Calculates hash code according to all attributes.
291
+ # @return [Integer] Hash code
292
+ def hash
293
+ [expires_at, headers, max_size_bytes, method, upload_id, upload_url].hash
294
+ end
295
+
296
+ # Builds the object from hash
297
+ # @param [Hash] attributes Model attributes in the form of hash
298
+ # @return [Object] Returns the model itself
299
+ def self.build_from_hash(attributes)
300
+ return nil unless attributes.is_a?(Hash)
301
+ attributes = attributes.transform_keys(&:to_sym)
302
+ transformed_hash = {}
303
+ openapi_types.each_pair do |key, type|
304
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
305
+ transformed_hash["#{key}"] = nil
306
+ elsif type =~ /\AArray<(.*)>/i
307
+ # check to ensure the input is an array given that the attribute
308
+ # is documented as an array but the input is not
309
+ if attributes[attribute_map[key]].is_a?(Array)
310
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
311
+ end
312
+ elsif !attributes[attribute_map[key]].nil?
313
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
314
+ end
315
+ end
316
+ new(transformed_hash)
317
+ end
318
+
319
+ # Returns the object in the form of hash
320
+ # @return [Hash] Returns the object in the form of hash
321
+ def to_hash
322
+ hash = {}
323
+ self.class.attribute_map.each_pair do |attr, param|
324
+ value = self.send(attr)
325
+ if value.nil?
326
+ is_nullable = self.class.openapi_nullable.include?(attr)
327
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
328
+ end
329
+
330
+ hash[param] = _to_hash(value)
331
+ end
332
+ hash
333
+ end
334
+
335
+ end
336
+
337
+ end
@@ -0,0 +1,279 @@
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 AttachmentUploadIntentRequest < ApiModelBase
18
+ # MIME type expected for the upload.
19
+ attr_accessor :content_type
20
+
21
+ # Filename to associate with the uploaded attachment.
22
+ attr_accessor :filename
23
+
24
+ # Optional SHA-256 hex digest for the upload bytes.
25
+ attr_accessor :sha256
26
+
27
+ # Exact byte size that will be uploaded.
28
+ attr_accessor :size_bytes
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'content_type' => :'content_type',
34
+ :'filename' => :'filename',
35
+ :'sha256' => :'sha256',
36
+ :'size_bytes' => :'size_bytes'
37
+ }
38
+ end
39
+
40
+ # Returns attribute mapping this model knows about
41
+ def self.acceptable_attribute_map
42
+ attribute_map
43
+ end
44
+
45
+ # Returns all the JSON keys this model knows about
46
+ def self.acceptable_attributes
47
+ acceptable_attribute_map.values
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.openapi_types
52
+ {
53
+ :'content_type' => :'String',
54
+ :'filename' => :'String',
55
+ :'sha256' => :'String',
56
+ :'size_bytes' => :'Integer'
57
+ }
58
+ end
59
+
60
+ # List of attributes with nullable: true
61
+ def self.openapi_nullable
62
+ Set.new([
63
+ ])
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ if (!attributes.is_a?(Hash))
70
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Sendmux::Sending::Generated::AttachmentUploadIntentRequest` initialize method"
71
+ end
72
+
73
+ # check to see if the attribute exists and convert string to symbol for hash key
74
+ acceptable_attribute_map = self.class.acceptable_attribute_map
75
+ attributes = attributes.each_with_object({}) { |(k, v), h|
76
+ if (!acceptable_attribute_map.key?(k.to_sym))
77
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Sendmux::Sending::Generated::AttachmentUploadIntentRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
78
+ end
79
+ h[k.to_sym] = v
80
+ }
81
+
82
+ if attributes.key?(:'content_type')
83
+ self.content_type = attributes[:'content_type']
84
+ end
85
+
86
+ if attributes.key?(:'filename')
87
+ self.filename = attributes[:'filename']
88
+ else
89
+ self.filename = nil
90
+ end
91
+
92
+ if attributes.key?(:'sha256')
93
+ self.sha256 = attributes[:'sha256']
94
+ end
95
+
96
+ if attributes.key?(:'size_bytes')
97
+ self.size_bytes = attributes[:'size_bytes']
98
+ else
99
+ self.size_bytes = nil
100
+ end
101
+ end
102
+
103
+ # Show invalid properties with the reasons. Usually used together with valid?
104
+ # @return Array for valid properties with the reasons
105
+ def list_invalid_properties
106
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
107
+ invalid_properties = Array.new
108
+ if !@content_type.nil? && @content_type.to_s.length > 255
109
+ invalid_properties.push('invalid value for "content_type", the character length must be smaller than or equal to 255.')
110
+ end
111
+
112
+ if @filename.nil?
113
+ invalid_properties.push('invalid value for "filename", filename cannot be nil.')
114
+ end
115
+
116
+ if @filename.to_s.length > 255
117
+ invalid_properties.push('invalid value for "filename", the character length must be smaller than or equal to 255.')
118
+ end
119
+
120
+ if @filename.to_s.length < 1
121
+ invalid_properties.push('invalid value for "filename", the character length must be greater than or equal to 1.')
122
+ end
123
+
124
+ pattern = Regexp.new(/^[a-f0-9]{64}$/)
125
+ if !@sha256.nil? && @sha256 !~ pattern
126
+ invalid_properties.push("invalid value for \"sha256\", must conform to the pattern #{pattern}.")
127
+ end
128
+
129
+ if @size_bytes.nil?
130
+ invalid_properties.push('invalid value for "size_bytes", size_bytes cannot be nil.')
131
+ end
132
+
133
+ if @size_bytes <= 0
134
+ invalid_properties.push('invalid value for "size_bytes", must be greater than 0.')
135
+ end
136
+
137
+ invalid_properties
138
+ end
139
+
140
+ # Check to see if the all the properties in the model are valid
141
+ # @return true if the model is valid
142
+ def valid?
143
+ warn '[DEPRECATED] the `valid?` method is obsolete'
144
+ return false if !@content_type.nil? && @content_type.to_s.length > 255
145
+ return false if @filename.nil?
146
+ return false if @filename.to_s.length > 255
147
+ return false if @filename.to_s.length < 1
148
+ return false if !@sha256.nil? && @sha256 !~ Regexp.new(/^[a-f0-9]{64}$/)
149
+ return false if @size_bytes.nil?
150
+ return false if @size_bytes <= 0
151
+ true
152
+ end
153
+
154
+ # Custom attribute writer method with validation
155
+ # @param [Object] content_type Value to be assigned
156
+ def content_type=(content_type)
157
+ if content_type.nil?
158
+ fail ArgumentError, 'content_type cannot be nil'
159
+ end
160
+
161
+ if content_type.to_s.length > 255
162
+ fail ArgumentError, 'invalid value for "content_type", the character length must be smaller than or equal to 255.'
163
+ end
164
+
165
+ @content_type = content_type
166
+ end
167
+
168
+ # Custom attribute writer method with validation
169
+ # @param [Object] filename Value to be assigned
170
+ def filename=(filename)
171
+ if filename.nil?
172
+ fail ArgumentError, 'filename cannot be nil'
173
+ end
174
+
175
+ if filename.to_s.length > 255
176
+ fail ArgumentError, 'invalid value for "filename", the character length must be smaller than or equal to 255.'
177
+ end
178
+
179
+ if filename.to_s.length < 1
180
+ fail ArgumentError, 'invalid value for "filename", the character length must be greater than or equal to 1.'
181
+ end
182
+
183
+ @filename = filename
184
+ end
185
+
186
+ # Custom attribute writer method with validation
187
+ # @param [Object] sha256 Value to be assigned
188
+ def sha256=(sha256)
189
+ if sha256.nil?
190
+ fail ArgumentError, 'sha256 cannot be nil'
191
+ end
192
+
193
+ pattern = Regexp.new(/^[a-f0-9]{64}$/)
194
+ if sha256 !~ pattern
195
+ fail ArgumentError, "invalid value for \"sha256\", must conform to the pattern #{pattern}."
196
+ end
197
+
198
+ @sha256 = sha256
199
+ end
200
+
201
+ # Custom attribute writer method with validation
202
+ # @param [Object] size_bytes Value to be assigned
203
+ def size_bytes=(size_bytes)
204
+ if size_bytes.nil?
205
+ fail ArgumentError, 'size_bytes cannot be nil'
206
+ end
207
+
208
+ if size_bytes <= 0
209
+ fail ArgumentError, 'invalid value for "size_bytes", must be greater than 0.'
210
+ end
211
+
212
+ @size_bytes = size_bytes
213
+ end
214
+
215
+ # Checks equality by comparing each attribute.
216
+ # @param [Object] Object to be compared
217
+ def ==(o)
218
+ return true if self.equal?(o)
219
+ self.class == o.class &&
220
+ content_type == o.content_type &&
221
+ filename == o.filename &&
222
+ sha256 == o.sha256 &&
223
+ size_bytes == o.size_bytes
224
+ end
225
+
226
+ # @see the `==` method
227
+ # @param [Object] Object to be compared
228
+ def eql?(o)
229
+ self == o
230
+ end
231
+
232
+ # Calculates hash code according to all attributes.
233
+ # @return [Integer] Hash code
234
+ def hash
235
+ [content_type, filename, sha256, size_bytes].hash
236
+ end
237
+
238
+ # Builds the object from hash
239
+ # @param [Hash] attributes Model attributes in the form of hash
240
+ # @return [Object] Returns the model itself
241
+ def self.build_from_hash(attributes)
242
+ return nil unless attributes.is_a?(Hash)
243
+ attributes = attributes.transform_keys(&:to_sym)
244
+ transformed_hash = {}
245
+ openapi_types.each_pair do |key, type|
246
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
247
+ transformed_hash["#{key}"] = nil
248
+ elsif type =~ /\AArray<(.*)>/i
249
+ # check to ensure the input is an array given that the attribute
250
+ # is documented as an array but the input is not
251
+ if attributes[attribute_map[key]].is_a?(Array)
252
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
253
+ end
254
+ elsif !attributes[attribute_map[key]].nil?
255
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
256
+ end
257
+ end
258
+ new(transformed_hash)
259
+ end
260
+
261
+ # Returns the object in the form of hash
262
+ # @return [Hash] Returns the object in the form of hash
263
+ def to_hash
264
+ hash = {}
265
+ self.class.attribute_map.each_pair do |attr, param|
266
+ value = self.send(attr)
267
+ if value.nil?
268
+ is_nullable = self.class.openapi_nullable.include?(attr)
269
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
270
+ end
271
+
272
+ hash[param] = _to_hash(value)
273
+ end
274
+ hash
275
+ end
276
+
277
+ end
278
+
279
+ end