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,483 @@
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 Campaign
18
+ # Encrypted ID of the campaign
19
+ attr_accessor :id
20
+
21
+ # Name of the campaign
22
+ attr_accessor :name
23
+
24
+ # Indicates if replies to the campaign should be tracked
25
+ attr_accessor :track_reply
26
+
27
+ # Campaign status: 0 (Draft), 1 (Scheduled), 2 (Sending), 3 (Sent), 4 (Quarantined)
28
+ attr_accessor :status
29
+
30
+ # Schedule type: 0 (Schedule later), 1 (Send Now), 2 (Trigger via automation), 3 (Recurring)
31
+ attr_accessor :schedule_type
32
+
33
+ # Condition for scheduling the campaign
34
+ attr_accessor :schedule_condition
35
+
36
+ # Time-related condition for the campaign
37
+ attr_accessor :time_condition
38
+
39
+ # Timezone for the scheduled send
40
+ attr_accessor :timezone
41
+
42
+ # Preferred time condition for the campaign
43
+ attr_accessor :preferred_time_condition
44
+
45
+ # Preferred timezone for sending the campaign
46
+ attr_accessor :preferred_timezone
47
+
48
+ # Strategy for the campaign
49
+ attr_accessor :strategy
50
+
51
+ # Indicates if the campaign should be sent in the recipient's timezone
52
+ attr_accessor :send_in_contacts_timezone
53
+
54
+ # Indicates if smart sending should be used
55
+ attr_accessor :smart_send
56
+
57
+ # Indicates if the campaign is archived
58
+ attr_accessor :is_archived
59
+
60
+ # Information about the sender of the campaign
61
+ attr_accessor :sender
62
+
63
+ # URL of the campaign's screenshot
64
+ attr_accessor :campaign_screenshot_url
65
+
66
+ # Segments to be included in the campaign
67
+ attr_accessor :included_segments
68
+
69
+ # Lists to be included in the campaign
70
+ attr_accessor :included_lists
71
+
72
+ # Tags to be included in the campaign
73
+ attr_accessor :included_tags
74
+
75
+ # Segments to be excluded from the campaign
76
+ attr_accessor :excluded_segments
77
+
78
+ # Lists to be excluded from the campaign
79
+ attr_accessor :excluded_lists
80
+
81
+ # Tags to be excluded from the campaign
82
+ attr_accessor :excluded_tags
83
+
84
+ class EnumAttributeValidator
85
+ attr_reader :datatype
86
+ attr_reader :allowable_values
87
+
88
+ def initialize(datatype, allowable_values)
89
+ @allowable_values = allowable_values.map do |value|
90
+ case datatype.to_s
91
+ when /Integer/i
92
+ value.to_i
93
+ when /Float/i
94
+ value.to_f
95
+ else
96
+ value
97
+ end
98
+ end
99
+ end
100
+
101
+ def valid?(value)
102
+ !value || allowable_values.include?(value)
103
+ end
104
+ end
105
+
106
+ # Attribute mapping from ruby-style variable name to JSON key.
107
+ def self.attribute_map
108
+ {
109
+ :'id' => :'id',
110
+ :'name' => :'name',
111
+ :'track_reply' => :'trackReply',
112
+ :'status' => :'status',
113
+ :'schedule_type' => :'scheduleType',
114
+ :'schedule_condition' => :'scheduleCondition',
115
+ :'time_condition' => :'timeCondition',
116
+ :'timezone' => :'timezone',
117
+ :'preferred_time_condition' => :'preferredTimeCondition',
118
+ :'preferred_timezone' => :'preferredTimezone',
119
+ :'strategy' => :'strategy',
120
+ :'send_in_contacts_timezone' => :'sendInContactsTimezone',
121
+ :'smart_send' => :'smartSend',
122
+ :'is_archived' => :'isArchived',
123
+ :'sender' => :'sender',
124
+ :'campaign_screenshot_url' => :'campaignScreenshotUrl',
125
+ :'included_segments' => :'includedSegments',
126
+ :'included_lists' => :'includedLists',
127
+ :'included_tags' => :'includedTags',
128
+ :'excluded_segments' => :'excludedSegments',
129
+ :'excluded_lists' => :'excludedLists',
130
+ :'excluded_tags' => :'excludedTags'
131
+ }
132
+ end
133
+
134
+ # Returns all the JSON keys this model knows about
135
+ def self.acceptable_attributes
136
+ attribute_map.values
137
+ end
138
+
139
+ # Attribute type mapping.
140
+ def self.openapi_types
141
+ {
142
+ :'id' => :'String',
143
+ :'name' => :'String',
144
+ :'track_reply' => :'Boolean',
145
+ :'status' => :'Integer',
146
+ :'schedule_type' => :'Integer',
147
+ :'schedule_condition' => :'String',
148
+ :'time_condition' => :'String',
149
+ :'timezone' => :'String',
150
+ :'preferred_time_condition' => :'String',
151
+ :'preferred_timezone' => :'String',
152
+ :'strategy' => :'String',
153
+ :'send_in_contacts_timezone' => :'Boolean',
154
+ :'smart_send' => :'Boolean',
155
+ :'is_archived' => :'Boolean',
156
+ :'sender' => :'String',
157
+ :'campaign_screenshot_url' => :'String',
158
+ :'included_segments' => :'Array<String>',
159
+ :'included_lists' => :'Array<String>',
160
+ :'included_tags' => :'Array<String>',
161
+ :'excluded_segments' => :'Array<String>',
162
+ :'excluded_lists' => :'Array<String>',
163
+ :'excluded_tags' => :'Array<String>'
164
+ }
165
+ end
166
+
167
+ # List of attributes with nullable: true
168
+ def self.openapi_nullable
169
+ Set.new([
170
+ ])
171
+ end
172
+
173
+ # Initializes the object
174
+ # @param [Hash] attributes Model attributes in the form of hash
175
+ def initialize(attributes = {})
176
+ if (!attributes.is_a?(Hash))
177
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SendX::Campaign` initialize method"
178
+ end
179
+
180
+ # check to see if the attribute exists and convert string to symbol for hash key
181
+ attributes = attributes.each_with_object({}) { |(k, v), h|
182
+ if (!self.class.attribute_map.key?(k.to_sym))
183
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SendX::Campaign`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
184
+ end
185
+ h[k.to_sym] = v
186
+ }
187
+
188
+ if attributes.key?(:'id')
189
+ self.id = attributes[:'id']
190
+ end
191
+
192
+ if attributes.key?(:'name')
193
+ self.name = attributes[:'name']
194
+ end
195
+
196
+ if attributes.key?(:'track_reply')
197
+ self.track_reply = attributes[:'track_reply']
198
+ end
199
+
200
+ if attributes.key?(:'status')
201
+ self.status = attributes[:'status']
202
+ end
203
+
204
+ if attributes.key?(:'schedule_type')
205
+ self.schedule_type = attributes[:'schedule_type']
206
+ end
207
+
208
+ if attributes.key?(:'schedule_condition')
209
+ self.schedule_condition = attributes[:'schedule_condition']
210
+ end
211
+
212
+ if attributes.key?(:'time_condition')
213
+ self.time_condition = attributes[:'time_condition']
214
+ end
215
+
216
+ if attributes.key?(:'timezone')
217
+ self.timezone = attributes[:'timezone']
218
+ end
219
+
220
+ if attributes.key?(:'preferred_time_condition')
221
+ self.preferred_time_condition = attributes[:'preferred_time_condition']
222
+ end
223
+
224
+ if attributes.key?(:'preferred_timezone')
225
+ self.preferred_timezone = attributes[:'preferred_timezone']
226
+ end
227
+
228
+ if attributes.key?(:'strategy')
229
+ self.strategy = attributes[:'strategy']
230
+ end
231
+
232
+ if attributes.key?(:'send_in_contacts_timezone')
233
+ self.send_in_contacts_timezone = attributes[:'send_in_contacts_timezone']
234
+ end
235
+
236
+ if attributes.key?(:'smart_send')
237
+ self.smart_send = attributes[:'smart_send']
238
+ end
239
+
240
+ if attributes.key?(:'is_archived')
241
+ self.is_archived = attributes[:'is_archived']
242
+ end
243
+
244
+ if attributes.key?(:'sender')
245
+ self.sender = attributes[:'sender']
246
+ end
247
+
248
+ if attributes.key?(:'campaign_screenshot_url')
249
+ self.campaign_screenshot_url = attributes[:'campaign_screenshot_url']
250
+ end
251
+
252
+ if attributes.key?(:'included_segments')
253
+ if (value = attributes[:'included_segments']).is_a?(Array)
254
+ self.included_segments = value
255
+ end
256
+ end
257
+
258
+ if attributes.key?(:'included_lists')
259
+ if (value = attributes[:'included_lists']).is_a?(Array)
260
+ self.included_lists = value
261
+ end
262
+ end
263
+
264
+ if attributes.key?(:'included_tags')
265
+ if (value = attributes[:'included_tags']).is_a?(Array)
266
+ self.included_tags = value
267
+ end
268
+ end
269
+
270
+ if attributes.key?(:'excluded_segments')
271
+ if (value = attributes[:'excluded_segments']).is_a?(Array)
272
+ self.excluded_segments = value
273
+ end
274
+ end
275
+
276
+ if attributes.key?(:'excluded_lists')
277
+ if (value = attributes[:'excluded_lists']).is_a?(Array)
278
+ self.excluded_lists = value
279
+ end
280
+ end
281
+
282
+ if attributes.key?(:'excluded_tags')
283
+ if (value = attributes[:'excluded_tags']).is_a?(Array)
284
+ self.excluded_tags = value
285
+ end
286
+ end
287
+ end
288
+
289
+ # Show invalid properties with the reasons. Usually used together with valid?
290
+ # @return Array for valid properties with the reasons
291
+ def list_invalid_properties
292
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
293
+ invalid_properties = Array.new
294
+ invalid_properties
295
+ end
296
+
297
+ # Check to see if the all the properties in the model are valid
298
+ # @return true if the model is valid
299
+ def valid?
300
+ warn '[DEPRECATED] the `valid?` method is obsolete'
301
+ status_validator = EnumAttributeValidator.new('Integer', [0, 1, 2, 3, 4])
302
+ return false unless status_validator.valid?(@status)
303
+ schedule_type_validator = EnumAttributeValidator.new('Integer', [0, 1, 2, 3])
304
+ return false unless schedule_type_validator.valid?(@schedule_type)
305
+ true
306
+ end
307
+
308
+ # Custom attribute writer method checking allowed values (enum).
309
+ # @param [Object] status Object to be assigned
310
+ def status=(status)
311
+ validator = EnumAttributeValidator.new('Integer', [0, 1, 2, 3, 4])
312
+ unless validator.valid?(status)
313
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
314
+ end
315
+ @status = status
316
+ end
317
+
318
+ # Custom attribute writer method checking allowed values (enum).
319
+ # @param [Object] schedule_type Object to be assigned
320
+ def schedule_type=(schedule_type)
321
+ validator = EnumAttributeValidator.new('Integer', [0, 1, 2, 3])
322
+ unless validator.valid?(schedule_type)
323
+ fail ArgumentError, "invalid value for \"schedule_type\", must be one of #{validator.allowable_values}."
324
+ end
325
+ @schedule_type = schedule_type
326
+ end
327
+
328
+ # Checks equality by comparing each attribute.
329
+ # @param [Object] Object to be compared
330
+ def ==(o)
331
+ return true if self.equal?(o)
332
+ self.class == o.class &&
333
+ id == o.id &&
334
+ name == o.name &&
335
+ track_reply == o.track_reply &&
336
+ status == o.status &&
337
+ schedule_type == o.schedule_type &&
338
+ schedule_condition == o.schedule_condition &&
339
+ time_condition == o.time_condition &&
340
+ timezone == o.timezone &&
341
+ preferred_time_condition == o.preferred_time_condition &&
342
+ preferred_timezone == o.preferred_timezone &&
343
+ strategy == o.strategy &&
344
+ send_in_contacts_timezone == o.send_in_contacts_timezone &&
345
+ smart_send == o.smart_send &&
346
+ is_archived == o.is_archived &&
347
+ sender == o.sender &&
348
+ campaign_screenshot_url == o.campaign_screenshot_url &&
349
+ included_segments == o.included_segments &&
350
+ included_lists == o.included_lists &&
351
+ included_tags == o.included_tags &&
352
+ excluded_segments == o.excluded_segments &&
353
+ excluded_lists == o.excluded_lists &&
354
+ excluded_tags == o.excluded_tags
355
+ end
356
+
357
+ # @see the `==` method
358
+ # @param [Object] Object to be compared
359
+ def eql?(o)
360
+ self == o
361
+ end
362
+
363
+ # Calculates hash code according to all attributes.
364
+ # @return [Integer] Hash code
365
+ def hash
366
+ [id, name, track_reply, status, schedule_type, schedule_condition, time_condition, timezone, preferred_time_condition, preferred_timezone, strategy, send_in_contacts_timezone, smart_send, is_archived, sender, campaign_screenshot_url, included_segments, included_lists, included_tags, excluded_segments, excluded_lists, excluded_tags].hash
367
+ end
368
+
369
+ # Builds the object from hash
370
+ # @param [Hash] attributes Model attributes in the form of hash
371
+ # @return [Object] Returns the model itself
372
+ def self.build_from_hash(attributes)
373
+ return nil unless attributes.is_a?(Hash)
374
+ attributes = attributes.transform_keys(&:to_sym)
375
+ transformed_hash = {}
376
+ openapi_types.each_pair do |key, type|
377
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
378
+ transformed_hash["#{key}"] = nil
379
+ elsif type =~ /\AArray<(.*)>/i
380
+ # check to ensure the input is an array given that the attribute
381
+ # is documented as an array but the input is not
382
+ if attributes[attribute_map[key]].is_a?(Array)
383
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
384
+ end
385
+ elsif !attributes[attribute_map[key]].nil?
386
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
387
+ end
388
+ end
389
+ new(transformed_hash)
390
+ end
391
+
392
+ # Deserializes the data based on type
393
+ # @param string type Data type
394
+ # @param string value Value to be deserialized
395
+ # @return [Object] Deserialized data
396
+ def self._deserialize(type, value)
397
+ case type.to_sym
398
+ when :Time
399
+ Time.parse(value)
400
+ when :Date
401
+ Date.parse(value)
402
+ when :String
403
+ value.to_s
404
+ when :Integer
405
+ value.to_i
406
+ when :Float
407
+ value.to_f
408
+ when :Boolean
409
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
410
+ true
411
+ else
412
+ false
413
+ end
414
+ when :Object
415
+ # generic object (usually a Hash), return directly
416
+ value
417
+ when /\AArray<(?<inner_type>.+)>\z/
418
+ inner_type = Regexp.last_match[:inner_type]
419
+ value.map { |v| _deserialize(inner_type, v) }
420
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
421
+ k_type = Regexp.last_match[:k_type]
422
+ v_type = Regexp.last_match[:v_type]
423
+ {}.tap do |hash|
424
+ value.each do |k, v|
425
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
426
+ end
427
+ end
428
+ else # model
429
+ # models (e.g. Pet) or oneOf
430
+ klass = SendX.const_get(type)
431
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
432
+ end
433
+ end
434
+
435
+ # Returns the string representation of the object
436
+ # @return [String] String presentation of the object
437
+ def to_s
438
+ to_hash.to_s
439
+ end
440
+
441
+ # to_body is an alias to to_hash (backward compatibility)
442
+ # @return [Hash] Returns the object in the form of hash
443
+ def to_body
444
+ to_hash
445
+ end
446
+
447
+ # Returns the object in the form of hash
448
+ # @return [Hash] Returns the object in the form of hash
449
+ def to_hash
450
+ hash = {}
451
+ self.class.attribute_map.each_pair do |attr, param|
452
+ value = self.send(attr)
453
+ if value.nil?
454
+ is_nullable = self.class.openapi_nullable.include?(attr)
455
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
456
+ end
457
+
458
+ hash[param] = _to_hash(value)
459
+ end
460
+ hash
461
+ end
462
+
463
+ # Outputs non-array value in the form of hash
464
+ # For object, use to_hash. Otherwise, just return the value
465
+ # @param [Object] value Any valid value
466
+ # @return [Hash] Returns the value in the form of hash
467
+ def _to_hash(value)
468
+ if value.is_a?(Array)
469
+ value.compact.map { |v| _to_hash(v) }
470
+ elsif value.is_a?(Hash)
471
+ {}.tap do |hash|
472
+ value.each { |k, v| hash[k] = _to_hash(v) }
473
+ end
474
+ elsif value.respond_to? :to_hash
475
+ value.to_hash
476
+ else
477
+ value
478
+ end
479
+ end
480
+
481
+ end
482
+
483
+ end