klaviyo_sdk 1.0.0.20220329
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +6 -0
- data/README.md +1121 -0
- data/klaviyo_sdk.gemspec +35 -0
- data/lib/klaviyo_sdk/api/campaigns_api.rb +717 -0
- data/lib/klaviyo_sdk/api/data_privacy_api.rb +86 -0
- data/lib/klaviyo_sdk/api/lists_segments_api.rb +1101 -0
- data/lib/klaviyo_sdk/api/metrics_api.rb +343 -0
- data/lib/klaviyo_sdk/api/profiles_api.rb +381 -0
- data/lib/klaviyo_sdk/api/templates_api.rb +555 -0
- data/lib/klaviyo_sdk/api/track_identify_api.rb +288 -0
- data/lib/klaviyo_sdk/api_client.rb +389 -0
- data/lib/klaviyo_sdk/api_error.rb +57 -0
- data/lib/klaviyo_sdk/configuration.rb +278 -0
- data/lib/klaviyo_sdk/models/campaign.rb +310 -0
- data/lib/klaviyo_sdk/models/check_membership_request.rb +244 -0
- data/lib/klaviyo_sdk/models/delete_email.rb +218 -0
- data/lib/klaviyo_sdk/models/delete_person.rb +218 -0
- data/lib/klaviyo_sdk/models/delete_phone.rb +219 -0
- data/lib/klaviyo_sdk/models/deprecated_get_list_response.rb +298 -0
- data/lib/klaviyo_sdk/models/deprecated_get_list_response_data.rb +263 -0
- data/lib/klaviyo_sdk/models/global_exclusion_response_data.rb +274 -0
- data/lib/klaviyo_sdk/models/identify_payload.rb +237 -0
- data/lib/klaviyo_sdk/models/identify_payload_properties.rb +327 -0
- data/lib/klaviyo_sdk/models/inline_object.rb +220 -0
- data/lib/klaviyo_sdk/models/inline_object3.rb +226 -0
- data/lib/klaviyo_sdk/models/inline_object4.rb +254 -0
- data/lib/klaviyo_sdk/models/inline_object5.rb +288 -0
- data/lib/klaviyo_sdk/models/metric.rb +265 -0
- data/lib/klaviyo_sdk/models/metric_export.rb +285 -0
- data/lib/klaviyo_sdk/models/metric_timeline.rb +271 -0
- data/lib/klaviyo_sdk/models/metric_timeline_data.rb +294 -0
- data/lib/klaviyo_sdk/models/person.rb +389 -0
- data/lib/klaviyo_sdk/models/person.rb.bak +389 -0
- data/lib/klaviyo_sdk/models/privacy_email.rb +218 -0
- data/lib/klaviyo_sdk/models/privacy_id.rb +218 -0
- data/lib/klaviyo_sdk/models/privacy_phone.rb +218 -0
- data/lib/klaviyo_sdk/models/rendered_template.rb +247 -0
- data/lib/klaviyo_sdk/models/template.rb +272 -0
- data/lib/klaviyo_sdk/models/track_payload.rb +261 -0
- data/lib/klaviyo_sdk/models/track_payload_customer_properties.rb +227 -0
- data/lib/klaviyo_sdk/models/track_payload_properties.rb +237 -0
- data/lib/klaviyo_sdk/version.rb +15 -0
- data/lib/klaviyo_sdk.rb +124 -0
- metadata +120 -0
@@ -0,0 +1,285 @@
|
|
1
|
+
=begin
|
2
|
+
#Klaviyo API
|
3
|
+
|
4
|
+
#Empowering creators to own their destiny
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2022.03.29
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.4.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Client
|
17
|
+
class MetricExport
|
18
|
+
attr_accessor :metric
|
19
|
+
|
20
|
+
attr_accessor :start_date
|
21
|
+
|
22
|
+
attr_accessor :end_date
|
23
|
+
|
24
|
+
attr_accessor :unit
|
25
|
+
|
26
|
+
attr_accessor :measurement
|
27
|
+
|
28
|
+
attr_accessor :by
|
29
|
+
|
30
|
+
attr_accessor :where
|
31
|
+
|
32
|
+
attr_accessor :results
|
33
|
+
|
34
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
35
|
+
def self.attribute_map
|
36
|
+
{
|
37
|
+
:'metric' => :'metric',
|
38
|
+
:'start_date' => :'start_date',
|
39
|
+
:'end_date' => :'end_date',
|
40
|
+
:'unit' => :'unit',
|
41
|
+
:'measurement' => :'measurement',
|
42
|
+
:'by' => :'by',
|
43
|
+
:'where' => :'where',
|
44
|
+
:'results' => :'results'
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
# Returns all the JSON keys this model knows about
|
49
|
+
def self.acceptable_attributes
|
50
|
+
attribute_map.values
|
51
|
+
end
|
52
|
+
|
53
|
+
# Attribute type mapping.
|
54
|
+
def self.openapi_types
|
55
|
+
{
|
56
|
+
:'metric' => :'Hash<String, Object>',
|
57
|
+
:'start_date' => :'String',
|
58
|
+
:'end_date' => :'String',
|
59
|
+
:'unit' => :'String',
|
60
|
+
:'measurement' => :'String',
|
61
|
+
:'by' => :'String',
|
62
|
+
:'where' => :'String',
|
63
|
+
:'results' => :'Array<Hash<String, Object>>'
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
# List of attributes with nullable: true
|
68
|
+
def self.openapi_nullable
|
69
|
+
Set.new([
|
70
|
+
])
|
71
|
+
end
|
72
|
+
|
73
|
+
# Initializes the object
|
74
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
75
|
+
def initialize(attributes = {})
|
76
|
+
if (!attributes.is_a?(Hash))
|
77
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Client::MetricExport` initialize method"
|
78
|
+
end
|
79
|
+
|
80
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
81
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
82
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
83
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Client::MetricExport`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
84
|
+
end
|
85
|
+
h[k.to_sym] = v
|
86
|
+
}
|
87
|
+
|
88
|
+
if attributes.key?(:'metric')
|
89
|
+
if (value = attributes[:'metric']).is_a?(Hash)
|
90
|
+
self.metric = value
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.key?(:'start_date')
|
95
|
+
self.start_date = attributes[:'start_date']
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes.key?(:'end_date')
|
99
|
+
self.end_date = attributes[:'end_date']
|
100
|
+
end
|
101
|
+
|
102
|
+
if attributes.key?(:'unit')
|
103
|
+
self.unit = attributes[:'unit']
|
104
|
+
end
|
105
|
+
|
106
|
+
if attributes.key?(:'measurement')
|
107
|
+
self.measurement = attributes[:'measurement']
|
108
|
+
end
|
109
|
+
|
110
|
+
if attributes.key?(:'by')
|
111
|
+
self.by = attributes[:'by']
|
112
|
+
end
|
113
|
+
|
114
|
+
if attributes.key?(:'where')
|
115
|
+
self.where = attributes[:'where']
|
116
|
+
end
|
117
|
+
|
118
|
+
if attributes.key?(:'results')
|
119
|
+
if (value = attributes[:'results']).is_a?(Array)
|
120
|
+
self.results = value
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
126
|
+
# @return Array for valid properties with the reasons
|
127
|
+
def list_invalid_properties
|
128
|
+
invalid_properties = Array.new
|
129
|
+
invalid_properties
|
130
|
+
end
|
131
|
+
|
132
|
+
# Check to see if the all the properties in the model are valid
|
133
|
+
# @return true if the model is valid
|
134
|
+
def valid?
|
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
|
+
metric == o.metric &&
|
144
|
+
start_date == o.start_date &&
|
145
|
+
end_date == o.end_date &&
|
146
|
+
unit == o.unit &&
|
147
|
+
measurement == o.measurement &&
|
148
|
+
by == o.by &&
|
149
|
+
where == o.where &&
|
150
|
+
results == o.results
|
151
|
+
end
|
152
|
+
|
153
|
+
# @see the `==` method
|
154
|
+
# @param [Object] Object to be compared
|
155
|
+
def eql?(o)
|
156
|
+
self == o
|
157
|
+
end
|
158
|
+
|
159
|
+
# Calculates hash code according to all attributes.
|
160
|
+
# @return [Integer] Hash code
|
161
|
+
def hash
|
162
|
+
[metric, start_date, end_date, unit, measurement, by, where, results].hash
|
163
|
+
end
|
164
|
+
|
165
|
+
# Builds the object from hash
|
166
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
167
|
+
# @return [Object] Returns the model itself
|
168
|
+
def self.build_from_hash(attributes)
|
169
|
+
new.build_from_hash(attributes)
|
170
|
+
end
|
171
|
+
|
172
|
+
# Builds the object from hash
|
173
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
174
|
+
# @return [Object] Returns the model itself
|
175
|
+
def build_from_hash(attributes)
|
176
|
+
return nil unless attributes.is_a?(Hash)
|
177
|
+
self.class.openapi_types.each_pair do |key, type|
|
178
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
179
|
+
self.send("#{key}=", nil)
|
180
|
+
elsif type =~ /\AArray<(.*)>/i
|
181
|
+
# check to ensure the input is an array given that the attribute
|
182
|
+
# is documented as an array but the input is not
|
183
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
184
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
185
|
+
end
|
186
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
187
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
self
|
192
|
+
end
|
193
|
+
|
194
|
+
# Deserializes the data based on type
|
195
|
+
# @param string type Data type
|
196
|
+
# @param string value Value to be deserialized
|
197
|
+
# @return [Object] Deserialized data
|
198
|
+
def _deserialize(type, value)
|
199
|
+
case type.to_sym
|
200
|
+
when :Time
|
201
|
+
Time.parse(value)
|
202
|
+
when :Date
|
203
|
+
Date.parse(value)
|
204
|
+
when :String
|
205
|
+
value.to_s
|
206
|
+
when :Integer
|
207
|
+
value.to_i
|
208
|
+
when :Float
|
209
|
+
value.to_f
|
210
|
+
when :Boolean
|
211
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
212
|
+
true
|
213
|
+
else
|
214
|
+
false
|
215
|
+
end
|
216
|
+
when :Object
|
217
|
+
# generic object (usually a Hash), return directly
|
218
|
+
value
|
219
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
220
|
+
inner_type = Regexp.last_match[:inner_type]
|
221
|
+
value.map { |v| _deserialize(inner_type, v) }
|
222
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
223
|
+
k_type = Regexp.last_match[:k_type]
|
224
|
+
v_type = Regexp.last_match[:v_type]
|
225
|
+
{}.tap do |hash|
|
226
|
+
value.each do |k, v|
|
227
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
else # model
|
231
|
+
# models (e.g. Pet) or oneOf
|
232
|
+
klass = Client.const_get(type)
|
233
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
# Returns the string representation of the object
|
238
|
+
# @return [String] String presentation of the object
|
239
|
+
def to_s
|
240
|
+
to_hash.to_s
|
241
|
+
end
|
242
|
+
|
243
|
+
# to_body is an alias to to_hash (backward compatibility)
|
244
|
+
# @return [Hash] Returns the object in the form of hash
|
245
|
+
def to_body
|
246
|
+
to_hash
|
247
|
+
end
|
248
|
+
|
249
|
+
# Returns the object in the form of hash
|
250
|
+
# @return [Hash] Returns the object in the form of hash
|
251
|
+
def to_hash
|
252
|
+
hash = {}
|
253
|
+
self.class.attribute_map.each_pair do |attr, param|
|
254
|
+
value = self.send(attr)
|
255
|
+
if value.nil?
|
256
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
257
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
258
|
+
end
|
259
|
+
|
260
|
+
hash[param] = _to_hash(value)
|
261
|
+
end
|
262
|
+
hash
|
263
|
+
end
|
264
|
+
|
265
|
+
# Outputs non-array value in the form of hash
|
266
|
+
# For object, use to_hash. Otherwise, just return the value
|
267
|
+
# @param [Object] value Any valid value
|
268
|
+
# @return [Hash] Returns the value in the form of hash
|
269
|
+
def _to_hash(value)
|
270
|
+
if value.is_a?(Array)
|
271
|
+
value.compact.map { |v| _to_hash(v) }
|
272
|
+
elsif value.is_a?(Hash)
|
273
|
+
{}.tap do |hash|
|
274
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
275
|
+
end
|
276
|
+
elsif value.respond_to? :to_hash
|
277
|
+
value.to_hash
|
278
|
+
else
|
279
|
+
value
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
end
|
284
|
+
|
285
|
+
end
|
@@ -0,0 +1,271 @@
|
|
1
|
+
=begin
|
2
|
+
#Klaviyo API
|
3
|
+
|
4
|
+
#Empowering creators to own their destiny
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2022.03.29
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 5.4.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
require 'time'
|
15
|
+
|
16
|
+
module Client
|
17
|
+
class MetricTimeline
|
18
|
+
attr_accessor :object
|
19
|
+
|
20
|
+
attr_accessor :count
|
21
|
+
|
22
|
+
attr_accessor :data
|
23
|
+
|
24
|
+
attr_accessor :_next
|
25
|
+
|
26
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
27
|
+
def self.attribute_map
|
28
|
+
{
|
29
|
+
:'object' => :'object',
|
30
|
+
:'count' => :'count',
|
31
|
+
:'data' => :'data',
|
32
|
+
:'_next' => :'next'
|
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
|
+
:'object' => :'String',
|
45
|
+
:'count' => :'Integer',
|
46
|
+
:'data' => :'Array<MetricTimelineData>',
|
47
|
+
:'_next' => :'String'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# List of attributes with nullable: true
|
52
|
+
def self.openapi_nullable
|
53
|
+
Set.new([
|
54
|
+
])
|
55
|
+
end
|
56
|
+
|
57
|
+
# Initializes the object
|
58
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
59
|
+
def initialize(attributes = {})
|
60
|
+
if (!attributes.is_a?(Hash))
|
61
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Client::MetricTimeline` initialize method"
|
62
|
+
end
|
63
|
+
|
64
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
65
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
66
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
67
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Client::MetricTimeline`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
68
|
+
end
|
69
|
+
h[k.to_sym] = v
|
70
|
+
}
|
71
|
+
|
72
|
+
if attributes.key?(:'object')
|
73
|
+
self.object = attributes[:'object']
|
74
|
+
end
|
75
|
+
|
76
|
+
if attributes.key?(:'count')
|
77
|
+
self.count = attributes[:'count']
|
78
|
+
end
|
79
|
+
|
80
|
+
if attributes.key?(:'data')
|
81
|
+
if (value = attributes[:'data']).is_a?(Array)
|
82
|
+
self.data = value
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.key?(:'_next')
|
87
|
+
self._next = attributes[:'_next']
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
92
|
+
# @return Array for valid properties with the reasons
|
93
|
+
def list_invalid_properties
|
94
|
+
invalid_properties = Array.new
|
95
|
+
if !@data.nil? && @data.length > 100
|
96
|
+
invalid_properties.push('invalid value for "data", number of items must be less than or equal to 100.')
|
97
|
+
end
|
98
|
+
|
99
|
+
if !@data.nil? && @data.length < 0
|
100
|
+
invalid_properties.push('invalid value for "data", number of items must be greater than or equal to 0.')
|
101
|
+
end
|
102
|
+
|
103
|
+
invalid_properties
|
104
|
+
end
|
105
|
+
|
106
|
+
# Check to see if the all the properties in the model are valid
|
107
|
+
# @return true if the model is valid
|
108
|
+
def valid?
|
109
|
+
return false if !@data.nil? && @data.length > 100
|
110
|
+
return false if !@data.nil? && @data.length < 0
|
111
|
+
true
|
112
|
+
end
|
113
|
+
|
114
|
+
# Custom attribute writer method with validation
|
115
|
+
# @param [Object] data Value to be assigned
|
116
|
+
def data=(data)
|
117
|
+
if !data.nil? && data.length > 100
|
118
|
+
fail ArgumentError, 'invalid value for "data", number of items must be less than or equal to 100.'
|
119
|
+
end
|
120
|
+
|
121
|
+
if !data.nil? && data.length < 0
|
122
|
+
fail ArgumentError, 'invalid value for "data", number of items must be greater than or equal to 0.'
|
123
|
+
end
|
124
|
+
|
125
|
+
@data = data
|
126
|
+
end
|
127
|
+
|
128
|
+
# Checks equality by comparing each attribute.
|
129
|
+
# @param [Object] Object to be compared
|
130
|
+
def ==(o)
|
131
|
+
return true if self.equal?(o)
|
132
|
+
self.class == o.class &&
|
133
|
+
object == o.object &&
|
134
|
+
count == o.count &&
|
135
|
+
data == o.data &&
|
136
|
+
_next == o._next
|
137
|
+
end
|
138
|
+
|
139
|
+
# @see the `==` method
|
140
|
+
# @param [Object] Object to be compared
|
141
|
+
def eql?(o)
|
142
|
+
self == o
|
143
|
+
end
|
144
|
+
|
145
|
+
# Calculates hash code according to all attributes.
|
146
|
+
# @return [Integer] Hash code
|
147
|
+
def hash
|
148
|
+
[object, count, data, _next].hash
|
149
|
+
end
|
150
|
+
|
151
|
+
# Builds the object from hash
|
152
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
153
|
+
# @return [Object] Returns the model itself
|
154
|
+
def self.build_from_hash(attributes)
|
155
|
+
new.build_from_hash(attributes)
|
156
|
+
end
|
157
|
+
|
158
|
+
# Builds the object from hash
|
159
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
160
|
+
# @return [Object] Returns the model itself
|
161
|
+
def build_from_hash(attributes)
|
162
|
+
return nil unless attributes.is_a?(Hash)
|
163
|
+
self.class.openapi_types.each_pair do |key, type|
|
164
|
+
if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
|
165
|
+
self.send("#{key}=", nil)
|
166
|
+
elsif type =~ /\AArray<(.*)>/i
|
167
|
+
# check to ensure the input is an array given that the attribute
|
168
|
+
# is documented as an array but the input is not
|
169
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
170
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
171
|
+
end
|
172
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
173
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
self
|
178
|
+
end
|
179
|
+
|
180
|
+
# Deserializes the data based on type
|
181
|
+
# @param string type Data type
|
182
|
+
# @param string value Value to be deserialized
|
183
|
+
# @return [Object] Deserialized data
|
184
|
+
def _deserialize(type, value)
|
185
|
+
case type.to_sym
|
186
|
+
when :Time
|
187
|
+
Time.parse(value)
|
188
|
+
when :Date
|
189
|
+
Date.parse(value)
|
190
|
+
when :String
|
191
|
+
value.to_s
|
192
|
+
when :Integer
|
193
|
+
value.to_i
|
194
|
+
when :Float
|
195
|
+
value.to_f
|
196
|
+
when :Boolean
|
197
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
198
|
+
true
|
199
|
+
else
|
200
|
+
false
|
201
|
+
end
|
202
|
+
when :Object
|
203
|
+
# generic object (usually a Hash), return directly
|
204
|
+
value
|
205
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
206
|
+
inner_type = Regexp.last_match[:inner_type]
|
207
|
+
value.map { |v| _deserialize(inner_type, v) }
|
208
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
209
|
+
k_type = Regexp.last_match[:k_type]
|
210
|
+
v_type = Regexp.last_match[:v_type]
|
211
|
+
{}.tap do |hash|
|
212
|
+
value.each do |k, v|
|
213
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
else # model
|
217
|
+
# models (e.g. Pet) or oneOf
|
218
|
+
klass = Client.const_get(type)
|
219
|
+
klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns the string representation of the object
|
224
|
+
# @return [String] String presentation of the object
|
225
|
+
def to_s
|
226
|
+
to_hash.to_s
|
227
|
+
end
|
228
|
+
|
229
|
+
# to_body is an alias to to_hash (backward compatibility)
|
230
|
+
# @return [Hash] Returns the object in the form of hash
|
231
|
+
def to_body
|
232
|
+
to_hash
|
233
|
+
end
|
234
|
+
|
235
|
+
# Returns the object in the form of hash
|
236
|
+
# @return [Hash] Returns the object in the form of hash
|
237
|
+
def to_hash
|
238
|
+
hash = {}
|
239
|
+
self.class.attribute_map.each_pair do |attr, param|
|
240
|
+
value = self.send(attr)
|
241
|
+
if value.nil?
|
242
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
243
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
244
|
+
end
|
245
|
+
|
246
|
+
hash[param] = _to_hash(value)
|
247
|
+
end
|
248
|
+
hash
|
249
|
+
end
|
250
|
+
|
251
|
+
# Outputs non-array value in the form of hash
|
252
|
+
# For object, use to_hash. Otherwise, just return the value
|
253
|
+
# @param [Object] value Any valid value
|
254
|
+
# @return [Hash] Returns the value in the form of hash
|
255
|
+
def _to_hash(value)
|
256
|
+
if value.is_a?(Array)
|
257
|
+
value.compact.map { |v| _to_hash(v) }
|
258
|
+
elsif value.is_a?(Hash)
|
259
|
+
{}.tap do |hash|
|
260
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
261
|
+
end
|
262
|
+
elsif value.respond_to? :to_hash
|
263
|
+
value.to_hash
|
264
|
+
else
|
265
|
+
value
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|