unsent 1.0.0 → 1.0.2
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/LICENSE.txt +1 -1
- data/README.md +273 -2
- data/lib/unsent/analytics.rb +30 -0
- data/lib/unsent/api_keys.rb +21 -0
- data/lib/unsent/campaigns.rb +4 -0
- data/lib/unsent/client.rb +24 -12
- data/lib/unsent/contact_books.rb +29 -0
- data/lib/unsent/contacts.rb +11 -0
- data/lib/unsent/emails.rb +59 -6
- data/lib/unsent/errors.rb +2 -0
- data/lib/unsent/models/add_suppression_request.rb +223 -0
- data/lib/unsent/models/create_api_key_request.rb +218 -0
- data/lib/unsent/models/create_campaign200_response.rb +750 -0
- data/lib/unsent/models/create_campaign_request.rb +426 -0
- data/lib/unsent/models/create_campaign_request_reply_to.rb +103 -0
- data/lib/unsent/models/create_contact200_response.rb +147 -0
- data/lib/unsent/models/create_contact_book200_response.rb +304 -0
- data/lib/unsent/models/create_contact_book_request.rb +193 -0
- data/lib/unsent/models/create_contact_request.rb +202 -0
- data/lib/unsent/models/create_domain_request.rb +190 -0
- data/lib/unsent/models/create_template200_response.rb +164 -0
- data/lib/unsent/models/create_template_request.rb +226 -0
- data/lib/unsent/models/delete_contact_book200_response.rb +164 -0
- data/lib/unsent/models/get_api_keys200_response_inner.rb +278 -0
- data/lib/unsent/models/get_campaigns200_response_inner.rb +296 -0
- data/lib/unsent/models/get_contact_book200_response.rb +330 -0
- data/lib/unsent/models/get_contact_book200_response_details.rb +218 -0
- data/lib/unsent/models/get_domains200_response_inner.rb +482 -0
- data/lib/unsent/models/get_domains200_response_inner_dns_records_inner.rb +318 -0
- data/lib/unsent/models/get_health200_response.rb +216 -0
- data/lib/unsent/models/get_templates200_response_inner.rb +314 -0
- data/lib/unsent/models/list_emails_domain_id_parameter.rb +103 -0
- data/lib/unsent/models/schedule_campaign_request.rb +185 -0
- data/lib/unsent/models/send_email_request.rb +378 -0
- data/lib/unsent/models/send_email_request_to.rb +103 -0
- data/lib/unsent/models/update_contact_book200_response.rb +190 -0
- data/lib/unsent/models/update_contact_book_request.rb +167 -0
- data/lib/unsent/models/update_contact_request.rb +176 -0
- data/lib/unsent/models/update_template_request.rb +174 -0
- data/lib/unsent/settings.rb +13 -0
- data/lib/unsent/suppressions.rb +28 -0
- data/lib/unsent/templates.rb +29 -0
- data/lib/unsent/version.rb +1 -1
- data/lib/unsent/webhooks.rb +25 -0
- data/lib/unsent.rb +7 -0
- metadata +38 -2
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Unsent API
|
|
3
|
+
|
|
4
|
+
#API for Unsent.dev
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
Contact: support@unsent.dev
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.18.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module Unsent
|
|
17
|
+
class SendEmailRequest < ApiModelBase
|
|
18
|
+
attr_accessor :to
|
|
19
|
+
|
|
20
|
+
attr_accessor :from
|
|
21
|
+
|
|
22
|
+
# Optional when templateId is provided
|
|
23
|
+
attr_accessor :subject
|
|
24
|
+
|
|
25
|
+
# ID of a template from the dashboard
|
|
26
|
+
attr_accessor :template_id
|
|
27
|
+
|
|
28
|
+
attr_accessor :variables
|
|
29
|
+
|
|
30
|
+
attr_accessor :reply_to
|
|
31
|
+
|
|
32
|
+
attr_accessor :cc
|
|
33
|
+
|
|
34
|
+
attr_accessor :bcc
|
|
35
|
+
|
|
36
|
+
attr_accessor :text
|
|
37
|
+
|
|
38
|
+
attr_accessor :html
|
|
39
|
+
|
|
40
|
+
# Custom headers to included with the emails
|
|
41
|
+
attr_accessor :headers
|
|
42
|
+
|
|
43
|
+
attr_accessor :attachments
|
|
44
|
+
|
|
45
|
+
attr_accessor :scheduled_at
|
|
46
|
+
|
|
47
|
+
attr_accessor :in_reply_to_id
|
|
48
|
+
|
|
49
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
50
|
+
def self.attribute_map
|
|
51
|
+
{
|
|
52
|
+
:'to' => :'to',
|
|
53
|
+
:'from' => :'from',
|
|
54
|
+
:'subject' => :'subject',
|
|
55
|
+
:'template_id' => :'templateId',
|
|
56
|
+
:'variables' => :'variables',
|
|
57
|
+
:'reply_to' => :'replyTo',
|
|
58
|
+
:'cc' => :'cc',
|
|
59
|
+
:'bcc' => :'bcc',
|
|
60
|
+
:'text' => :'text',
|
|
61
|
+
:'html' => :'html',
|
|
62
|
+
:'headers' => :'headers',
|
|
63
|
+
:'attachments' => :'attachments',
|
|
64
|
+
:'scheduled_at' => :'scheduledAt',
|
|
65
|
+
:'in_reply_to_id' => :'inReplyToId'
|
|
66
|
+
}
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Returns attribute mapping this model knows about
|
|
70
|
+
def self.acceptable_attribute_map
|
|
71
|
+
attribute_map
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Returns all the JSON keys this model knows about
|
|
75
|
+
def self.acceptable_attributes
|
|
76
|
+
acceptable_attribute_map.values
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Attribute type mapping.
|
|
80
|
+
def self.openapi_types
|
|
81
|
+
{
|
|
82
|
+
:'to' => :'SendEmailRequestTo',
|
|
83
|
+
:'from' => :'String',
|
|
84
|
+
:'subject' => :'String',
|
|
85
|
+
:'template_id' => :'String',
|
|
86
|
+
:'variables' => :'Hash<String, String>',
|
|
87
|
+
:'reply_to' => :'SendEmailRequestTo',
|
|
88
|
+
:'cc' => :'SendEmailRequestTo',
|
|
89
|
+
:'bcc' => :'SendEmailRequestTo',
|
|
90
|
+
:'text' => :'String',
|
|
91
|
+
:'html' => :'String',
|
|
92
|
+
:'headers' => :'Hash<String, String>',
|
|
93
|
+
:'attachments' => :'Array<Object>',
|
|
94
|
+
:'scheduled_at' => :'Time',
|
|
95
|
+
:'in_reply_to_id' => :'String'
|
|
96
|
+
}
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# List of attributes with nullable: true
|
|
100
|
+
def self.openapi_nullable
|
|
101
|
+
Set.new([
|
|
102
|
+
:'text',
|
|
103
|
+
:'html',
|
|
104
|
+
:'in_reply_to_id'
|
|
105
|
+
])
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Initializes the object
|
|
109
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
110
|
+
def initialize(attributes = {})
|
|
111
|
+
if (!attributes.is_a?(Hash))
|
|
112
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Unsent::SendEmailRequest` initialize method"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
116
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
117
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
118
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
119
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Unsent::SendEmailRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
120
|
+
end
|
|
121
|
+
h[k.to_sym] = v
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if attributes.key?(:'to')
|
|
125
|
+
self.to = attributes[:'to']
|
|
126
|
+
else
|
|
127
|
+
self.to = nil
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
if attributes.key?(:'from')
|
|
131
|
+
self.from = attributes[:'from']
|
|
132
|
+
else
|
|
133
|
+
self.from = nil
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
if attributes.key?(:'subject')
|
|
137
|
+
self.subject = attributes[:'subject']
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
if attributes.key?(:'template_id')
|
|
141
|
+
self.template_id = attributes[:'template_id']
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
if attributes.key?(:'variables')
|
|
145
|
+
if (value = attributes[:'variables']).is_a?(Hash)
|
|
146
|
+
self.variables = value
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
if attributes.key?(:'reply_to')
|
|
151
|
+
self.reply_to = attributes[:'reply_to']
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
if attributes.key?(:'cc')
|
|
155
|
+
self.cc = attributes[:'cc']
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
if attributes.key?(:'bcc')
|
|
159
|
+
self.bcc = attributes[:'bcc']
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
if attributes.key?(:'text')
|
|
163
|
+
self.text = attributes[:'text']
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
if attributes.key?(:'html')
|
|
167
|
+
self.html = attributes[:'html']
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
if attributes.key?(:'headers')
|
|
171
|
+
if (value = attributes[:'headers']).is_a?(Hash)
|
|
172
|
+
self.headers = value
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
if attributes.key?(:'attachments')
|
|
177
|
+
if (value = attributes[:'attachments']).is_a?(Array)
|
|
178
|
+
self.attachments = value
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
if attributes.key?(:'scheduled_at')
|
|
183
|
+
self.scheduled_at = attributes[:'scheduled_at']
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
if attributes.key?(:'in_reply_to_id')
|
|
187
|
+
self.in_reply_to_id = attributes[:'in_reply_to_id']
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
192
|
+
# @return Array for valid properties with the reasons
|
|
193
|
+
def list_invalid_properties
|
|
194
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
195
|
+
invalid_properties = Array.new
|
|
196
|
+
if @to.nil?
|
|
197
|
+
invalid_properties.push('invalid value for "to", to cannot be nil.')
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
if @from.nil?
|
|
201
|
+
invalid_properties.push('invalid value for "from", from cannot be nil.')
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
if !@subject.nil? && @subject.to_s.length < 1
|
|
205
|
+
invalid_properties.push('invalid value for "subject", the character length must be greater than or equal to 1.')
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
if !@text.nil? && @text.to_s.length < 1
|
|
209
|
+
invalid_properties.push('invalid value for "text", the character length must be greater than or equal to 1.')
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
if !@html.nil? && @html.to_s.length < 1
|
|
213
|
+
invalid_properties.push('invalid value for "html", the character length must be greater than or equal to 1.')
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
if !@attachments.nil? && @attachments.length > 10
|
|
217
|
+
invalid_properties.push('invalid value for "attachments", number of items must be less than or equal to 10.')
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
invalid_properties
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# Check to see if the all the properties in the model are valid
|
|
224
|
+
# @return true if the model is valid
|
|
225
|
+
def valid?
|
|
226
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
227
|
+
return false if @to.nil?
|
|
228
|
+
return false if @from.nil?
|
|
229
|
+
return false if !@subject.nil? && @subject.to_s.length < 1
|
|
230
|
+
return false if !@text.nil? && @text.to_s.length < 1
|
|
231
|
+
return false if !@html.nil? && @html.to_s.length < 1
|
|
232
|
+
return false if !@attachments.nil? && @attachments.length > 10
|
|
233
|
+
true
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
# Custom attribute writer method with validation
|
|
237
|
+
# @param [Object] to Value to be assigned
|
|
238
|
+
def to=(to)
|
|
239
|
+
if to.nil?
|
|
240
|
+
fail ArgumentError, 'to cannot be nil'
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
@to = to
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
# Custom attribute writer method with validation
|
|
247
|
+
# @param [Object] from Value to be assigned
|
|
248
|
+
def from=(from)
|
|
249
|
+
if from.nil?
|
|
250
|
+
fail ArgumentError, 'from cannot be nil'
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
@from = from
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
# Custom attribute writer method with validation
|
|
257
|
+
# @param [Object] subject Value to be assigned
|
|
258
|
+
def subject=(subject)
|
|
259
|
+
if subject.nil?
|
|
260
|
+
fail ArgumentError, 'subject cannot be nil'
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
if subject.to_s.length < 1
|
|
264
|
+
fail ArgumentError, 'invalid value for "subject", the character length must be greater than or equal to 1.'
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
@subject = subject
|
|
268
|
+
end
|
|
269
|
+
|
|
270
|
+
# Custom attribute writer method with validation
|
|
271
|
+
# @param [Object] text Value to be assigned
|
|
272
|
+
def text=(text)
|
|
273
|
+
if !text.nil? && text.to_s.length < 1
|
|
274
|
+
fail ArgumentError, 'invalid value for "text", the character length must be greater than or equal to 1.'
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
@text = text
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
# Custom attribute writer method with validation
|
|
281
|
+
# @param [Object] html Value to be assigned
|
|
282
|
+
def html=(html)
|
|
283
|
+
if !html.nil? && html.to_s.length < 1
|
|
284
|
+
fail ArgumentError, 'invalid value for "html", the character length must be greater than or equal to 1.'
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
@html = html
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
# Custom attribute writer method with validation
|
|
291
|
+
# @param [Object] attachments Value to be assigned
|
|
292
|
+
def attachments=(attachments)
|
|
293
|
+
if attachments.nil?
|
|
294
|
+
fail ArgumentError, 'attachments cannot be nil'
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
if attachments.length > 10
|
|
298
|
+
fail ArgumentError, 'invalid value for "attachments", number of items must be less than or equal to 10.'
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
@attachments = attachments
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
# Checks equality by comparing each attribute.
|
|
305
|
+
# @param [Object] Object to be compared
|
|
306
|
+
def ==(o)
|
|
307
|
+
return true if self.equal?(o)
|
|
308
|
+
self.class == o.class &&
|
|
309
|
+
to == o.to &&
|
|
310
|
+
from == o.from &&
|
|
311
|
+
subject == o.subject &&
|
|
312
|
+
template_id == o.template_id &&
|
|
313
|
+
variables == o.variables &&
|
|
314
|
+
reply_to == o.reply_to &&
|
|
315
|
+
cc == o.cc &&
|
|
316
|
+
bcc == o.bcc &&
|
|
317
|
+
text == o.text &&
|
|
318
|
+
html == o.html &&
|
|
319
|
+
headers == o.headers &&
|
|
320
|
+
attachments == o.attachments &&
|
|
321
|
+
scheduled_at == o.scheduled_at &&
|
|
322
|
+
in_reply_to_id == o.in_reply_to_id
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
# @see the `==` method
|
|
326
|
+
# @param [Object] Object to be compared
|
|
327
|
+
def eql?(o)
|
|
328
|
+
self == o
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
# Calculates hash code according to all attributes.
|
|
332
|
+
# @return [Integer] Hash code
|
|
333
|
+
def hash
|
|
334
|
+
[to, from, subject, template_id, variables, reply_to, cc, bcc, text, html, headers, attachments, scheduled_at, in_reply_to_id].hash
|
|
335
|
+
end
|
|
336
|
+
|
|
337
|
+
# Builds the object from hash
|
|
338
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
339
|
+
# @return [Object] Returns the model itself
|
|
340
|
+
def self.build_from_hash(attributes)
|
|
341
|
+
return nil unless attributes.is_a?(Hash)
|
|
342
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
343
|
+
transformed_hash = {}
|
|
344
|
+
openapi_types.each_pair do |key, type|
|
|
345
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
346
|
+
transformed_hash["#{key}"] = nil
|
|
347
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
348
|
+
# check to ensure the input is an array given that the attribute
|
|
349
|
+
# is documented as an array but the input is not
|
|
350
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
351
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
352
|
+
end
|
|
353
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
354
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
355
|
+
end
|
|
356
|
+
end
|
|
357
|
+
new(transformed_hash)
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
# Returns the object in the form of hash
|
|
361
|
+
# @return [Hash] Returns the object in the form of hash
|
|
362
|
+
def to_hash
|
|
363
|
+
hash = {}
|
|
364
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
365
|
+
value = self.send(attr)
|
|
366
|
+
if value.nil?
|
|
367
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
368
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
hash[param] = _to_hash(value)
|
|
372
|
+
end
|
|
373
|
+
hash
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Unsent API
|
|
3
|
+
|
|
4
|
+
#API for Unsent.dev
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
Contact: support@unsent.dev
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.18.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module Unsent
|
|
17
|
+
module SendEmailRequestTo
|
|
18
|
+
class << self
|
|
19
|
+
# List of class defined in anyOf (OpenAPI v3)
|
|
20
|
+
def openapi_any_of
|
|
21
|
+
[
|
|
22
|
+
:'Array<String>',
|
|
23
|
+
:'String'
|
|
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
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
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 = Unsent.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
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
raise # if no match by now, raise
|
|
97
|
+
rescue
|
|
98
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
end
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Unsent API
|
|
3
|
+
|
|
4
|
+
#API for Unsent.dev
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
|
7
|
+
Contact: support@unsent.dev
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.18.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module Unsent
|
|
17
|
+
class UpdateContactBook200Response < ApiModelBase
|
|
18
|
+
attr_accessor :id
|
|
19
|
+
|
|
20
|
+
attr_accessor :name
|
|
21
|
+
|
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
23
|
+
def self.attribute_map
|
|
24
|
+
{
|
|
25
|
+
:'id' => :'id',
|
|
26
|
+
:'name' => :'name'
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Returns attribute mapping this model knows about
|
|
31
|
+
def self.acceptable_attribute_map
|
|
32
|
+
attribute_map
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Returns all the JSON keys this model knows about
|
|
36
|
+
def self.acceptable_attributes
|
|
37
|
+
acceptable_attribute_map.values
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Attribute type mapping.
|
|
41
|
+
def self.openapi_types
|
|
42
|
+
{
|
|
43
|
+
:'id' => :'String',
|
|
44
|
+
:'name' => :'String'
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# List of attributes with nullable: true
|
|
49
|
+
def self.openapi_nullable
|
|
50
|
+
Set.new([
|
|
51
|
+
])
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Initializes the object
|
|
55
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
56
|
+
def initialize(attributes = {})
|
|
57
|
+
if (!attributes.is_a?(Hash))
|
|
58
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Unsent::UpdateContactBook200Response` initialize method"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
62
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
63
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
64
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
65
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Unsent::UpdateContactBook200Response`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
66
|
+
end
|
|
67
|
+
h[k.to_sym] = v
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if attributes.key?(:'id')
|
|
71
|
+
self.id = attributes[:'id']
|
|
72
|
+
else
|
|
73
|
+
self.id = nil
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
if attributes.key?(:'name')
|
|
77
|
+
self.name = attributes[:'name']
|
|
78
|
+
else
|
|
79
|
+
self.name = nil
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
84
|
+
# @return Array for valid properties with the reasons
|
|
85
|
+
def list_invalid_properties
|
|
86
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
87
|
+
invalid_properties = Array.new
|
|
88
|
+
if @id.nil?
|
|
89
|
+
invalid_properties.push('invalid value for "id", id cannot be nil.')
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
if @name.nil?
|
|
93
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
invalid_properties
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Check to see if the all the properties in the model are valid
|
|
100
|
+
# @return true if the model is valid
|
|
101
|
+
def valid?
|
|
102
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
103
|
+
return false if @id.nil?
|
|
104
|
+
return false if @name.nil?
|
|
105
|
+
true
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Custom attribute writer method with validation
|
|
109
|
+
# @param [Object] id Value to be assigned
|
|
110
|
+
def id=(id)
|
|
111
|
+
if id.nil?
|
|
112
|
+
fail ArgumentError, 'id cannot be nil'
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
@id = id
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Custom attribute writer method with validation
|
|
119
|
+
# @param [Object] name Value to be assigned
|
|
120
|
+
def name=(name)
|
|
121
|
+
if name.nil?
|
|
122
|
+
fail ArgumentError, 'name cannot be nil'
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
@name = name
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Checks equality by comparing each attribute.
|
|
129
|
+
# @param [Object] Object to be compared
|
|
130
|
+
def ==(o)
|
|
131
|
+
return true if self.equal?(o)
|
|
132
|
+
self.class == o.class &&
|
|
133
|
+
id == o.id &&
|
|
134
|
+
name == o.name
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# @see the `==` method
|
|
138
|
+
# @param [Object] Object to be compared
|
|
139
|
+
def eql?(o)
|
|
140
|
+
self == o
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Calculates hash code according to all attributes.
|
|
144
|
+
# @return [Integer] Hash code
|
|
145
|
+
def hash
|
|
146
|
+
[id, name].hash
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Builds the object from hash
|
|
150
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
151
|
+
# @return [Object] Returns the model itself
|
|
152
|
+
def self.build_from_hash(attributes)
|
|
153
|
+
return nil unless attributes.is_a?(Hash)
|
|
154
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
155
|
+
transformed_hash = {}
|
|
156
|
+
openapi_types.each_pair do |key, type|
|
|
157
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
158
|
+
transformed_hash["#{key}"] = nil
|
|
159
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
160
|
+
# check to ensure the input is an array given that the attribute
|
|
161
|
+
# is documented as an array but the input is not
|
|
162
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
163
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
164
|
+
end
|
|
165
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
166
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
new(transformed_hash)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# Returns the object in the form of hash
|
|
173
|
+
# @return [Hash] Returns the object in the form of hash
|
|
174
|
+
def to_hash
|
|
175
|
+
hash = {}
|
|
176
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
177
|
+
value = self.send(attr)
|
|
178
|
+
if value.nil?
|
|
179
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
180
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
hash[param] = _to_hash(value)
|
|
184
|
+
end
|
|
185
|
+
hash
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
end
|