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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/sendmux/sending/client.rb +4 -0
- data/lib/sendmux/sending/version.rb +1 -1
- data/lib/sendmux_sending_generated/api/attachments_api.rb +370 -0
- data/lib/sendmux_sending_generated/api_client.rb +7 -1
- data/lib/sendmux_sending_generated/models/attachment.rb +76 -247
- data/lib/sendmux_sending_generated/models/attachment_upload_data.rb +284 -0
- data/lib/sendmux_sending_generated/models/attachment_upload_intent_data.rb +337 -0
- data/lib/sendmux_sending_generated/models/attachment_upload_intent_request.rb +279 -0
- data/lib/sendmux_sending_generated/models/attachment_upload_intent_response.rb +223 -0
- data/lib/sendmux_sending_generated/models/attachment_upload_response.rb +223 -0
- data/lib/sendmux_sending_generated/models/email_send_request.rb +1 -1
- data/lib/sendmux_sending_generated/models/inline_attachment.rb +274 -0
- data/lib/sendmux_sending_generated/models/uploaded_attachment_ref.rb +176 -0
- data/lib/sendmux_sending_generated.rb +8 -0
- metadata +10 -2
|
@@ -14,261 +14,90 @@ require 'date'
|
|
|
14
14
|
require 'time'
|
|
15
15
|
|
|
16
16
|
module Sendmux::Sending::Generated
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
17
|
+
module Attachment
|
|
18
|
+
class << self
|
|
19
|
+
# List of class defined in anyOf (OpenAPI v3)
|
|
20
|
+
def openapi_any_of
|
|
21
|
+
[
|
|
22
|
+
:'InlineAttachment',
|
|
23
|
+
:'UploadedAttachmentRef'
|
|
24
|
+
]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Builds the object
|
|
28
|
+
# @param [Mixed] Data to be matched against the list of anyOf items
|
|
29
|
+
# @return [Object] Returns the model or the data itself
|
|
30
|
+
def build(data)
|
|
31
|
+
# Go through the list of anyOf items and attempt to identify the appropriate one.
|
|
32
|
+
# Note:
|
|
33
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
|
34
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
|
35
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
|
36
|
+
# - TODO: logging when debugging is set.
|
|
37
|
+
openapi_any_of.each do |klass|
|
|
38
|
+
begin
|
|
39
|
+
next if klass == :AnyType # "nullable: true"
|
|
40
|
+
return find_and_cast_into_type(klass, data)
|
|
41
|
+
rescue # rescue all errors so we keep iterating even if the current item lookup raises
|
|
42
42
|
end
|
|
43
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
44
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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) }
|
|
45
|
+
openapi_any_of.include?(:AnyType) ? data : nil
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
private
|
|
49
|
+
|
|
50
|
+
SchemaMismatchError = Class.new(StandardError)
|
|
51
|
+
|
|
52
|
+
# Note: 'File' is missing here because in the regular case we get the data _after_ a call to JSON.parse.
|
|
53
|
+
def find_and_cast_into_type(klass, data)
|
|
54
|
+
return if data.nil?
|
|
55
|
+
|
|
56
|
+
case klass.to_s
|
|
57
|
+
when 'Boolean'
|
|
58
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
|
59
|
+
when 'Float'
|
|
60
|
+
return data if data.instance_of?(Float)
|
|
61
|
+
when 'Integer'
|
|
62
|
+
return data if data.instance_of?(Integer)
|
|
63
|
+
when 'Time'
|
|
64
|
+
return Time.parse(data)
|
|
65
|
+
when 'Date'
|
|
66
|
+
return Date.iso8601(data)
|
|
67
|
+
when 'String'
|
|
68
|
+
return data if data.instance_of?(String)
|
|
69
|
+
when 'Object' # "type: object"
|
|
70
|
+
return data if data.instance_of?(Hash)
|
|
71
|
+
when /\AArray<(?<sub_type>.+)>\z/ # "type: array"
|
|
72
|
+
if data.instance_of?(Array)
|
|
73
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
74
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
|
75
|
+
end
|
|
76
|
+
when /\AHash<String, (?<sub_type>.+)>\z/ # "type: object" with "additionalProperties: { ... }"
|
|
77
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
|
78
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
79
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
|
80
|
+
end
|
|
81
|
+
else # model
|
|
82
|
+
const = Sendmux::Sending::Generated.const_get(klass)
|
|
83
|
+
if const
|
|
84
|
+
if const.respond_to?(:openapi_any_of) # nested anyOf model
|
|
85
|
+
model = const.build(data)
|
|
86
|
+
return model if model
|
|
87
|
+
else
|
|
88
|
+
# raise if data contains keys that are not known to the model
|
|
89
|
+
raise if const.respond_to?(:acceptable_attributes) && !(data.keys - const.acceptable_attributes).empty?
|
|
90
|
+
model = const.build_from_hash(data)
|
|
91
|
+
return model if model
|
|
92
|
+
end
|
|
248
93
|
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
94
|
end
|
|
266
95
|
|
|
267
|
-
|
|
96
|
+
raise # if no match by now, raise
|
|
97
|
+
rescue
|
|
98
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
268
99
|
end
|
|
269
|
-
hash
|
|
270
100
|
end
|
|
271
|
-
|
|
272
101
|
end
|
|
273
102
|
|
|
274
103
|
end
|
|
@@ -0,0 +1,284 @@
|
|
|
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 AttachmentUploadData < ApiModelBase
|
|
18
|
+
# Temporary attachment ID to use in email attachments[].
|
|
19
|
+
attr_accessor :attachment_id
|
|
20
|
+
|
|
21
|
+
# Stored attachment MIME type
|
|
22
|
+
attr_accessor :content_type
|
|
23
|
+
|
|
24
|
+
# ISO timestamp when this temporary attachment reference expires.
|
|
25
|
+
attr_accessor :expires_at
|
|
26
|
+
|
|
27
|
+
# Stored attachment filename
|
|
28
|
+
attr_accessor :filename
|
|
29
|
+
|
|
30
|
+
# Stored attachment byte size
|
|
31
|
+
attr_accessor :size_bytes
|
|
32
|
+
|
|
33
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
34
|
+
def self.attribute_map
|
|
35
|
+
{
|
|
36
|
+
:'attachment_id' => :'attachment_id',
|
|
37
|
+
:'content_type' => :'content_type',
|
|
38
|
+
:'expires_at' => :'expires_at',
|
|
39
|
+
:'filename' => :'filename',
|
|
40
|
+
:'size_bytes' => :'size_bytes'
|
|
41
|
+
}
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Returns attribute mapping this model knows about
|
|
45
|
+
def self.acceptable_attribute_map
|
|
46
|
+
attribute_map
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Returns all the JSON keys this model knows about
|
|
50
|
+
def self.acceptable_attributes
|
|
51
|
+
acceptable_attribute_map.values
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Attribute type mapping.
|
|
55
|
+
def self.openapi_types
|
|
56
|
+
{
|
|
57
|
+
:'attachment_id' => :'String',
|
|
58
|
+
:'content_type' => :'String',
|
|
59
|
+
:'expires_at' => :'Time',
|
|
60
|
+
:'filename' => :'String',
|
|
61
|
+
:'size_bytes' => :'Integer'
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# List of attributes with nullable: true
|
|
66
|
+
def self.openapi_nullable
|
|
67
|
+
Set.new([
|
|
68
|
+
])
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Initializes the object
|
|
72
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
73
|
+
def initialize(attributes = {})
|
|
74
|
+
if (!attributes.is_a?(Hash))
|
|
75
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Sendmux::Sending::Generated::AttachmentUploadData` initialize method"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
79
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
80
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
81
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
82
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Sendmux::Sending::Generated::AttachmentUploadData`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
83
|
+
end
|
|
84
|
+
h[k.to_sym] = v
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if attributes.key?(:'attachment_id')
|
|
88
|
+
self.attachment_id = attributes[:'attachment_id']
|
|
89
|
+
else
|
|
90
|
+
self.attachment_id = nil
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
if attributes.key?(:'content_type')
|
|
94
|
+
self.content_type = attributes[:'content_type']
|
|
95
|
+
else
|
|
96
|
+
self.content_type = nil
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
if attributes.key?(:'expires_at')
|
|
100
|
+
self.expires_at = attributes[:'expires_at']
|
|
101
|
+
else
|
|
102
|
+
self.expires_at = nil
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
if attributes.key?(:'filename')
|
|
106
|
+
self.filename = attributes[:'filename']
|
|
107
|
+
else
|
|
108
|
+
self.filename = nil
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
if attributes.key?(:'size_bytes')
|
|
112
|
+
self.size_bytes = attributes[:'size_bytes']
|
|
113
|
+
else
|
|
114
|
+
self.size_bytes = nil
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
119
|
+
# @return Array for valid properties with the reasons
|
|
120
|
+
def list_invalid_properties
|
|
121
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
122
|
+
invalid_properties = Array.new
|
|
123
|
+
if @attachment_id.nil?
|
|
124
|
+
invalid_properties.push('invalid value for "attachment_id", attachment_id cannot be nil.')
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
pattern = Regexp.new(/^att_[a-z0-9]{24}$/)
|
|
128
|
+
if @attachment_id !~ pattern
|
|
129
|
+
invalid_properties.push("invalid value for \"attachment_id\", must conform to the pattern #{pattern}.")
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
if @content_type.nil?
|
|
133
|
+
invalid_properties.push('invalid value for "content_type", content_type cannot be nil.')
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
if @expires_at.nil?
|
|
137
|
+
invalid_properties.push('invalid value for "expires_at", expires_at cannot be nil.')
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
if @filename.nil?
|
|
141
|
+
invalid_properties.push('invalid value for "filename", filename cannot be nil.')
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
if @size_bytes.nil?
|
|
145
|
+
invalid_properties.push('invalid value for "size_bytes", size_bytes cannot be nil.')
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
invalid_properties
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Check to see if the all the properties in the model are valid
|
|
152
|
+
# @return true if the model is valid
|
|
153
|
+
def valid?
|
|
154
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
155
|
+
return false if @attachment_id.nil?
|
|
156
|
+
return false if @attachment_id !~ Regexp.new(/^att_[a-z0-9]{24}$/)
|
|
157
|
+
return false if @content_type.nil?
|
|
158
|
+
return false if @expires_at.nil?
|
|
159
|
+
return false if @filename.nil?
|
|
160
|
+
return false if @size_bytes.nil?
|
|
161
|
+
true
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Custom attribute writer method with validation
|
|
165
|
+
# @param [Object] attachment_id Value to be assigned
|
|
166
|
+
def attachment_id=(attachment_id)
|
|
167
|
+
if attachment_id.nil?
|
|
168
|
+
fail ArgumentError, 'attachment_id cannot be nil'
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
pattern = Regexp.new(/^att_[a-z0-9]{24}$/)
|
|
172
|
+
if attachment_id !~ pattern
|
|
173
|
+
fail ArgumentError, "invalid value for \"attachment_id\", must conform to the pattern #{pattern}."
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
@attachment_id = attachment_id
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# Custom attribute writer method with validation
|
|
180
|
+
# @param [Object] content_type Value to be assigned
|
|
181
|
+
def content_type=(content_type)
|
|
182
|
+
if content_type.nil?
|
|
183
|
+
fail ArgumentError, 'content_type cannot be nil'
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
@content_type = content_type
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# Custom attribute writer method with validation
|
|
190
|
+
# @param [Object] expires_at Value to be assigned
|
|
191
|
+
def expires_at=(expires_at)
|
|
192
|
+
if expires_at.nil?
|
|
193
|
+
fail ArgumentError, 'expires_at cannot be nil'
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
@expires_at = expires_at
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Custom attribute writer method with validation
|
|
200
|
+
# @param [Object] filename Value to be assigned
|
|
201
|
+
def filename=(filename)
|
|
202
|
+
if filename.nil?
|
|
203
|
+
fail ArgumentError, 'filename cannot be nil'
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
@filename = filename
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Custom attribute writer method with validation
|
|
210
|
+
# @param [Object] size_bytes Value to be assigned
|
|
211
|
+
def size_bytes=(size_bytes)
|
|
212
|
+
if size_bytes.nil?
|
|
213
|
+
fail ArgumentError, 'size_bytes cannot be nil'
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
@size_bytes = size_bytes
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
# Checks equality by comparing each attribute.
|
|
220
|
+
# @param [Object] Object to be compared
|
|
221
|
+
def ==(o)
|
|
222
|
+
return true if self.equal?(o)
|
|
223
|
+
self.class == o.class &&
|
|
224
|
+
attachment_id == o.attachment_id &&
|
|
225
|
+
content_type == o.content_type &&
|
|
226
|
+
expires_at == o.expires_at &&
|
|
227
|
+
filename == o.filename &&
|
|
228
|
+
size_bytes == o.size_bytes
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
# @see the `==` method
|
|
232
|
+
# @param [Object] Object to be compared
|
|
233
|
+
def eql?(o)
|
|
234
|
+
self == o
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Calculates hash code according to all attributes.
|
|
238
|
+
# @return [Integer] Hash code
|
|
239
|
+
def hash
|
|
240
|
+
[attachment_id, content_type, expires_at, filename, size_bytes].hash
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
# Builds the object from hash
|
|
244
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
245
|
+
# @return [Object] Returns the model itself
|
|
246
|
+
def self.build_from_hash(attributes)
|
|
247
|
+
return nil unless attributes.is_a?(Hash)
|
|
248
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
249
|
+
transformed_hash = {}
|
|
250
|
+
openapi_types.each_pair do |key, type|
|
|
251
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
252
|
+
transformed_hash["#{key}"] = nil
|
|
253
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
254
|
+
# check to ensure the input is an array given that the attribute
|
|
255
|
+
# is documented as an array but the input is not
|
|
256
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
257
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
258
|
+
end
|
|
259
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
260
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
new(transformed_hash)
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
# Returns the object in the form of hash
|
|
267
|
+
# @return [Hash] Returns the object in the form of hash
|
|
268
|
+
def to_hash
|
|
269
|
+
hash = {}
|
|
270
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
271
|
+
value = self.send(attr)
|
|
272
|
+
if value.nil?
|
|
273
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
274
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
hash[param] = _to_hash(value)
|
|
278
|
+
end
|
|
279
|
+
hash
|
|
280
|
+
end
|
|
281
|
+
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
end
|