sendx-ruby-sdk 1.0.2 → 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 +18 -6
  3. data/lib/sendx-ruby-sdk/api/campaign_api.rb +1 -1
  4. data/lib/sendx-ruby-sdk/api/contact_api.rb +1 -1
  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
@@ -0,0 +1,290 @@
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 RevenueEventRequest
18
+ # Unique identifier for the contact.
19
+ attr_accessor :identifier
20
+
21
+ # Recognized revenue amount associated with the event.
22
+ attr_accessor :amount
23
+
24
+ # Currency code (ISO 4217) for the revenue (e.g., 'USD', 'EUR', 'INR').
25
+ attr_accessor :currency
26
+
27
+ # Source of the revenue (e.g., 'website', 'mobile app', 'partner referral').
28
+ attr_accessor :source
29
+
30
+ # Unix timestamp indicating when the revenue event occurred.
31
+ attr_accessor :time
32
+
33
+ # Attribute mapping from ruby-style variable name to JSON key.
34
+ def self.attribute_map
35
+ {
36
+ :'identifier' => :'identifier',
37
+ :'amount' => :'amount',
38
+ :'currency' => :'currency',
39
+ :'source' => :'source',
40
+ :'time' => :'time'
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
+ :'identifier' => :'String',
53
+ :'amount' => :'Float',
54
+ :'currency' => :'String',
55
+ :'source' => :'String',
56
+ :'time' => :'Integer'
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::RevenueEventRequest` 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::RevenueEventRequest`. 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?(:'identifier')
82
+ self.identifier = attributes[:'identifier']
83
+ else
84
+ self.identifier = nil
85
+ end
86
+
87
+ if attributes.key?(:'amount')
88
+ self.amount = attributes[:'amount']
89
+ else
90
+ self.amount = nil
91
+ end
92
+
93
+ if attributes.key?(:'currency')
94
+ self.currency = attributes[:'currency']
95
+ else
96
+ self.currency = nil
97
+ end
98
+
99
+ if attributes.key?(:'source')
100
+ self.source = attributes[:'source']
101
+ else
102
+ self.source = nil
103
+ end
104
+
105
+ if attributes.key?(:'time')
106
+ self.time = attributes[:'time']
107
+ else
108
+ self.time = nil
109
+ end
110
+ end
111
+
112
+ # Show invalid properties with the reasons. Usually used together with valid?
113
+ # @return Array for valid properties with the reasons
114
+ def list_invalid_properties
115
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
116
+ invalid_properties = Array.new
117
+ if @identifier.nil?
118
+ invalid_properties.push('invalid value for "identifier", identifier cannot be nil.')
119
+ end
120
+
121
+ if @amount.nil?
122
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
123
+ end
124
+
125
+ if @currency.nil?
126
+ invalid_properties.push('invalid value for "currency", currency cannot be nil.')
127
+ end
128
+
129
+ if @source.nil?
130
+ invalid_properties.push('invalid value for "source", source cannot be nil.')
131
+ end
132
+
133
+ if @time.nil?
134
+ invalid_properties.push('invalid value for "time", time cannot be nil.')
135
+ end
136
+
137
+ invalid_properties
138
+ end
139
+
140
+ # Check to see if the all the properties in the model are valid
141
+ # @return true if the model is valid
142
+ def valid?
143
+ warn '[DEPRECATED] the `valid?` method is obsolete'
144
+ return false if @identifier.nil?
145
+ return false if @amount.nil?
146
+ return false if @currency.nil?
147
+ return false if @source.nil?
148
+ return false if @time.nil?
149
+ true
150
+ end
151
+
152
+ # Checks equality by comparing each attribute.
153
+ # @param [Object] Object to be compared
154
+ def ==(o)
155
+ return true if self.equal?(o)
156
+ self.class == o.class &&
157
+ identifier == o.identifier &&
158
+ amount == o.amount &&
159
+ currency == o.currency &&
160
+ source == o.source &&
161
+ time == o.time
162
+ end
163
+
164
+ # @see the `==` method
165
+ # @param [Object] Object to be compared
166
+ def eql?(o)
167
+ self == o
168
+ end
169
+
170
+ # Calculates hash code according to all attributes.
171
+ # @return [Integer] Hash code
172
+ def hash
173
+ [identifier, amount, currency, source, time].hash
174
+ end
175
+
176
+ # Builds the object from hash
177
+ # @param [Hash] attributes Model attributes in the form of hash
178
+ # @return [Object] Returns the model itself
179
+ def self.build_from_hash(attributes)
180
+ return nil unless attributes.is_a?(Hash)
181
+ attributes = attributes.transform_keys(&:to_sym)
182
+ transformed_hash = {}
183
+ openapi_types.each_pair do |key, type|
184
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
185
+ transformed_hash["#{key}"] = nil
186
+ elsif type =~ /\AArray<(.*)>/i
187
+ # check to ensure the input is an array given that the attribute
188
+ # is documented as an array but the input is not
189
+ if attributes[attribute_map[key]].is_a?(Array)
190
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
191
+ end
192
+ elsif !attributes[attribute_map[key]].nil?
193
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
194
+ end
195
+ end
196
+ new(transformed_hash)
197
+ end
198
+
199
+ # Deserializes the data based on type
200
+ # @param string type Data type
201
+ # @param string value Value to be deserialized
202
+ # @return [Object] Deserialized data
203
+ def self._deserialize(type, value)
204
+ case type.to_sym
205
+ when :Time
206
+ Time.parse(value)
207
+ when :Date
208
+ Date.parse(value)
209
+ when :String
210
+ value.to_s
211
+ when :Integer
212
+ value.to_i
213
+ when :Float
214
+ value.to_f
215
+ when :Boolean
216
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
217
+ true
218
+ else
219
+ false
220
+ end
221
+ when :Object
222
+ # generic object (usually a Hash), return directly
223
+ value
224
+ when /\AArray<(?<inner_type>.+)>\z/
225
+ inner_type = Regexp.last_match[:inner_type]
226
+ value.map { |v| _deserialize(inner_type, v) }
227
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
228
+ k_type = Regexp.last_match[:k_type]
229
+ v_type = Regexp.last_match[:v_type]
230
+ {}.tap do |hash|
231
+ value.each do |k, v|
232
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
233
+ end
234
+ end
235
+ else # model
236
+ # models (e.g. Pet) or oneOf
237
+ klass = SendX.const_get(type)
238
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
239
+ end
240
+ end
241
+
242
+ # Returns the string representation of the object
243
+ # @return [String] String presentation of the object
244
+ def to_s
245
+ to_hash.to_s
246
+ end
247
+
248
+ # to_body is an alias to to_hash (backward compatibility)
249
+ # @return [Hash] Returns the object in the form of hash
250
+ def to_body
251
+ to_hash
252
+ end
253
+
254
+ # Returns the object in the form of hash
255
+ # @return [Hash] Returns the object in the form of hash
256
+ def to_hash
257
+ hash = {}
258
+ self.class.attribute_map.each_pair do |attr, param|
259
+ value = self.send(attr)
260
+ if value.nil?
261
+ is_nullable = self.class.openapi_nullable.include?(attr)
262
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
263
+ end
264
+
265
+ hash[param] = _to_hash(value)
266
+ end
267
+ hash
268
+ end
269
+
270
+ # Outputs non-array value in the form of hash
271
+ # For object, use to_hash. Otherwise, just return the value
272
+ # @param [Object] value Any valid value
273
+ # @return [Hash] Returns the value in the form of hash
274
+ def _to_hash(value)
275
+ if value.is_a?(Array)
276
+ value.compact.map { |v| _to_hash(v) }
277
+ elsif value.is_a?(Hash)
278
+ {}.tap do |hash|
279
+ value.each { |k, v| hash[k] = _to_hash(v) }
280
+ end
281
+ elsif value.respond_to? :to_hash
282
+ value.to_hash
283
+ else
284
+ value
285
+ end
286
+ end
287
+
288
+ end
289
+
290
+ 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
@@ -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,237 @@
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 TrackRequest
18
+ # Email address of the contact to track.
19
+ attr_accessor :email
20
+
21
+ attr_accessor :add_tags
22
+
23
+ attr_accessor :remove_tags
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'email' => :'email',
29
+ :'add_tags' => :'addTags',
30
+ :'remove_tags' => :'removeTags'
31
+ }
32
+ end
33
+
34
+ # Returns all the JSON keys this model knows about
35
+ def self.acceptable_attributes
36
+ attribute_map.values
37
+ end
38
+
39
+ # Attribute type mapping.
40
+ def self.openapi_types
41
+ {
42
+ :'email' => :'String',
43
+ :'add_tags' => :'Array<String>',
44
+ :'remove_tags' => :'Array<String>'
45
+ }
46
+ end
47
+
48
+ # List of attributes with nullable: true
49
+ def self.openapi_nullable
50
+ Set.new([
51
+ ])
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ if (!attributes.is_a?(Hash))
58
+ fail ArgumentError, "The input argument (attributes) must be a hash in `SendX::TrackRequest` initialize method"
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ fail ArgumentError, "`#{k}` is not a valid attribute in `SendX::TrackRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
65
+ end
66
+ h[k.to_sym] = v
67
+ }
68
+
69
+ if attributes.key?(:'email')
70
+ self.email = attributes[:'email']
71
+ end
72
+
73
+ if attributes.key?(:'add_tags')
74
+ if (value = attributes[:'add_tags']).is_a?(Array)
75
+ self.add_tags = value
76
+ end
77
+ end
78
+
79
+ if attributes.key?(:'remove_tags')
80
+ if (value = attributes[:'remove_tags']).is_a?(Array)
81
+ self.remove_tags = value
82
+ end
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
90
+ invalid_properties = Array.new
91
+ invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ warn '[DEPRECATED] the `valid?` method is obsolete'
98
+ true
99
+ end
100
+
101
+ # Checks equality by comparing each attribute.
102
+ # @param [Object] Object to be compared
103
+ def ==(o)
104
+ return true if self.equal?(o)
105
+ self.class == o.class &&
106
+ email == o.email &&
107
+ add_tags == o.add_tags &&
108
+ remove_tags == o.remove_tags
109
+ end
110
+
111
+ # @see the `==` method
112
+ # @param [Object] Object to be compared
113
+ def eql?(o)
114
+ self == o
115
+ end
116
+
117
+ # Calculates hash code according to all attributes.
118
+ # @return [Integer] Hash code
119
+ def hash
120
+ [email, add_tags, remove_tags].hash
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def self.build_from_hash(attributes)
127
+ return nil unless attributes.is_a?(Hash)
128
+ attributes = attributes.transform_keys(&:to_sym)
129
+ transformed_hash = {}
130
+ openapi_types.each_pair do |key, type|
131
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
132
+ transformed_hash["#{key}"] = nil
133
+ elsif type =~ /\AArray<(.*)>/i
134
+ # check to ensure the input is an array given that the attribute
135
+ # is documented as an array but the input is not
136
+ if attributes[attribute_map[key]].is_a?(Array)
137
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
138
+ end
139
+ elsif !attributes[attribute_map[key]].nil?
140
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
141
+ end
142
+ end
143
+ new(transformed_hash)
144
+ end
145
+
146
+ # Deserializes the data based on type
147
+ # @param string type Data type
148
+ # @param string value Value to be deserialized
149
+ # @return [Object] Deserialized data
150
+ def self._deserialize(type, value)
151
+ case type.to_sym
152
+ when :Time
153
+ Time.parse(value)
154
+ when :Date
155
+ Date.parse(value)
156
+ when :String
157
+ value.to_s
158
+ when :Integer
159
+ value.to_i
160
+ when :Float
161
+ value.to_f
162
+ when :Boolean
163
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
164
+ true
165
+ else
166
+ false
167
+ end
168
+ when :Object
169
+ # generic object (usually a Hash), return directly
170
+ value
171
+ when /\AArray<(?<inner_type>.+)>\z/
172
+ inner_type = Regexp.last_match[:inner_type]
173
+ value.map { |v| _deserialize(inner_type, v) }
174
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
175
+ k_type = Regexp.last_match[:k_type]
176
+ v_type = Regexp.last_match[:v_type]
177
+ {}.tap do |hash|
178
+ value.each do |k, v|
179
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
180
+ end
181
+ end
182
+ else # model
183
+ # models (e.g. Pet) or oneOf
184
+ klass = SendX.const_get(type)
185
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
186
+ end
187
+ end
188
+
189
+ # Returns the string representation of the object
190
+ # @return [String] String presentation of the object
191
+ def to_s
192
+ to_hash.to_s
193
+ end
194
+
195
+ # to_body is an alias to to_hash (backward compatibility)
196
+ # @return [Hash] Returns the object in the form of hash
197
+ def to_body
198
+ to_hash
199
+ end
200
+
201
+ # Returns the object in the form of hash
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_hash
204
+ hash = {}
205
+ self.class.attribute_map.each_pair do |attr, param|
206
+ value = self.send(attr)
207
+ if value.nil?
208
+ is_nullable = self.class.openapi_nullable.include?(attr)
209
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
210
+ end
211
+
212
+ hash[param] = _to_hash(value)
213
+ end
214
+ hash
215
+ end
216
+
217
+ # Outputs non-array value in the form of hash
218
+ # For object, use to_hash. Otherwise, just return the value
219
+ # @param [Object] value Any valid value
220
+ # @return [Hash] Returns the value in the form of hash
221
+ def _to_hash(value)
222
+ if value.is_a?(Array)
223
+ value.compact.map { |v| _to_hash(v) }
224
+ elsif value.is_a?(Hash)
225
+ {}.tap do |hash|
226
+ value.each { |k, v| hash[k] = _to_hash(v) }
227
+ end
228
+ elsif value.respond_to? :to_hash
229
+ value.to_hash
230
+ else
231
+ value
232
+ end
233
+ end
234
+
235
+ end
236
+
237
+ end