sendx-ruby-sdk 1.0.1

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 (61) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +156 -0
  3. data/lib/sendx-ruby-sdk/api/campaign_api.rb +356 -0
  4. data/lib/sendx-ruby-sdk/api/contact_api.rb +426 -0
  5. data/lib/sendx-ruby-sdk/api/list_api.rb +356 -0
  6. data/lib/sendx-ruby-sdk/api/reports_api.rb +88 -0
  7. data/lib/sendx-ruby-sdk/api/sender_api.rb +156 -0
  8. data/lib/sendx-ruby-sdk/api/tags_api.rb +356 -0
  9. data/lib/sendx-ruby-sdk/api_client.rb +394 -0
  10. data/lib/sendx-ruby-sdk/api_error.rb +58 -0
  11. data/lib/sendx-ruby-sdk/configuration.rb +316 -0
  12. data/lib/sendx-ruby-sdk/models/campaign.rb +483 -0
  13. data/lib/sendx-ruby-sdk/models/campaign_dashboard_data.rb +255 -0
  14. data/lib/sendx-ruby-sdk/models/campaign_request.rb +441 -0
  15. data/lib/sendx-ruby-sdk/models/contact.rb +425 -0
  16. data/lib/sendx-ruby-sdk/models/contact_request.rb +292 -0
  17. data/lib/sendx-ruby-sdk/models/create_response.rb +232 -0
  18. data/lib/sendx-ruby-sdk/models/dashboard_stats.rb +234 -0
  19. data/lib/sendx-ruby-sdk/models/delete_campaign200_response.rb +225 -0
  20. data/lib/sendx-ruby-sdk/models/delete_request.rb +215 -0
  21. data/lib/sendx-ruby-sdk/models/delete_response.rb +223 -0
  22. data/lib/sendx-ruby-sdk/models/last_sent_campaign_stat.rb +284 -0
  23. data/lib/sendx-ruby-sdk/models/list_model.rb +410 -0
  24. data/lib/sendx-ruby-sdk/models/list_request.rb +379 -0
  25. data/lib/sendx-ruby-sdk/models/report_data.rb +358 -0
  26. data/lib/sendx-ruby-sdk/models/response.rb +235 -0
  27. data/lib/sendx-ruby-sdk/models/sender.rb +256 -0
  28. data/lib/sendx-ruby-sdk/models/sender_request.rb +239 -0
  29. data/lib/sendx-ruby-sdk/models/sender_response.rb +273 -0
  30. data/lib/sendx-ruby-sdk/models/tag.rb +241 -0
  31. data/lib/sendx-ruby-sdk/models/tag_request.rb +214 -0
  32. data/lib/sendx-ruby-sdk/version.rb +15 -0
  33. data/lib/sendx-ruby-sdk.rb +65 -0
  34. data/spec/api/campaign_api_spec.rb +98 -0
  35. data/spec/api/contact_api_spec.rb +111 -0
  36. data/spec/api/list_api_spec.rb +98 -0
  37. data/spec/api/reports_api_spec.rb +48 -0
  38. data/spec/api/sender_api_spec.rb +61 -0
  39. data/spec/api/tags_api_spec.rb +98 -0
  40. data/spec/models/campaign_dashboard_data_spec.rb +60 -0
  41. data/spec/models/campaign_request_spec.rb +148 -0
  42. data/spec/models/campaign_spec.rb +170 -0
  43. data/spec/models/contact_request_spec.rb +78 -0
  44. data/spec/models/contact_spec.rb +142 -0
  45. data/spec/models/create_response_spec.rb +48 -0
  46. data/spec/models/dashboard_stats_spec.rb +48 -0
  47. data/spec/models/delete_campaign200_response_spec.rb +42 -0
  48. data/spec/models/delete_request_spec.rb +36 -0
  49. data/spec/models/delete_response_spec.rb +42 -0
  50. data/spec/models/last_sent_campaign_stat_spec.rb +78 -0
  51. data/spec/models/list_model_spec.rb +136 -0
  52. data/spec/models/list_request_spec.rb +118 -0
  53. data/spec/models/report_data_spec.rb +120 -0
  54. data/spec/models/response_spec.rb +48 -0
  55. data/spec/models/sender_request_spec.rb +42 -0
  56. data/spec/models/sender_response_spec.rb +54 -0
  57. data/spec/models/sender_spec.rb +48 -0
  58. data/spec/models/tag_request_spec.rb +36 -0
  59. data/spec/models/tag_spec.rb +54 -0
  60. data/spec/spec_helper.rb +111 -0
  61. metadata +171 -0
@@ -0,0 +1,425 @@
1
+ =begin
2
+ #SendX REST API
3
+
4
+ ## Introduction SendX is an email marketing product. It helps you convert website visitors to customers, send them promotional emails, engage with them using drip sequences and craft custom journeys using powerful but simple automations. The SendX API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs. The SendX Rest API doesn’t support bulk updates. You can work on only one object per request. <br>
5
+
6
+ The version of the OpenAPI document: 1.0.1
7
+ Contact: support@sendx.io
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.8.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module SendX
17
+ class Contact
18
+ # Identifier for the contact.
19
+ attr_accessor :id
20
+
21
+ # The first name of the contact.
22
+ attr_accessor :first_name
23
+
24
+ # The last name of the contact.
25
+ attr_accessor :last_name
26
+
27
+ # The email address of the contact.
28
+ attr_accessor :email
29
+
30
+ # The company of the contact.
31
+ attr_accessor :company
32
+
33
+ # Custom fields and their values
34
+ attr_accessor :custom_fields
35
+
36
+ # Indicates if the contact has unsubscribed from emails.
37
+ attr_accessor :unsubscribed
38
+
39
+ # Indicates if the contact's email has bounced.
40
+ attr_accessor :bounced
41
+
42
+ # Indicates if the contact marked the email as spam.
43
+ attr_accessor :spam
44
+
45
+ # The date and time when the contact was created.
46
+ attr_accessor :created
47
+
48
+ # The date and time when the contact was last updated.
49
+ attr_accessor :updated
50
+
51
+ # Indicates if the contact is blocked from receiving emails.
52
+ attr_accessor :blocked
53
+
54
+ # Indicates if emails to this contact were dropped.
55
+ attr_accessor :dropped
56
+
57
+ # Lifetime value (LTV) of the contact in currency units.
58
+ attr_accessor :ltv
59
+
60
+ # The source from which the contact was added. Possible values:
61
+ attr_accessor :contact_source
62
+
63
+ # The last known IP address tracked for the contact.
64
+ attr_accessor :last_tracked_ip
65
+
66
+ # A list of `lists` ids the contact is subscribed to.
67
+ attr_accessor :lists
68
+
69
+ # `Tag` ids associated with the contact for segmentation or categorization.
70
+ attr_accessor :tags
71
+
72
+ class EnumAttributeValidator
73
+ attr_reader :datatype
74
+ attr_reader :allowable_values
75
+
76
+ def initialize(datatype, allowable_values)
77
+ @allowable_values = allowable_values.map do |value|
78
+ case datatype.to_s
79
+ when /Integer/i
80
+ value.to_i
81
+ when /Float/i
82
+ value.to_f
83
+ else
84
+ value
85
+ end
86
+ end
87
+ end
88
+
89
+ def valid?(value)
90
+ !value || allowable_values.include?(value)
91
+ end
92
+ end
93
+
94
+ # Attribute mapping from ruby-style variable name to JSON key.
95
+ def self.attribute_map
96
+ {
97
+ :'id' => :'id',
98
+ :'first_name' => :'firstName',
99
+ :'last_name' => :'lastName',
100
+ :'email' => :'email',
101
+ :'company' => :'company',
102
+ :'custom_fields' => :'customFields',
103
+ :'unsubscribed' => :'unsubscribed',
104
+ :'bounced' => :'bounced',
105
+ :'spam' => :'spam',
106
+ :'created' => :'created',
107
+ :'updated' => :'updated',
108
+ :'blocked' => :'blocked',
109
+ :'dropped' => :'dropped',
110
+ :'ltv' => :'LTV',
111
+ :'contact_source' => :'contactSource',
112
+ :'last_tracked_ip' => :'lastTrackedIp',
113
+ :'lists' => :'lists',
114
+ :'tags' => :'tags'
115
+ }
116
+ end
117
+
118
+ # Returns all the JSON keys this model knows about
119
+ def self.acceptable_attributes
120
+ attribute_map.values
121
+ end
122
+
123
+ # Attribute type mapping.
124
+ def self.openapi_types
125
+ {
126
+ :'id' => :'String',
127
+ :'first_name' => :'String',
128
+ :'last_name' => :'String',
129
+ :'email' => :'String',
130
+ :'company' => :'String',
131
+ :'custom_fields' => :'Hash<String, String>',
132
+ :'unsubscribed' => :'Boolean',
133
+ :'bounced' => :'Boolean',
134
+ :'spam' => :'Boolean',
135
+ :'created' => :'Time',
136
+ :'updated' => :'Time',
137
+ :'blocked' => :'Boolean',
138
+ :'dropped' => :'Boolean',
139
+ :'ltv' => :'Integer',
140
+ :'contact_source' => :'Integer',
141
+ :'last_tracked_ip' => :'String',
142
+ :'lists' => :'Array<String>',
143
+ :'tags' => :'Array<String>'
144
+ }
145
+ end
146
+
147
+ # List of attributes with nullable: true
148
+ def self.openapi_nullable
149
+ Set.new([
150
+ ])
151
+ end
152
+
153
+ # Initializes the object
154
+ # @param [Hash] attributes Model attributes in the form of hash
155
+ def initialize(attributes = {})
156
+ if (!attributes.is_a?(Hash))
157
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SendX::Contact` initialize method"
158
+ end
159
+
160
+ # check to see if the attribute exists and convert string to symbol for hash key
161
+ attributes = attributes.each_with_object({}) { |(k, v), h|
162
+ if (!self.class.attribute_map.key?(k.to_sym))
163
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SendX::Contact`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
164
+ end
165
+ h[k.to_sym] = v
166
+ }
167
+
168
+ if attributes.key?(:'id')
169
+ self.id = attributes[:'id']
170
+ end
171
+
172
+ if attributes.key?(:'first_name')
173
+ self.first_name = attributes[:'first_name']
174
+ end
175
+
176
+ if attributes.key?(:'last_name')
177
+ self.last_name = attributes[:'last_name']
178
+ end
179
+
180
+ if attributes.key?(:'email')
181
+ self.email = attributes[:'email']
182
+ end
183
+
184
+ if attributes.key?(:'company')
185
+ self.company = attributes[:'company']
186
+ end
187
+
188
+ if attributes.key?(:'custom_fields')
189
+ if (value = attributes[:'custom_fields']).is_a?(Hash)
190
+ self.custom_fields = value
191
+ end
192
+ end
193
+
194
+ if attributes.key?(:'unsubscribed')
195
+ self.unsubscribed = attributes[:'unsubscribed']
196
+ end
197
+
198
+ if attributes.key?(:'bounced')
199
+ self.bounced = attributes[:'bounced']
200
+ end
201
+
202
+ if attributes.key?(:'spam')
203
+ self.spam = attributes[:'spam']
204
+ end
205
+
206
+ if attributes.key?(:'created')
207
+ self.created = attributes[:'created']
208
+ end
209
+
210
+ if attributes.key?(:'updated')
211
+ self.updated = attributes[:'updated']
212
+ end
213
+
214
+ if attributes.key?(:'blocked')
215
+ self.blocked = attributes[:'blocked']
216
+ end
217
+
218
+ if attributes.key?(:'dropped')
219
+ self.dropped = attributes[:'dropped']
220
+ end
221
+
222
+ if attributes.key?(:'ltv')
223
+ self.ltv = attributes[:'ltv']
224
+ end
225
+
226
+ if attributes.key?(:'contact_source')
227
+ self.contact_source = attributes[:'contact_source']
228
+ end
229
+
230
+ if attributes.key?(:'last_tracked_ip')
231
+ self.last_tracked_ip = attributes[:'last_tracked_ip']
232
+ end
233
+
234
+ if attributes.key?(:'lists')
235
+ if (value = attributes[:'lists']).is_a?(Array)
236
+ self.lists = value
237
+ end
238
+ end
239
+
240
+ if attributes.key?(:'tags')
241
+ if (value = attributes[:'tags']).is_a?(Array)
242
+ self.tags = value
243
+ end
244
+ end
245
+ end
246
+
247
+ # Show invalid properties with the reasons. Usually used together with valid?
248
+ # @return Array for valid properties with the reasons
249
+ def list_invalid_properties
250
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
251
+ invalid_properties = Array.new
252
+ invalid_properties
253
+ end
254
+
255
+ # Check to see if the all the properties in the model are valid
256
+ # @return true if the model is valid
257
+ def valid?
258
+ warn '[DEPRECATED] the `valid?` method is obsolete'
259
+ contact_source_validator = EnumAttributeValidator.new('Integer', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])
260
+ return false unless contact_source_validator.valid?(@contact_source)
261
+ true
262
+ end
263
+
264
+ # Custom attribute writer method checking allowed values (enum).
265
+ # @param [Object] contact_source Object to be assigned
266
+ def contact_source=(contact_source)
267
+ validator = EnumAttributeValidator.new('Integer', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19])
268
+ unless validator.valid?(contact_source)
269
+ fail ArgumentError, "invalid value for \"contact_source\", must be one of #{validator.allowable_values}."
270
+ end
271
+ @contact_source = contact_source
272
+ end
273
+
274
+ # Checks equality by comparing each attribute.
275
+ # @param [Object] Object to be compared
276
+ def ==(o)
277
+ return true if self.equal?(o)
278
+ self.class == o.class &&
279
+ id == o.id &&
280
+ first_name == o.first_name &&
281
+ last_name == o.last_name &&
282
+ email == o.email &&
283
+ company == o.company &&
284
+ custom_fields == o.custom_fields &&
285
+ unsubscribed == o.unsubscribed &&
286
+ bounced == o.bounced &&
287
+ spam == o.spam &&
288
+ created == o.created &&
289
+ updated == o.updated &&
290
+ blocked == o.blocked &&
291
+ dropped == o.dropped &&
292
+ ltv == o.ltv &&
293
+ contact_source == o.contact_source &&
294
+ last_tracked_ip == o.last_tracked_ip &&
295
+ lists == o.lists &&
296
+ tags == o.tags
297
+ end
298
+
299
+ # @see the `==` method
300
+ # @param [Object] Object to be compared
301
+ def eql?(o)
302
+ self == o
303
+ end
304
+
305
+ # Calculates hash code according to all attributes.
306
+ # @return [Integer] Hash code
307
+ def hash
308
+ [id, first_name, last_name, email, company, custom_fields, unsubscribed, bounced, spam, created, updated, blocked, dropped, ltv, contact_source, last_tracked_ip, lists, tags].hash
309
+ end
310
+
311
+ # Builds the object from hash
312
+ # @param [Hash] attributes Model attributes in the form of hash
313
+ # @return [Object] Returns the model itself
314
+ def self.build_from_hash(attributes)
315
+ return nil unless attributes.is_a?(Hash)
316
+ attributes = attributes.transform_keys(&:to_sym)
317
+ transformed_hash = {}
318
+ openapi_types.each_pair do |key, type|
319
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
320
+ transformed_hash["#{key}"] = nil
321
+ elsif type =~ /\AArray<(.*)>/i
322
+ # check to ensure the input is an array given that the attribute
323
+ # is documented as an array but the input is not
324
+ if attributes[attribute_map[key]].is_a?(Array)
325
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
326
+ end
327
+ elsif !attributes[attribute_map[key]].nil?
328
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
329
+ end
330
+ end
331
+ new(transformed_hash)
332
+ end
333
+
334
+ # Deserializes the data based on type
335
+ # @param string type Data type
336
+ # @param string value Value to be deserialized
337
+ # @return [Object] Deserialized data
338
+ def self._deserialize(type, value)
339
+ case type.to_sym
340
+ when :Time
341
+ Time.parse(value)
342
+ when :Date
343
+ Date.parse(value)
344
+ when :String
345
+ value.to_s
346
+ when :Integer
347
+ value.to_i
348
+ when :Float
349
+ value.to_f
350
+ when :Boolean
351
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
352
+ true
353
+ else
354
+ false
355
+ end
356
+ when :Object
357
+ # generic object (usually a Hash), return directly
358
+ value
359
+ when /\AArray<(?<inner_type>.+)>\z/
360
+ inner_type = Regexp.last_match[:inner_type]
361
+ value.map { |v| _deserialize(inner_type, v) }
362
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
363
+ k_type = Regexp.last_match[:k_type]
364
+ v_type = Regexp.last_match[:v_type]
365
+ {}.tap do |hash|
366
+ value.each do |k, v|
367
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
368
+ end
369
+ end
370
+ else # model
371
+ # models (e.g. Pet) or oneOf
372
+ klass = SendX.const_get(type)
373
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
374
+ end
375
+ end
376
+
377
+ # Returns the string representation of the object
378
+ # @return [String] String presentation of the object
379
+ def to_s
380
+ to_hash.to_s
381
+ end
382
+
383
+ # to_body is an alias to to_hash (backward compatibility)
384
+ # @return [Hash] Returns the object in the form of hash
385
+ def to_body
386
+ to_hash
387
+ end
388
+
389
+ # Returns the object in the form of hash
390
+ # @return [Hash] Returns the object in the form of hash
391
+ def to_hash
392
+ hash = {}
393
+ self.class.attribute_map.each_pair do |attr, param|
394
+ value = self.send(attr)
395
+ if value.nil?
396
+ is_nullable = self.class.openapi_nullable.include?(attr)
397
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
398
+ end
399
+
400
+ hash[param] = _to_hash(value)
401
+ end
402
+ hash
403
+ end
404
+
405
+ # Outputs non-array value in the form of hash
406
+ # For object, use to_hash. Otherwise, just return the value
407
+ # @param [Object] value Any valid value
408
+ # @return [Hash] Returns the value in the form of hash
409
+ def _to_hash(value)
410
+ if value.is_a?(Array)
411
+ value.compact.map { |v| _to_hash(v) }
412
+ elsif value.is_a?(Hash)
413
+ {}.tap do |hash|
414
+ value.each { |k, v| hash[k] = _to_hash(v) }
415
+ end
416
+ elsif value.respond_to? :to_hash
417
+ value.to_hash
418
+ else
419
+ value
420
+ end
421
+ end
422
+
423
+ end
424
+
425
+ end
@@ -0,0 +1,292 @@
1
+ =begin
2
+ #SendX REST API
3
+
4
+ ## Introduction SendX is an email marketing product. It helps you convert website visitors to customers, send them promotional emails, engage with them using drip sequences and craft custom journeys using powerful but simple automations. The SendX API is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs. The SendX Rest API doesn’t support bulk updates. You can work on only one object per request. <br>
5
+
6
+ The version of the OpenAPI document: 1.0.1
7
+ Contact: support@sendx.io
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.8.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module SendX
17
+ # Schema for the contact request payload. Used for creating or updating a contact.
18
+ class ContactRequest
19
+ # The email address of the contact. Must be a valid email.
20
+ attr_accessor :email
21
+
22
+ # The first name of the contact.
23
+ attr_accessor :first_name
24
+
25
+ # The last name of the contact.
26
+ attr_accessor :last_name
27
+
28
+ # The company where the contact works.
29
+ attr_accessor :company
30
+
31
+ # The last known IP address of the contact.
32
+ attr_accessor :last_tracked_ip
33
+
34
+ # Custom fields specific to the contact, which may vary by account.
35
+ attr_accessor :custom_fields
36
+
37
+ # A list of `lists` ids the contact is subscribed to.
38
+ attr_accessor :lists
39
+
40
+ # Tag ids associated with the contact for segmentation or categorization.
41
+ attr_accessor :tags
42
+
43
+ # Attribute mapping from ruby-style variable name to JSON key.
44
+ def self.attribute_map
45
+ {
46
+ :'email' => :'email',
47
+ :'first_name' => :'firstName',
48
+ :'last_name' => :'lastName',
49
+ :'company' => :'company',
50
+ :'last_tracked_ip' => :'lastTrackedIp',
51
+ :'custom_fields' => :'customFields',
52
+ :'lists' => :'lists',
53
+ :'tags' => :'tags'
54
+ }
55
+ end
56
+
57
+ # Returns all the JSON keys this model knows about
58
+ def self.acceptable_attributes
59
+ attribute_map.values
60
+ end
61
+
62
+ # Attribute type mapping.
63
+ def self.openapi_types
64
+ {
65
+ :'email' => :'String',
66
+ :'first_name' => :'String',
67
+ :'last_name' => :'String',
68
+ :'company' => :'String',
69
+ :'last_tracked_ip' => :'String',
70
+ :'custom_fields' => :'Hash<String, String>',
71
+ :'lists' => :'Array<String>',
72
+ :'tags' => :'Array<String>'
73
+ }
74
+ end
75
+
76
+ # List of attributes with nullable: true
77
+ def self.openapi_nullable
78
+ Set.new([
79
+ ])
80
+ end
81
+
82
+ # Initializes the object
83
+ # @param [Hash] attributes Model attributes in the form of hash
84
+ def initialize(attributes = {})
85
+ if (!attributes.is_a?(Hash))
86
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SendX::ContactRequest` initialize method"
87
+ end
88
+
89
+ # check to see if the attribute exists and convert string to symbol for hash key
90
+ attributes = attributes.each_with_object({}) { |(k, v), h|
91
+ if (!self.class.attribute_map.key?(k.to_sym))
92
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SendX::ContactRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
93
+ end
94
+ h[k.to_sym] = v
95
+ }
96
+
97
+ if attributes.key?(:'email')
98
+ self.email = attributes[:'email']
99
+ end
100
+
101
+ if attributes.key?(:'first_name')
102
+ self.first_name = attributes[:'first_name']
103
+ end
104
+
105
+ if attributes.key?(:'last_name')
106
+ self.last_name = attributes[:'last_name']
107
+ end
108
+
109
+ if attributes.key?(:'company')
110
+ self.company = attributes[:'company']
111
+ end
112
+
113
+ if attributes.key?(:'last_tracked_ip')
114
+ self.last_tracked_ip = attributes[:'last_tracked_ip']
115
+ end
116
+
117
+ if attributes.key?(:'custom_fields')
118
+ if (value = attributes[:'custom_fields']).is_a?(Hash)
119
+ self.custom_fields = value
120
+ end
121
+ end
122
+
123
+ if attributes.key?(:'lists')
124
+ if (value = attributes[:'lists']).is_a?(Array)
125
+ self.lists = value
126
+ end
127
+ end
128
+
129
+ if attributes.key?(:'tags')
130
+ if (value = attributes[:'tags']).is_a?(Array)
131
+ self.tags = value
132
+ end
133
+ end
134
+ end
135
+
136
+ # Show invalid properties with the reasons. Usually used together with valid?
137
+ # @return Array for valid properties with the reasons
138
+ def list_invalid_properties
139
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
140
+ invalid_properties = Array.new
141
+ invalid_properties
142
+ end
143
+
144
+ # Check to see if the all the properties in the model are valid
145
+ # @return true if the model is valid
146
+ def valid?
147
+ warn '[DEPRECATED] the `valid?` method is obsolete'
148
+ true
149
+ end
150
+
151
+ # Checks equality by comparing each attribute.
152
+ # @param [Object] Object to be compared
153
+ def ==(o)
154
+ return true if self.equal?(o)
155
+ self.class == o.class &&
156
+ email == o.email &&
157
+ first_name == o.first_name &&
158
+ last_name == o.last_name &&
159
+ company == o.company &&
160
+ last_tracked_ip == o.last_tracked_ip &&
161
+ custom_fields == o.custom_fields &&
162
+ lists == o.lists &&
163
+ tags == o.tags
164
+ end
165
+
166
+ # @see the `==` method
167
+ # @param [Object] Object to be compared
168
+ def eql?(o)
169
+ self == o
170
+ end
171
+
172
+ # Calculates hash code according to all attributes.
173
+ # @return [Integer] Hash code
174
+ def hash
175
+ [email, first_name, last_name, company, last_tracked_ip, custom_fields, lists, tags].hash
176
+ end
177
+
178
+ # Builds the object from hash
179
+ # @param [Hash] attributes Model attributes in the form of hash
180
+ # @return [Object] Returns the model itself
181
+ def self.build_from_hash(attributes)
182
+ return nil unless attributes.is_a?(Hash)
183
+ attributes = attributes.transform_keys(&:to_sym)
184
+ transformed_hash = {}
185
+ openapi_types.each_pair do |key, type|
186
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
187
+ transformed_hash["#{key}"] = nil
188
+ elsif type =~ /\AArray<(.*)>/i
189
+ # check to ensure the input is an array given that the attribute
190
+ # is documented as an array but the input is not
191
+ if attributes[attribute_map[key]].is_a?(Array)
192
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
193
+ end
194
+ elsif !attributes[attribute_map[key]].nil?
195
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
196
+ end
197
+ end
198
+ new(transformed_hash)
199
+ end
200
+
201
+ # Deserializes the data based on type
202
+ # @param string type Data type
203
+ # @param string value Value to be deserialized
204
+ # @return [Object] Deserialized data
205
+ def self._deserialize(type, value)
206
+ case type.to_sym
207
+ when :Time
208
+ Time.parse(value)
209
+ when :Date
210
+ Date.parse(value)
211
+ when :String
212
+ value.to_s
213
+ when :Integer
214
+ value.to_i
215
+ when :Float
216
+ value.to_f
217
+ when :Boolean
218
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
219
+ true
220
+ else
221
+ false
222
+ end
223
+ when :Object
224
+ # generic object (usually a Hash), return directly
225
+ value
226
+ when /\AArray<(?<inner_type>.+)>\z/
227
+ inner_type = Regexp.last_match[:inner_type]
228
+ value.map { |v| _deserialize(inner_type, v) }
229
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
230
+ k_type = Regexp.last_match[:k_type]
231
+ v_type = Regexp.last_match[:v_type]
232
+ {}.tap do |hash|
233
+ value.each do |k, v|
234
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
235
+ end
236
+ end
237
+ else # model
238
+ # models (e.g. Pet) or oneOf
239
+ klass = SendX.const_get(type)
240
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
241
+ end
242
+ end
243
+
244
+ # Returns the string representation of the object
245
+ # @return [String] String presentation of the object
246
+ def to_s
247
+ to_hash.to_s
248
+ end
249
+
250
+ # to_body is an alias to to_hash (backward compatibility)
251
+ # @return [Hash] Returns the object in the form of hash
252
+ def to_body
253
+ to_hash
254
+ end
255
+
256
+ # Returns the object in the form of hash
257
+ # @return [Hash] Returns the object in the form of hash
258
+ def to_hash
259
+ hash = {}
260
+ self.class.attribute_map.each_pair do |attr, param|
261
+ value = self.send(attr)
262
+ if value.nil?
263
+ is_nullable = self.class.openapi_nullable.include?(attr)
264
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
265
+ end
266
+
267
+ hash[param] = _to_hash(value)
268
+ end
269
+ hash
270
+ end
271
+
272
+ # Outputs non-array value in the form of hash
273
+ # For object, use to_hash. Otherwise, just return the value
274
+ # @param [Object] value Any valid value
275
+ # @return [Hash] Returns the value in the form of hash
276
+ def _to_hash(value)
277
+ if value.is_a?(Array)
278
+ value.compact.map { |v| _to_hash(v) }
279
+ elsif value.is_a?(Hash)
280
+ {}.tap do |hash|
281
+ value.each { |k, v| hash[k] = _to_hash(v) }
282
+ end
283
+ elsif value.respond_to? :to_hash
284
+ value.to_hash
285
+ else
286
+ value
287
+ end
288
+ end
289
+
290
+ end
291
+
292
+ end