algolia 3.0.0.alpha.14 → 3.0.0.alpha.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +2 -2
- data/lib/algolia/api/abtesting_client.rb +4 -4
- data/lib/algolia/api/analytics_client.rb +268 -98
- data/lib/algolia/api/ingestion_client.rb +4 -4
- data/lib/algolia/api/insights_client.rb +4 -4
- data/lib/algolia/api/monitoring_client.rb +4 -4
- data/lib/algolia/api/personalization_client.rb +4 -4
- data/lib/algolia/api/query_suggestions_client.rb +4 -4
- data/lib/algolia/api/recommend_client.rb +4 -4
- data/lib/algolia/api/search_client.rb +4 -4
- data/lib/algolia/models/abtesting/{currencies_value.rb → currency.rb} +3 -3
- data/lib/algolia/models/abtesting/variant.rb +2 -5
- data/lib/algolia/models/analytics/click_positions_inner.rb +242 -0
- data/lib/algolia/models/analytics/currencies_value.rb +208 -0
- data/lib/algolia/models/analytics/daily_add_to_cart_rates.rb +265 -0
- data/lib/algolia/models/analytics/daily_average_clicks.rb +249 -0
- data/lib/algolia/models/analytics/{click_through_rate_event.rb → daily_click_through_rates.rb} +24 -14
- data/lib/algolia/models/analytics/daily_conversion_rates.rb +265 -0
- data/lib/algolia/models/analytics/{no_click_rate_event.rb → daily_no_click_rates.rb} +21 -7
- data/lib/algolia/models/analytics/{no_results_rate_event.rb → daily_no_results_rates.rb} +7 -7
- data/lib/algolia/models/analytics/{conversion_rate_event.rb → daily_purchase_rates.rb} +18 -22
- data/lib/algolia/models/analytics/{average_click_event.rb → daily_revenue.rb} +15 -25
- data/lib/algolia/models/analytics/{search_event.rb → daily_searches.rb} +4 -4
- data/lib/algolia/models/analytics/{search_no_result_event.rb → daily_searches_no_clicks.rb} +19 -5
- data/lib/algolia/models/analytics/{search_no_click_event.rb → daily_searches_no_results.rb} +19 -5
- data/lib/algolia/models/analytics/{user_with_date.rb → daily_users.rb} +5 -5
- data/lib/algolia/models/analytics/get_add_to_cart_rate_response.rb +267 -0
- data/lib/algolia/models/analytics/get_average_click_position_response.rb +31 -5
- data/lib/algolia/models/analytics/get_click_positions_response.rb +6 -6
- data/lib/algolia/models/analytics/get_click_through_rate_response.rb +22 -12
- data/lib/algolia/models/analytics/get_conversion_rate_response.rb +267 -0
- data/lib/algolia/models/analytics/get_no_click_rate_response.rb +19 -5
- data/lib/algolia/models/analytics/get_no_results_rate_response.rb +5 -5
- data/lib/algolia/models/analytics/{get_conversation_rate_response.rb → get_purchase_rate_response.rb} +19 -23
- data/lib/algolia/models/analytics/{click_position.rb → get_revenue.rb} +23 -21
- data/lib/algolia/models/analytics/get_searches_count_response.rb +2 -2
- data/lib/algolia/models/analytics/get_searches_no_clicks_response.rb +2 -2
- data/lib/algolia/models/analytics/get_searches_no_results_response.rb +2 -2
- data/lib/algolia/models/analytics/get_status_response.rb +4 -2
- data/lib/algolia/models/analytics/get_top_countries_response.rb +1 -1
- data/lib/algolia/models/analytics/get_top_filter_attributes_response.rb +1 -1
- data/lib/algolia/models/analytics/get_top_filter_for_attribute.rb +23 -2
- data/lib/algolia/models/analytics/get_top_filters_no_results_response.rb +4 -2
- data/lib/algolia/models/analytics/get_top_filters_no_results_value.rb +23 -2
- data/lib/algolia/models/analytics/get_top_hits_response.rb +2 -1
- data/lib/algolia/models/analytics/get_top_searches_response.rb +2 -1
- data/lib/algolia/models/analytics/get_users_count_response.rb +3 -3
- data/lib/algolia/models/analytics/operator.rb +38 -0
- data/lib/algolia/models/analytics/top_country.rb +1 -1
- data/lib/algolia/models/analytics/top_hit.rb +1 -1
- data/lib/algolia/models/analytics/top_hit_with_analytics.rb +60 -21
- data/lib/algolia/models/analytics/top_hit_with_revenue_analytics.rb +437 -0
- data/lib/algolia/models/analytics/top_hits_response.rb +1 -1
- data/lib/algolia/models/analytics/top_hits_response_with_analytics.rb +1 -1
- data/lib/algolia/models/analytics/top_hits_response_with_revenue_analytics.rb +201 -0
- data/lib/algolia/models/analytics/top_search.rb +2 -2
- data/lib/algolia/models/analytics/top_search_with_analytics.rb +99 -17
- data/lib/algolia/models/analytics/top_search_with_revenue_analytics.rb +504 -0
- data/lib/algolia/models/analytics/top_searches_response.rb +1 -1
- data/lib/algolia/models/analytics/top_searches_response_with_analytics.rb +1 -1
- data/lib/algolia/models/analytics/top_searches_response_with_revenue_analytics.rb +201 -0
- data/lib/algolia/version.rb +1 -1
- metadata +26 -14
@@ -0,0 +1,208 @@
|
|
1
|
+
# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'time'
|
5
|
+
|
6
|
+
module Algolia
|
7
|
+
module Analytics
|
8
|
+
# Currency code.
|
9
|
+
class CurrenciesValue
|
10
|
+
# Currency code.
|
11
|
+
attr_accessor :currency
|
12
|
+
|
13
|
+
# Revenue associated with this search in this currency.
|
14
|
+
attr_accessor :revenue
|
15
|
+
|
16
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
17
|
+
def self.attribute_map
|
18
|
+
{
|
19
|
+
:currency => :currency,
|
20
|
+
:revenue => :revenue
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns all the JSON keys this model knows about
|
25
|
+
def self.acceptable_attributes
|
26
|
+
attribute_map.values
|
27
|
+
end
|
28
|
+
|
29
|
+
# Attribute type mapping.
|
30
|
+
def self.types_mapping
|
31
|
+
{
|
32
|
+
:currency => :String,
|
33
|
+
:revenue => :Float
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# List of attributes with nullable: true
|
38
|
+
def self.openapi_nullable
|
39
|
+
Set.new([])
|
40
|
+
end
|
41
|
+
|
42
|
+
# Initializes the object
|
43
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
44
|
+
def initialize(attributes = {})
|
45
|
+
unless attributes.is_a?(Hash)
|
46
|
+
raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::CurrenciesValue` initialize method"
|
47
|
+
end
|
48
|
+
|
49
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
50
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
51
|
+
unless self.class.attribute_map.key?(k.to_sym)
|
52
|
+
raise ArgumentError,
|
53
|
+
"`#{k}` is not a valid attribute in `Algolia::CurrenciesValue`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
54
|
+
end
|
55
|
+
|
56
|
+
h[k.to_sym] = v
|
57
|
+
end
|
58
|
+
|
59
|
+
if attributes.key?(:currency)
|
60
|
+
self.currency = attributes[:currency]
|
61
|
+
end
|
62
|
+
|
63
|
+
if attributes.key?(:revenue)
|
64
|
+
self.revenue = attributes[:revenue]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Checks equality by comparing each attribute.
|
69
|
+
# @param [Object] Object to be compared
|
70
|
+
def ==(other)
|
71
|
+
return true if equal?(other)
|
72
|
+
|
73
|
+
self.class == other.class &&
|
74
|
+
currency == other.currency &&
|
75
|
+
revenue == other.revenue
|
76
|
+
end
|
77
|
+
|
78
|
+
# @see the `==` method
|
79
|
+
# @param [Object] Object to be compared
|
80
|
+
def eql?(other)
|
81
|
+
self == other
|
82
|
+
end
|
83
|
+
|
84
|
+
# Calculates hash code according to all attributes.
|
85
|
+
# @return [Integer] Hash code
|
86
|
+
def hash
|
87
|
+
[currency, revenue].hash
|
88
|
+
end
|
89
|
+
|
90
|
+
# Builds the object from hash
|
91
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
92
|
+
# @return [Object] Returns the model itself
|
93
|
+
def self.build_from_hash(attributes)
|
94
|
+
return nil unless attributes.is_a?(Hash)
|
95
|
+
|
96
|
+
attributes = attributes.transform_keys(&:to_sym)
|
97
|
+
transformed_hash = {}
|
98
|
+
types_mapping.each_pair do |key, type|
|
99
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
100
|
+
transformed_hash[key.to_sym] = nil
|
101
|
+
elsif type =~ /\AArray<(.*)>/i
|
102
|
+
# check to ensure the input is an array given that the attribute
|
103
|
+
# is documented as an array but the input is not
|
104
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
105
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
|
106
|
+
end
|
107
|
+
elsif !attributes[attribute_map[key]].nil?
|
108
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
109
|
+
end
|
110
|
+
end
|
111
|
+
new(transformed_hash)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Deserializes the data based on type
|
115
|
+
# @param string type Data type
|
116
|
+
# @param string value Value to be deserialized
|
117
|
+
# @return [Object] Deserialized data
|
118
|
+
def self._deserialize(type, value)
|
119
|
+
case type.to_sym
|
120
|
+
when :Time
|
121
|
+
Time.parse(value)
|
122
|
+
when :Date
|
123
|
+
Date.parse(value)
|
124
|
+
when :String
|
125
|
+
value.to_s
|
126
|
+
when :Integer
|
127
|
+
value.to_i
|
128
|
+
when :Float
|
129
|
+
value.to_f
|
130
|
+
when :Boolean
|
131
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
132
|
+
true
|
133
|
+
else
|
134
|
+
false
|
135
|
+
end
|
136
|
+
when :Object
|
137
|
+
# generic object (usually a Hash), return directly
|
138
|
+
value
|
139
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
140
|
+
inner_type = Regexp.last_match[:inner_type]
|
141
|
+
value.map { |v| _deserialize(inner_type, v) }
|
142
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
143
|
+
k_type = Regexp.last_match[:k_type]
|
144
|
+
v_type = Regexp.last_match[:v_type]
|
145
|
+
{}.tap do |hash|
|
146
|
+
value.each do |k, v|
|
147
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
else # model
|
151
|
+
# models (e.g. Pet) or oneOf
|
152
|
+
klass = Algolia::Analytics.const_get(type)
|
153
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# Returns the string representation of the object
|
158
|
+
# @return [String] String presentation of the object
|
159
|
+
def to_s
|
160
|
+
to_hash.to_s
|
161
|
+
end
|
162
|
+
|
163
|
+
# to_body is an alias to to_hash (backward compatibility)
|
164
|
+
# @return [Hash] Returns the object in the form of hash
|
165
|
+
def to_body
|
166
|
+
to_hash
|
167
|
+
end
|
168
|
+
|
169
|
+
def to_json(*_args)
|
170
|
+
to_hash.to_json
|
171
|
+
end
|
172
|
+
|
173
|
+
# Returns the object in the form of hash
|
174
|
+
# @return [Hash] Returns the object in the form of hash
|
175
|
+
def to_hash
|
176
|
+
hash = {}
|
177
|
+
self.class.attribute_map.each_pair do |attr, param|
|
178
|
+
value = send(attr)
|
179
|
+
if value.nil?
|
180
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
181
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
182
|
+
end
|
183
|
+
|
184
|
+
hash[param] = _to_hash(value)
|
185
|
+
end
|
186
|
+
hash
|
187
|
+
end
|
188
|
+
|
189
|
+
# Outputs non-array value in the form of hash
|
190
|
+
# For object, use to_hash. Otherwise, just return the value
|
191
|
+
# @param [Object] value Any valid value
|
192
|
+
# @return [Hash] Returns the value in the form of hash
|
193
|
+
def _to_hash(value)
|
194
|
+
if value.is_a?(Array)
|
195
|
+
value.compact.map { |v| _to_hash(v) }
|
196
|
+
elsif value.is_a?(Hash)
|
197
|
+
{}.tap do |hash|
|
198
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
199
|
+
end
|
200
|
+
elsif value.respond_to? :to_hash
|
201
|
+
value.to_hash
|
202
|
+
else
|
203
|
+
value
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
@@ -0,0 +1,265 @@
|
|
1
|
+
# Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'time'
|
5
|
+
|
6
|
+
module Algolia
|
7
|
+
module Analytics
|
8
|
+
class DailyAddToCartRates
|
9
|
+
# Add-to-cart rate, calculated as number of tracked searches with at least one add-to-cart event divided by the number of tracked searches. If null, Algolia didn't receive any search requests with `clickAnalytics` set to true.
|
10
|
+
attr_accessor :rate
|
11
|
+
|
12
|
+
# Number of tracked searches. Tracked searches are search requests where the `clickAnalytics` parameter is true.
|
13
|
+
attr_accessor :tracked_search_count
|
14
|
+
|
15
|
+
# Number of add-to-cart events from this search.
|
16
|
+
attr_accessor :add_to_cart_count
|
17
|
+
|
18
|
+
# Date in the format YYYY-MM-DD.
|
19
|
+
attr_accessor :date
|
20
|
+
|
21
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
22
|
+
def self.attribute_map
|
23
|
+
{
|
24
|
+
:rate => :rate,
|
25
|
+
:tracked_search_count => :trackedSearchCount,
|
26
|
+
:add_to_cart_count => :addToCartCount,
|
27
|
+
:date => :date
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns all the JSON keys this model knows about
|
32
|
+
def self.acceptable_attributes
|
33
|
+
attribute_map.values
|
34
|
+
end
|
35
|
+
|
36
|
+
# Attribute type mapping.
|
37
|
+
def self.types_mapping
|
38
|
+
{
|
39
|
+
:rate => :Float,
|
40
|
+
:tracked_search_count => :Integer,
|
41
|
+
:add_to_cart_count => :Integer,
|
42
|
+
:date => :String
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
# List of attributes with nullable: true
|
47
|
+
def self.openapi_nullable
|
48
|
+
Set.new([
|
49
|
+
:rate
|
50
|
+
])
|
51
|
+
end
|
52
|
+
|
53
|
+
# Initializes the object
|
54
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
55
|
+
def initialize(attributes = {})
|
56
|
+
unless attributes.is_a?(Hash)
|
57
|
+
raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::DailyAddToCartRates` initialize method"
|
58
|
+
end
|
59
|
+
|
60
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
61
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
62
|
+
unless self.class.attribute_map.key?(k.to_sym)
|
63
|
+
raise ArgumentError,
|
64
|
+
"`#{k}` is not a valid attribute in `Algolia::DailyAddToCartRates`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
65
|
+
end
|
66
|
+
|
67
|
+
h[k.to_sym] = v
|
68
|
+
end
|
69
|
+
|
70
|
+
if attributes.key?(:rate)
|
71
|
+
self.rate = attributes[:rate]
|
72
|
+
else
|
73
|
+
self.rate = nil
|
74
|
+
end
|
75
|
+
|
76
|
+
if attributes.key?(:tracked_search_count)
|
77
|
+
self.tracked_search_count = attributes[:tracked_search_count]
|
78
|
+
else
|
79
|
+
self.tracked_search_count = nil
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.key?(:add_to_cart_count)
|
83
|
+
self.add_to_cart_count = attributes[:add_to_cart_count]
|
84
|
+
else
|
85
|
+
self.add_to_cart_count = nil
|
86
|
+
end
|
87
|
+
|
88
|
+
if attributes.key?(:date)
|
89
|
+
self.date = attributes[:date]
|
90
|
+
else
|
91
|
+
self.date = nil
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Custom attribute writer method with validation
|
96
|
+
# @param [Object] rate Value to be assigned
|
97
|
+
def rate=(rate)
|
98
|
+
if !rate.nil? && rate > 1
|
99
|
+
raise ArgumentError, 'invalid value for "rate", must be smaller than or equal to 1.'
|
100
|
+
end
|
101
|
+
|
102
|
+
if !rate.nil? && rate < 0
|
103
|
+
raise ArgumentError, 'invalid value for "rate", must be greater than or equal to 0.'
|
104
|
+
end
|
105
|
+
|
106
|
+
@rate = rate
|
107
|
+
end
|
108
|
+
|
109
|
+
# Custom attribute writer method with validation
|
110
|
+
# @param [Object] add_to_cart_count Value to be assigned
|
111
|
+
def add_to_cart_count=(add_to_cart_count)
|
112
|
+
if add_to_cart_count.nil?
|
113
|
+
raise ArgumentError, 'add_to_cart_count cannot be nil'
|
114
|
+
end
|
115
|
+
|
116
|
+
if add_to_cart_count < 0
|
117
|
+
raise ArgumentError, 'invalid value for "add_to_cart_count", must be greater than or equal to 0.'
|
118
|
+
end
|
119
|
+
|
120
|
+
@add_to_cart_count = add_to_cart_count
|
121
|
+
end
|
122
|
+
|
123
|
+
# Checks equality by comparing each attribute.
|
124
|
+
# @param [Object] Object to be compared
|
125
|
+
def ==(other)
|
126
|
+
return true if equal?(other)
|
127
|
+
|
128
|
+
self.class == other.class &&
|
129
|
+
rate == other.rate &&
|
130
|
+
tracked_search_count == other.tracked_search_count &&
|
131
|
+
add_to_cart_count == other.add_to_cart_count &&
|
132
|
+
date == other.date
|
133
|
+
end
|
134
|
+
|
135
|
+
# @see the `==` method
|
136
|
+
# @param [Object] Object to be compared
|
137
|
+
def eql?(other)
|
138
|
+
self == other
|
139
|
+
end
|
140
|
+
|
141
|
+
# Calculates hash code according to all attributes.
|
142
|
+
# @return [Integer] Hash code
|
143
|
+
def hash
|
144
|
+
[rate, tracked_search_count, add_to_cart_count, date].hash
|
145
|
+
end
|
146
|
+
|
147
|
+
# Builds the object from hash
|
148
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
149
|
+
# @return [Object] Returns the model itself
|
150
|
+
def self.build_from_hash(attributes)
|
151
|
+
return nil unless attributes.is_a?(Hash)
|
152
|
+
|
153
|
+
attributes = attributes.transform_keys(&:to_sym)
|
154
|
+
transformed_hash = {}
|
155
|
+
types_mapping.each_pair do |key, type|
|
156
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
157
|
+
transformed_hash[key.to_sym] = nil
|
158
|
+
elsif type =~ /\AArray<(.*)>/i
|
159
|
+
# check to ensure the input is an array given that the attribute
|
160
|
+
# is documented as an array but the input is not
|
161
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
162
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
|
163
|
+
end
|
164
|
+
elsif !attributes[attribute_map[key]].nil?
|
165
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
166
|
+
end
|
167
|
+
end
|
168
|
+
new(transformed_hash)
|
169
|
+
end
|
170
|
+
|
171
|
+
# Deserializes the data based on type
|
172
|
+
# @param string type Data type
|
173
|
+
# @param string value Value to be deserialized
|
174
|
+
# @return [Object] Deserialized data
|
175
|
+
def self._deserialize(type, value)
|
176
|
+
case type.to_sym
|
177
|
+
when :Time
|
178
|
+
Time.parse(value)
|
179
|
+
when :Date
|
180
|
+
Date.parse(value)
|
181
|
+
when :String
|
182
|
+
value.to_s
|
183
|
+
when :Integer
|
184
|
+
value.to_i
|
185
|
+
when :Float
|
186
|
+
value.to_f
|
187
|
+
when :Boolean
|
188
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
189
|
+
true
|
190
|
+
else
|
191
|
+
false
|
192
|
+
end
|
193
|
+
when :Object
|
194
|
+
# generic object (usually a Hash), return directly
|
195
|
+
value
|
196
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
197
|
+
inner_type = Regexp.last_match[:inner_type]
|
198
|
+
value.map { |v| _deserialize(inner_type, v) }
|
199
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
200
|
+
k_type = Regexp.last_match[:k_type]
|
201
|
+
v_type = Regexp.last_match[:v_type]
|
202
|
+
{}.tap do |hash|
|
203
|
+
value.each do |k, v|
|
204
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
else # model
|
208
|
+
# models (e.g. Pet) or oneOf
|
209
|
+
klass = Algolia::Analytics.const_get(type)
|
210
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
# Returns the string representation of the object
|
215
|
+
# @return [String] String presentation of the object
|
216
|
+
def to_s
|
217
|
+
to_hash.to_s
|
218
|
+
end
|
219
|
+
|
220
|
+
# to_body is an alias to to_hash (backward compatibility)
|
221
|
+
# @return [Hash] Returns the object in the form of hash
|
222
|
+
def to_body
|
223
|
+
to_hash
|
224
|
+
end
|
225
|
+
|
226
|
+
def to_json(*_args)
|
227
|
+
to_hash.to_json
|
228
|
+
end
|
229
|
+
|
230
|
+
# Returns the object in the form of hash
|
231
|
+
# @return [Hash] Returns the object in the form of hash
|
232
|
+
def to_hash
|
233
|
+
hash = {}
|
234
|
+
self.class.attribute_map.each_pair do |attr, param|
|
235
|
+
value = send(attr)
|
236
|
+
if value.nil?
|
237
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
238
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
239
|
+
end
|
240
|
+
|
241
|
+
hash[param] = _to_hash(value)
|
242
|
+
end
|
243
|
+
hash
|
244
|
+
end
|
245
|
+
|
246
|
+
# Outputs non-array value in the form of hash
|
247
|
+
# For object, use to_hash. Otherwise, just return the value
|
248
|
+
# @param [Object] value Any valid value
|
249
|
+
# @return [Hash] Returns the value in the form of hash
|
250
|
+
def _to_hash(value)
|
251
|
+
if value.is_a?(Array)
|
252
|
+
value.compact.map { |v| _to_hash(v) }
|
253
|
+
elsif value.is_a?(Hash)
|
254
|
+
{}.tap do |hash|
|
255
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
256
|
+
end
|
257
|
+
elsif value.respond_to? :to_hash
|
258
|
+
value.to_hash
|
259
|
+
else
|
260
|
+
value
|
261
|
+
end
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|