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,379 @@
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 ListRequest
18
+ # Name of the list
19
+ attr_accessor :name
20
+
21
+ # Type of the list representing opt-in methods <br> 0: Single opt-in list <br> 1: Double opt-in list
22
+ attr_accessor :type
23
+
24
+ # Indicates if a thank-you email should be sent
25
+ attr_accessor :send_thank_you_mail
26
+
27
+ # Name displayed as the sender in the thank-you email
28
+ attr_accessor :thank_you_from_name
29
+
30
+ # Email address from which the thank-you email is sent
31
+ attr_accessor :thank_you_from_email
32
+
33
+ # Subject line of the thank-you email
34
+ attr_accessor :thank_you_mail_subject
35
+
36
+ # Plain text message body of the thank-you email
37
+ attr_accessor :thank_you_mail_message
38
+
39
+ # Sender ID for the thank-you email
40
+ attr_accessor :thank_you_sender
41
+
42
+ # Name displayed as the sender in the confirmation email
43
+ attr_accessor :confirm_from_name
44
+
45
+ # Email address from which the confirmation email is sent
46
+ attr_accessor :confirm_from_email
47
+
48
+ # Subject line of the confirmation email
49
+ attr_accessor :confirm_mail_subject
50
+
51
+ # Plain text message body of the confirmation email
52
+ attr_accessor :confirm_mail_message
53
+
54
+ # URL of the success page after confirmation
55
+ attr_accessor :confirm_success_page
56
+
57
+ # Sender ID for the confirmation email
58
+ attr_accessor :confirm_sender
59
+
60
+ class EnumAttributeValidator
61
+ attr_reader :datatype
62
+ attr_reader :allowable_values
63
+
64
+ def initialize(datatype, allowable_values)
65
+ @allowable_values = allowable_values.map do |value|
66
+ case datatype.to_s
67
+ when /Integer/i
68
+ value.to_i
69
+ when /Float/i
70
+ value.to_f
71
+ else
72
+ value
73
+ end
74
+ end
75
+ end
76
+
77
+ def valid?(value)
78
+ !value || allowable_values.include?(value)
79
+ end
80
+ end
81
+
82
+ # Attribute mapping from ruby-style variable name to JSON key.
83
+ def self.attribute_map
84
+ {
85
+ :'name' => :'name',
86
+ :'type' => :'type',
87
+ :'send_thank_you_mail' => :'sendThankYouMail',
88
+ :'thank_you_from_name' => :'thankYouFromName',
89
+ :'thank_you_from_email' => :'thankYouFromEmail',
90
+ :'thank_you_mail_subject' => :'thankYouMailSubject',
91
+ :'thank_you_mail_message' => :'thankYouMailMessage',
92
+ :'thank_you_sender' => :'thankYouSender',
93
+ :'confirm_from_name' => :'confirmFromName',
94
+ :'confirm_from_email' => :'confirmFromEmail',
95
+ :'confirm_mail_subject' => :'confirmMailSubject',
96
+ :'confirm_mail_message' => :'confirmMailMessage',
97
+ :'confirm_success_page' => :'confirmSuccessPage',
98
+ :'confirm_sender' => :'confirmSender'
99
+ }
100
+ end
101
+
102
+ # Returns all the JSON keys this model knows about
103
+ def self.acceptable_attributes
104
+ attribute_map.values
105
+ end
106
+
107
+ # Attribute type mapping.
108
+ def self.openapi_types
109
+ {
110
+ :'name' => :'String',
111
+ :'type' => :'Integer',
112
+ :'send_thank_you_mail' => :'Boolean',
113
+ :'thank_you_from_name' => :'String',
114
+ :'thank_you_from_email' => :'String',
115
+ :'thank_you_mail_subject' => :'String',
116
+ :'thank_you_mail_message' => :'String',
117
+ :'thank_you_sender' => :'String',
118
+ :'confirm_from_name' => :'String',
119
+ :'confirm_from_email' => :'String',
120
+ :'confirm_mail_subject' => :'String',
121
+ :'confirm_mail_message' => :'String',
122
+ :'confirm_success_page' => :'String',
123
+ :'confirm_sender' => :'String'
124
+ }
125
+ end
126
+
127
+ # List of attributes with nullable: true
128
+ def self.openapi_nullable
129
+ Set.new([
130
+ ])
131
+ end
132
+
133
+ # Initializes the object
134
+ # @param [Hash] attributes Model attributes in the form of hash
135
+ def initialize(attributes = {})
136
+ if (!attributes.is_a?(Hash))
137
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SendX::ListRequest` initialize method"
138
+ end
139
+
140
+ # check to see if the attribute exists and convert string to symbol for hash key
141
+ attributes = attributes.each_with_object({}) { |(k, v), h|
142
+ if (!self.class.attribute_map.key?(k.to_sym))
143
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SendX::ListRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
144
+ end
145
+ h[k.to_sym] = v
146
+ }
147
+
148
+ if attributes.key?(:'name')
149
+ self.name = attributes[:'name']
150
+ end
151
+
152
+ if attributes.key?(:'type')
153
+ self.type = attributes[:'type']
154
+ end
155
+
156
+ if attributes.key?(:'send_thank_you_mail')
157
+ self.send_thank_you_mail = attributes[:'send_thank_you_mail']
158
+ end
159
+
160
+ if attributes.key?(:'thank_you_from_name')
161
+ self.thank_you_from_name = attributes[:'thank_you_from_name']
162
+ end
163
+
164
+ if attributes.key?(:'thank_you_from_email')
165
+ self.thank_you_from_email = attributes[:'thank_you_from_email']
166
+ end
167
+
168
+ if attributes.key?(:'thank_you_mail_subject')
169
+ self.thank_you_mail_subject = attributes[:'thank_you_mail_subject']
170
+ end
171
+
172
+ if attributes.key?(:'thank_you_mail_message')
173
+ self.thank_you_mail_message = attributes[:'thank_you_mail_message']
174
+ end
175
+
176
+ if attributes.key?(:'thank_you_sender')
177
+ self.thank_you_sender = attributes[:'thank_you_sender']
178
+ end
179
+
180
+ if attributes.key?(:'confirm_from_name')
181
+ self.confirm_from_name = attributes[:'confirm_from_name']
182
+ end
183
+
184
+ if attributes.key?(:'confirm_from_email')
185
+ self.confirm_from_email = attributes[:'confirm_from_email']
186
+ end
187
+
188
+ if attributes.key?(:'confirm_mail_subject')
189
+ self.confirm_mail_subject = attributes[:'confirm_mail_subject']
190
+ end
191
+
192
+ if attributes.key?(:'confirm_mail_message')
193
+ self.confirm_mail_message = attributes[:'confirm_mail_message']
194
+ end
195
+
196
+ if attributes.key?(:'confirm_success_page')
197
+ self.confirm_success_page = attributes[:'confirm_success_page']
198
+ end
199
+
200
+ if attributes.key?(:'confirm_sender')
201
+ self.confirm_sender = attributes[:'confirm_sender']
202
+ end
203
+ end
204
+
205
+ # Show invalid properties with the reasons. Usually used together with valid?
206
+ # @return Array for valid properties with the reasons
207
+ def list_invalid_properties
208
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
209
+ invalid_properties = Array.new
210
+ invalid_properties
211
+ end
212
+
213
+ # Check to see if the all the properties in the model are valid
214
+ # @return true if the model is valid
215
+ def valid?
216
+ warn '[DEPRECATED] the `valid?` method is obsolete'
217
+ type_validator = EnumAttributeValidator.new('Integer', [0, 1])
218
+ return false unless type_validator.valid?(@type)
219
+ true
220
+ end
221
+
222
+ # Custom attribute writer method checking allowed values (enum).
223
+ # @param [Object] type Object to be assigned
224
+ def type=(type)
225
+ validator = EnumAttributeValidator.new('Integer', [0, 1])
226
+ unless validator.valid?(type)
227
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
228
+ end
229
+ @type = type
230
+ end
231
+
232
+ # Checks equality by comparing each attribute.
233
+ # @param [Object] Object to be compared
234
+ def ==(o)
235
+ return true if self.equal?(o)
236
+ self.class == o.class &&
237
+ name == o.name &&
238
+ type == o.type &&
239
+ send_thank_you_mail == o.send_thank_you_mail &&
240
+ thank_you_from_name == o.thank_you_from_name &&
241
+ thank_you_from_email == o.thank_you_from_email &&
242
+ thank_you_mail_subject == o.thank_you_mail_subject &&
243
+ thank_you_mail_message == o.thank_you_mail_message &&
244
+ thank_you_sender == o.thank_you_sender &&
245
+ confirm_from_name == o.confirm_from_name &&
246
+ confirm_from_email == o.confirm_from_email &&
247
+ confirm_mail_subject == o.confirm_mail_subject &&
248
+ confirm_mail_message == o.confirm_mail_message &&
249
+ confirm_success_page == o.confirm_success_page &&
250
+ confirm_sender == o.confirm_sender
251
+ end
252
+
253
+ # @see the `==` method
254
+ # @param [Object] Object to be compared
255
+ def eql?(o)
256
+ self == o
257
+ end
258
+
259
+ # Calculates hash code according to all attributes.
260
+ # @return [Integer] Hash code
261
+ def hash
262
+ [name, type, send_thank_you_mail, thank_you_from_name, thank_you_from_email, thank_you_mail_subject, thank_you_mail_message, thank_you_sender, confirm_from_name, confirm_from_email, confirm_mail_subject, confirm_mail_message, confirm_success_page, confirm_sender].hash
263
+ end
264
+
265
+ # Builds the object from hash
266
+ # @param [Hash] attributes Model attributes in the form of hash
267
+ # @return [Object] Returns the model itself
268
+ def self.build_from_hash(attributes)
269
+ return nil unless attributes.is_a?(Hash)
270
+ attributes = attributes.transform_keys(&:to_sym)
271
+ transformed_hash = {}
272
+ openapi_types.each_pair do |key, type|
273
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
274
+ transformed_hash["#{key}"] = nil
275
+ elsif type =~ /\AArray<(.*)>/i
276
+ # check to ensure the input is an array given that the attribute
277
+ # is documented as an array but the input is not
278
+ if attributes[attribute_map[key]].is_a?(Array)
279
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
280
+ end
281
+ elsif !attributes[attribute_map[key]].nil?
282
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
283
+ end
284
+ end
285
+ new(transformed_hash)
286
+ end
287
+
288
+ # Deserializes the data based on type
289
+ # @param string type Data type
290
+ # @param string value Value to be deserialized
291
+ # @return [Object] Deserialized data
292
+ def self._deserialize(type, value)
293
+ case type.to_sym
294
+ when :Time
295
+ Time.parse(value)
296
+ when :Date
297
+ Date.parse(value)
298
+ when :String
299
+ value.to_s
300
+ when :Integer
301
+ value.to_i
302
+ when :Float
303
+ value.to_f
304
+ when :Boolean
305
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
306
+ true
307
+ else
308
+ false
309
+ end
310
+ when :Object
311
+ # generic object (usually a Hash), return directly
312
+ value
313
+ when /\AArray<(?<inner_type>.+)>\z/
314
+ inner_type = Regexp.last_match[:inner_type]
315
+ value.map { |v| _deserialize(inner_type, v) }
316
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
317
+ k_type = Regexp.last_match[:k_type]
318
+ v_type = Regexp.last_match[:v_type]
319
+ {}.tap do |hash|
320
+ value.each do |k, v|
321
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
322
+ end
323
+ end
324
+ else # model
325
+ # models (e.g. Pet) or oneOf
326
+ klass = SendX.const_get(type)
327
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
328
+ end
329
+ end
330
+
331
+ # Returns the string representation of the object
332
+ # @return [String] String presentation of the object
333
+ def to_s
334
+ to_hash.to_s
335
+ end
336
+
337
+ # to_body is an alias to to_hash (backward compatibility)
338
+ # @return [Hash] Returns the object in the form of hash
339
+ def to_body
340
+ to_hash
341
+ end
342
+
343
+ # Returns the object in the form of hash
344
+ # @return [Hash] Returns the object in the form of hash
345
+ def to_hash
346
+ hash = {}
347
+ self.class.attribute_map.each_pair do |attr, param|
348
+ value = self.send(attr)
349
+ if value.nil?
350
+ is_nullable = self.class.openapi_nullable.include?(attr)
351
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
352
+ end
353
+
354
+ hash[param] = _to_hash(value)
355
+ end
356
+ hash
357
+ end
358
+
359
+ # Outputs non-array value in the form of hash
360
+ # For object, use to_hash. Otherwise, just return the value
361
+ # @param [Object] value Any valid value
362
+ # @return [Hash] Returns the value in the form of hash
363
+ def _to_hash(value)
364
+ if value.is_a?(Array)
365
+ value.compact.map { |v| _to_hash(v) }
366
+ elsif value.is_a?(Hash)
367
+ {}.tap do |hash|
368
+ value.each { |k, v| hash[k] = _to_hash(v) }
369
+ end
370
+ elsif value.respond_to? :to_hash
371
+ value.to_hash
372
+ else
373
+ value
374
+ end
375
+ end
376
+
377
+ end
378
+
379
+ end