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