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