sendx-ruby-sdk 1.0.1 → 1.1.0

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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -19
  3. data/lib/sendx-ruby-sdk/api/campaign_api.rb +1 -1
  4. data/lib/sendx-ruby-sdk/api/contact_api.rb +41 -41
  5. data/lib/sendx-ruby-sdk/api/event_api.rb +158 -0
  6. data/lib/sendx-ruby-sdk/api/getting_started_api.rb +158 -0
  7. data/lib/sendx-ruby-sdk/api/list_api.rb +1 -1
  8. data/lib/sendx-ruby-sdk/api/reports_api.rb +1 -1
  9. data/lib/sendx-ruby-sdk/api/sender_api.rb +1 -1
  10. data/lib/sendx-ruby-sdk/api/tags_api.rb +1 -1
  11. data/lib/sendx-ruby-sdk/api_client.rb +1 -1
  12. data/lib/sendx-ruby-sdk/api_error.rb +1 -1
  13. data/lib/sendx-ruby-sdk/configuration.rb +1 -1
  14. data/lib/sendx-ruby-sdk/models/campaign.rb +1 -1
  15. data/lib/sendx-ruby-sdk/models/campaign_dashboard_data.rb +1 -1
  16. data/lib/sendx-ruby-sdk/models/campaign_request.rb +1 -1
  17. data/lib/sendx-ruby-sdk/models/contact.rb +1 -1
  18. data/lib/sendx-ruby-sdk/models/contact_request.rb +1 -1
  19. data/lib/sendx-ruby-sdk/models/create_response.rb +1 -1
  20. data/lib/sendx-ruby-sdk/models/custom_event_request.rb +275 -0
  21. data/lib/sendx-ruby-sdk/models/dashboard_stats.rb +1 -1
  22. data/lib/sendx-ruby-sdk/models/delete_campaign200_response.rb +1 -1
  23. data/lib/sendx-ruby-sdk/models/delete_request.rb +1 -1
  24. data/lib/sendx-ruby-sdk/models/delete_response.rb +1 -1
  25. data/lib/sendx-ruby-sdk/models/event_response.rb +235 -0
  26. data/lib/sendx-ruby-sdk/models/identify_request.rb +284 -0
  27. data/lib/sendx-ruby-sdk/models/identify_response.rb +232 -0
  28. data/lib/sendx-ruby-sdk/models/last_sent_campaign_stat.rb +1 -1
  29. data/lib/sendx-ruby-sdk/models/list_model.rb +1 -1
  30. data/lib/sendx-ruby-sdk/models/list_request.rb +1 -1
  31. data/lib/sendx-ruby-sdk/models/report_data.rb +1 -1
  32. data/lib/sendx-ruby-sdk/models/response.rb +1 -1
  33. data/lib/sendx-ruby-sdk/models/revenue_event_request.rb +290 -0
  34. data/lib/sendx-ruby-sdk/models/sender.rb +1 -1
  35. data/lib/sendx-ruby-sdk/models/sender_request.rb +1 -1
  36. data/lib/sendx-ruby-sdk/models/sender_response.rb +1 -1
  37. data/lib/sendx-ruby-sdk/models/tag.rb +1 -1
  38. data/lib/sendx-ruby-sdk/models/tag_request.rb +1 -1
  39. data/lib/sendx-ruby-sdk/models/track_request.rb +237 -0
  40. data/lib/sendx-ruby-sdk/models/track_response.rb +223 -0
  41. data/lib/sendx-ruby-sdk/version.rb +2 -2
  42. data/lib/sendx-ruby-sdk.rb +10 -1
  43. data/spec/api/event_api_spec.rb +59 -0
  44. data/spec/api/getting_started_api_spec.rb +59 -0
  45. data/spec/models/custom_event_request_spec.rb +54 -0
  46. data/spec/models/event_response_spec.rb +48 -0
  47. data/spec/models/identify_request_spec.rb +72 -0
  48. data/spec/models/identify_response_spec.rb +48 -0
  49. data/spec/models/revenue_event_request_spec.rb +60 -0
  50. data/spec/models/track_request_spec.rb +48 -0
  51. data/spec/models/track_response_spec.rb +42 -0
  52. data/spec/spec_helper.rb +1 -1
  53. metadata +29 -2
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 1.0.1
6
+ The version of the OpenAPI document: 1.0.0
7
7
  Contact: support@sendx.io
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.8.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 1.0.1
6
+ The version of the OpenAPI document: 1.0.0
7
7
  Contact: support@sendx.io
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.8.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 1.0.1
6
+ The version of the OpenAPI document: 1.0.0
7
7
  Contact: support@sendx.io
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.8.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 1.0.1
6
+ The version of the OpenAPI document: 1.0.0
7
7
  Contact: support@sendx.io
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.8.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 1.0.1
6
+ The version of the OpenAPI document: 1.0.0
7
7
  Contact: support@sendx.io
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.8.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 1.0.1
6
+ The version of the OpenAPI document: 1.0.0
7
7
  Contact: support@sendx.io
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.8.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 1.0.1
6
+ The version of the OpenAPI document: 1.0.0
7
7
  Contact: support@sendx.io
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.8.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 1.0.1
6
+ The version of the OpenAPI document: 1.0.0
7
7
  Contact: support@sendx.io
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.8.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 1.0.1
6
+ The version of the OpenAPI document: 1.0.0
7
7
  Contact: support@sendx.io
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.8.0
@@ -0,0 +1,275 @@
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.0
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 CustomEventRequest
18
+ # Name of the custom event (e.g., 'abandoned_cart').
19
+ attr_accessor :name
20
+
21
+ # Unique identifier for the contact (e.g., contact's email).
22
+ attr_accessor :identifier
23
+
24
+ # Map of property-value pairs associated with the event, where both key and value are strings.
25
+ attr_accessor :data
26
+
27
+ # Unix timestamp of when the event occurred.
28
+ attr_accessor :time
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'name' => :'name',
34
+ :'identifier' => :'identifier',
35
+ :'data' => :'data',
36
+ :'time' => :'time'
37
+ }
38
+ end
39
+
40
+ # Returns all the JSON keys this model knows about
41
+ def self.acceptable_attributes
42
+ attribute_map.values
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'name' => :'String',
49
+ :'identifier' => :'String',
50
+ :'data' => :'Hash<String, String>',
51
+ :'time' => :'Integer'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ ])
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SendX::CustomEventRequest` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SendX::CustomEventRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'name')
77
+ self.name = attributes[:'name']
78
+ else
79
+ self.name = nil
80
+ end
81
+
82
+ if attributes.key?(:'identifier')
83
+ self.identifier = attributes[:'identifier']
84
+ else
85
+ self.identifier = nil
86
+ end
87
+
88
+ if attributes.key?(:'data')
89
+ if (value = attributes[:'data']).is_a?(Hash)
90
+ self.data = value
91
+ end
92
+ else
93
+ self.data = nil
94
+ end
95
+
96
+ if attributes.key?(:'time')
97
+ self.time = attributes[:'time']
98
+ else
99
+ self.time = nil
100
+ end
101
+ end
102
+
103
+ # Show invalid properties with the reasons. Usually used together with valid?
104
+ # @return Array for valid properties with the reasons
105
+ def list_invalid_properties
106
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
107
+ invalid_properties = Array.new
108
+ if @name.nil?
109
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
110
+ end
111
+
112
+ if @identifier.nil?
113
+ invalid_properties.push('invalid value for "identifier", identifier cannot be nil.')
114
+ end
115
+
116
+ if @data.nil?
117
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
118
+ end
119
+
120
+ if @time.nil?
121
+ invalid_properties.push('invalid value for "time", time cannot be nil.')
122
+ end
123
+
124
+ invalid_properties
125
+ end
126
+
127
+ # Check to see if the all the properties in the model are valid
128
+ # @return true if the model is valid
129
+ def valid?
130
+ warn '[DEPRECATED] the `valid?` method is obsolete'
131
+ return false if @name.nil?
132
+ return false if @identifier.nil?
133
+ return false if @data.nil?
134
+ return false if @time.nil?
135
+ true
136
+ end
137
+
138
+ # Checks equality by comparing each attribute.
139
+ # @param [Object] Object to be compared
140
+ def ==(o)
141
+ return true if self.equal?(o)
142
+ self.class == o.class &&
143
+ name == o.name &&
144
+ identifier == o.identifier &&
145
+ data == o.data &&
146
+ time == o.time
147
+ end
148
+
149
+ # @see the `==` method
150
+ # @param [Object] Object to be compared
151
+ def eql?(o)
152
+ self == o
153
+ end
154
+
155
+ # Calculates hash code according to all attributes.
156
+ # @return [Integer] Hash code
157
+ def hash
158
+ [name, identifier, data, time].hash
159
+ end
160
+
161
+ # Builds the object from hash
162
+ # @param [Hash] attributes Model attributes in the form of hash
163
+ # @return [Object] Returns the model itself
164
+ def self.build_from_hash(attributes)
165
+ return nil unless attributes.is_a?(Hash)
166
+ attributes = attributes.transform_keys(&:to_sym)
167
+ transformed_hash = {}
168
+ openapi_types.each_pair do |key, type|
169
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
170
+ transformed_hash["#{key}"] = nil
171
+ elsif type =~ /\AArray<(.*)>/i
172
+ # check to ensure the input is an array given that the attribute
173
+ # is documented as an array but the input is not
174
+ if attributes[attribute_map[key]].is_a?(Array)
175
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
176
+ end
177
+ elsif !attributes[attribute_map[key]].nil?
178
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
179
+ end
180
+ end
181
+ new(transformed_hash)
182
+ end
183
+
184
+ # Deserializes the data based on type
185
+ # @param string type Data type
186
+ # @param string value Value to be deserialized
187
+ # @return [Object] Deserialized data
188
+ def self._deserialize(type, value)
189
+ case type.to_sym
190
+ when :Time
191
+ Time.parse(value)
192
+ when :Date
193
+ Date.parse(value)
194
+ when :String
195
+ value.to_s
196
+ when :Integer
197
+ value.to_i
198
+ when :Float
199
+ value.to_f
200
+ when :Boolean
201
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
202
+ true
203
+ else
204
+ false
205
+ end
206
+ when :Object
207
+ # generic object (usually a Hash), return directly
208
+ value
209
+ when /\AArray<(?<inner_type>.+)>\z/
210
+ inner_type = Regexp.last_match[:inner_type]
211
+ value.map { |v| _deserialize(inner_type, v) }
212
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
213
+ k_type = Regexp.last_match[:k_type]
214
+ v_type = Regexp.last_match[:v_type]
215
+ {}.tap do |hash|
216
+ value.each do |k, v|
217
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
218
+ end
219
+ end
220
+ else # model
221
+ # models (e.g. Pet) or oneOf
222
+ klass = SendX.const_get(type)
223
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
224
+ end
225
+ end
226
+
227
+ # Returns the string representation of the object
228
+ # @return [String] String presentation of the object
229
+ def to_s
230
+ to_hash.to_s
231
+ end
232
+
233
+ # to_body is an alias to to_hash (backward compatibility)
234
+ # @return [Hash] Returns the object in the form of hash
235
+ def to_body
236
+ to_hash
237
+ end
238
+
239
+ # Returns the object in the form of hash
240
+ # @return [Hash] Returns the object in the form of hash
241
+ def to_hash
242
+ hash = {}
243
+ self.class.attribute_map.each_pair do |attr, param|
244
+ value = self.send(attr)
245
+ if value.nil?
246
+ is_nullable = self.class.openapi_nullable.include?(attr)
247
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
248
+ end
249
+
250
+ hash[param] = _to_hash(value)
251
+ end
252
+ hash
253
+ end
254
+
255
+ # Outputs non-array value in the form of hash
256
+ # For object, use to_hash. Otherwise, just return the value
257
+ # @param [Object] value Any valid value
258
+ # @return [Hash] Returns the value in the form of hash
259
+ def _to_hash(value)
260
+ if value.is_a?(Array)
261
+ value.compact.map { |v| _to_hash(v) }
262
+ elsif value.is_a?(Hash)
263
+ {}.tap do |hash|
264
+ value.each { |k, v| hash[k] = _to_hash(v) }
265
+ end
266
+ elsif value.respond_to? :to_hash
267
+ value.to_hash
268
+ else
269
+ value
270
+ end
271
+ end
272
+
273
+ end
274
+
275
+ end
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 1.0.1
6
+ The version of the OpenAPI document: 1.0.0
7
7
  Contact: support@sendx.io
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.8.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 1.0.1
6
+ The version of the OpenAPI document: 1.0.0
7
7
  Contact: support@sendx.io
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.8.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 1.0.1
6
+ The version of the OpenAPI document: 1.0.0
7
7
  Contact: support@sendx.io
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.8.0
@@ -3,7 +3,7 @@
3
3
 
4
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
5
 
6
- The version of the OpenAPI document: 1.0.1
6
+ The version of the OpenAPI document: 1.0.0
7
7
  Contact: support@sendx.io
8
8
  Generated by: https://openapi-generator.tech
9
9
  Generator version: 7.8.0
@@ -0,0 +1,235 @@
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.0
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 EventResponse
18
+ # Unique identifier for the created event.
19
+ attr_accessor :event_id
20
+
21
+ # Status of the event creation (e.g., 'success').
22
+ attr_accessor :status
23
+
24
+ # Additional message about the event creation.
25
+ attr_accessor :message
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'event_id' => :'event_id',
31
+ :'status' => :'status',
32
+ :'message' => :'message'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'event_id' => :'String',
45
+ :'status' => :'String',
46
+ :'message' => :'String'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SendX::EventResponse` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ attributes = attributes.each_with_object({}) { |(k, v), h|
65
+ if (!self.class.attribute_map.key?(k.to_sym))
66
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SendX::EventResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
67
+ end
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:'event_id')
72
+ self.event_id = attributes[:'event_id']
73
+ end
74
+
75
+ if attributes.key?(:'status')
76
+ self.status = attributes[:'status']
77
+ end
78
+
79
+ if attributes.key?(:'message')
80
+ self.message = attributes[:'message']
81
+ end
82
+ end
83
+
84
+ # Show invalid properties with the reasons. Usually used together with valid?
85
+ # @return Array for valid properties with the reasons
86
+ def list_invalid_properties
87
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
88
+ invalid_properties = Array.new
89
+ invalid_properties
90
+ end
91
+
92
+ # Check to see if the all the properties in the model are valid
93
+ # @return true if the model is valid
94
+ def valid?
95
+ warn '[DEPRECATED] the `valid?` method is obsolete'
96
+ true
97
+ end
98
+
99
+ # Checks equality by comparing each attribute.
100
+ # @param [Object] Object to be compared
101
+ def ==(o)
102
+ return true if self.equal?(o)
103
+ self.class == o.class &&
104
+ event_id == o.event_id &&
105
+ status == o.status &&
106
+ message == o.message
107
+ end
108
+
109
+ # @see the `==` method
110
+ # @param [Object] Object to be compared
111
+ def eql?(o)
112
+ self == o
113
+ end
114
+
115
+ # Calculates hash code according to all attributes.
116
+ # @return [Integer] Hash code
117
+ def hash
118
+ [event_id, status, message].hash
119
+ end
120
+
121
+ # Builds the object from hash
122
+ # @param [Hash] attributes Model attributes in the form of hash
123
+ # @return [Object] Returns the model itself
124
+ def self.build_from_hash(attributes)
125
+ return nil unless attributes.is_a?(Hash)
126
+ attributes = attributes.transform_keys(&:to_sym)
127
+ transformed_hash = {}
128
+ openapi_types.each_pair do |key, type|
129
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
130
+ transformed_hash["#{key}"] = nil
131
+ elsif type =~ /\AArray<(.*)>/i
132
+ # check to ensure the input is an array given that the attribute
133
+ # is documented as an array but the input is not
134
+ if attributes[attribute_map[key]].is_a?(Array)
135
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
136
+ end
137
+ elsif !attributes[attribute_map[key]].nil?
138
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
139
+ end
140
+ end
141
+ new(transformed_hash)
142
+ end
143
+
144
+ # Deserializes the data based on type
145
+ # @param string type Data type
146
+ # @param string value Value to be deserialized
147
+ # @return [Object] Deserialized data
148
+ def self._deserialize(type, value)
149
+ case type.to_sym
150
+ when :Time
151
+ Time.parse(value)
152
+ when :Date
153
+ Date.parse(value)
154
+ when :String
155
+ value.to_s
156
+ when :Integer
157
+ value.to_i
158
+ when :Float
159
+ value.to_f
160
+ when :Boolean
161
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
162
+ true
163
+ else
164
+ false
165
+ end
166
+ when :Object
167
+ # generic object (usually a Hash), return directly
168
+ value
169
+ when /\AArray<(?<inner_type>.+)>\z/
170
+ inner_type = Regexp.last_match[:inner_type]
171
+ value.map { |v| _deserialize(inner_type, v) }
172
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
173
+ k_type = Regexp.last_match[:k_type]
174
+ v_type = Regexp.last_match[:v_type]
175
+ {}.tap do |hash|
176
+ value.each do |k, v|
177
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
178
+ end
179
+ end
180
+ else # model
181
+ # models (e.g. Pet) or oneOf
182
+ klass = SendX.const_get(type)
183
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
184
+ end
185
+ end
186
+
187
+ # Returns the string representation of the object
188
+ # @return [String] String presentation of the object
189
+ def to_s
190
+ to_hash.to_s
191
+ end
192
+
193
+ # to_body is an alias to to_hash (backward compatibility)
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_body
196
+ to_hash
197
+ end
198
+
199
+ # Returns the object in the form of hash
200
+ # @return [Hash] Returns the object in the form of hash
201
+ def to_hash
202
+ hash = {}
203
+ self.class.attribute_map.each_pair do |attr, param|
204
+ value = self.send(attr)
205
+ if value.nil?
206
+ is_nullable = self.class.openapi_nullable.include?(attr)
207
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
208
+ end
209
+
210
+ hash[param] = _to_hash(value)
211
+ end
212
+ hash
213
+ end
214
+
215
+ # Outputs non-array value in the form of hash
216
+ # For object, use to_hash. Otherwise, just return the value
217
+ # @param [Object] value Any valid value
218
+ # @return [Hash] Returns the value in the form of hash
219
+ def _to_hash(value)
220
+ if value.is_a?(Array)
221
+ value.compact.map { |v| _to_hash(v) }
222
+ elsif value.is_a?(Hash)
223
+ {}.tap do |hash|
224
+ value.each { |k, v| hash[k] = _to_hash(v) }
225
+ end
226
+ elsif value.respond_to? :to_hash
227
+ value.to_hash
228
+ else
229
+ value
230
+ end
231
+ end
232
+
233
+ end
234
+
235
+ end