algolia 3.0.0.alpha.17 → 3.0.0.alpha.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +4 -4
- data/lib/algolia/api/abtesting_client.rb +20 -20
- data/lib/algolia/api/personalization_client.rb +12 -12
- data/lib/algolia/models/abtesting/ab_test.rb +41 -16
- data/lib/algolia/models/abtesting/ab_test_configuration.rb +217 -0
- data/lib/algolia/models/abtesting/ab_test_response.rb +2 -2
- data/lib/algolia/models/abtesting/ab_tests_variant.rb +21 -3
- data/lib/algolia/models/abtesting/ab_tests_variant_search_params.rb +21 -3
- data/lib/algolia/models/abtesting/add_ab_tests_request.rb +1 -1
- data/lib/algolia/models/abtesting/custom_search_params.rb +1 -1
- data/lib/algolia/models/abtesting/effect.rb +35 -0
- data/lib/algolia/models/abtesting/empty_search.rb +198 -0
- data/lib/algolia/models/abtesting/list_ab_tests_response.rb +1 -1
- data/lib/algolia/models/abtesting/minimum_detectable_effect.rb +247 -0
- data/lib/algolia/models/abtesting/outliers.rb +198 -0
- data/lib/algolia/models/abtesting/status.rb +35 -0
- data/lib/algolia/models/abtesting/variant.rb +31 -13
- data/lib/algolia/models/ingestion/destination_index_name.rb +1 -1
- data/lib/algolia/models/ingestion/shopify_input.rb +212 -0
- data/lib/algolia/models/ingestion/shopify_market.rb +227 -0
- data/lib/algolia/models/ingestion/shopify_metafield.rb +221 -0
- data/lib/algolia/models/ingestion/source_input.rb +2 -1
- data/lib/algolia/models/ingestion/source_shopify.rb +278 -0
- data/lib/algolia/models/ingestion/source_shopify_base.rb +199 -0
- data/lib/algolia/models/ingestion/source_update_input.rb +2 -1
- data/lib/algolia/models/ingestion/source_update_shopify.rb +258 -0
- data/lib/algolia/models/ingestion/task_input.rb +1 -0
- data/lib/algolia/models/insights/added_to_cart_object_ids.rb +1 -1
- data/lib/algolia/models/insights/added_to_cart_object_ids_after_search.rb +1 -1
- data/lib/algolia/models/insights/clicked_filters.rb +1 -1
- data/lib/algolia/models/insights/clicked_object_ids.rb +1 -1
- data/lib/algolia/models/insights/clicked_object_ids_after_search.rb +1 -1
- data/lib/algolia/models/insights/converted_filters.rb +1 -1
- data/lib/algolia/models/insights/converted_object_ids.rb +1 -1
- data/lib/algolia/models/insights/converted_object_ids_after_search.rb +1 -1
- data/lib/algolia/models/insights/purchased_object_ids.rb +1 -1
- data/lib/algolia/models/insights/purchased_object_ids_after_search.rb +1 -1
- data/lib/algolia/models/insights/viewed_filters.rb +1 -1
- data/lib/algolia/models/insights/viewed_object_ids.rb +1 -1
- data/lib/algolia/models/personalization/delete_user_profile_response.rb +2 -2
- data/lib/algolia/models/personalization/event_scoring.rb +25 -4
- data/lib/algolia/models/personalization/event_type.rb +34 -0
- data/lib/algolia/models/personalization/facet_scoring.rb +2 -2
- data/lib/algolia/models/personalization/get_user_token_response.rb +3 -3
- data/lib/algolia/models/personalization/personalization_strategy_params.rb +21 -3
- data/lib/algolia/models/query-suggestions/get_config_status200_response.rb +1 -1
- data/lib/algolia/models/query-suggestions/query_suggestions_configuration_response.rb +1 -1
- data/lib/algolia/models/query-suggestions/query_suggestions_configuration_with_index.rb +1 -1
- data/lib/algolia/models/query-suggestions/source_index.rb +1 -1
- data/lib/algolia/models/recommend/base_recommend_request.rb +1 -1
- data/lib/algolia/models/recommend/base_search_params.rb +3 -3
- data/lib/algolia/models/recommend/base_search_params_without_query.rb +3 -3
- data/lib/algolia/models/recommend/bought_together_query.rb +1 -1
- data/lib/algolia/models/recommend/fallback_params.rb +9 -9
- data/lib/algolia/models/recommend/index_settings_as_search_params.rb +6 -6
- data/lib/algolia/models/recommend/looking_similar_query.rb +1 -1
- data/lib/algolia/models/recommend/re_ranking_apply_filter.rb +1 -1
- data/lib/algolia/models/recommend/recommended_for_you_query.rb +1 -1
- data/lib/algolia/models/recommend/related_query.rb +1 -1
- data/lib/algolia/models/recommend/search_params.rb +9 -9
- data/lib/algolia/models/recommend/search_params_object.rb +10 -9
- data/lib/algolia/models/recommend/trending_facets_query.rb +1 -1
- data/lib/algolia/models/recommend/trending_items_query.rb +1 -1
- data/lib/algolia/models/search/base_index_settings.rb +9 -9
- data/lib/algolia/models/search/base_search_params.rb +3 -3
- data/lib/algolia/models/search/base_search_params_without_query.rb +3 -3
- data/lib/algolia/models/search/browse_params_object.rb +9 -9
- data/lib/algolia/models/search/consequence_params.rb +9 -9
- data/lib/algolia/models/search/delete_by_params.rb +1 -1
- data/lib/algolia/models/search/index_settings.rb +15 -15
- data/lib/algolia/models/search/index_settings_as_search_params.rb +6 -6
- data/lib/algolia/models/search/multiple_batch_request.rb +1 -1
- data/lib/algolia/models/search/operation_index_params.rb +1 -1
- data/lib/algolia/models/search/re_ranking_apply_filter.rb +1 -1
- data/lib/algolia/models/search/search_for_facets.rb +10 -10
- data/lib/algolia/models/search/search_for_facets_options.rb +1 -1
- data/lib/algolia/models/search/search_for_hits.rb +10 -10
- data/lib/algolia/models/search/search_for_hits_options.rb +1 -1
- data/lib/algolia/models/search/search_params_object.rb +10 -9
- data/lib/algolia/version.rb +1 -1
- metadata +15 -2
@@ -6,13 +6,13 @@ require 'time'
|
|
6
6
|
module Algolia
|
7
7
|
module Abtesting
|
8
8
|
class AbTestsVariant
|
9
|
-
# A/B test
|
9
|
+
# Index name of the A/B test variant (case-sensitive).
|
10
10
|
attr_accessor :index
|
11
11
|
|
12
|
-
#
|
12
|
+
# Percentage of search requests each variant receives.
|
13
13
|
attr_accessor :traffic_percentage
|
14
14
|
|
15
|
-
#
|
15
|
+
# Description for this variant.
|
16
16
|
attr_accessor :description
|
17
17
|
|
18
18
|
# Attribute mapping from ruby-style variable name to JSON key.
|
@@ -77,6 +77,24 @@ module Algolia
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
+
# Custom attribute writer method with validation
|
81
|
+
# @param [Object] traffic_percentage Value to be assigned
|
82
|
+
def traffic_percentage=(traffic_percentage)
|
83
|
+
if traffic_percentage.nil?
|
84
|
+
raise ArgumentError, 'traffic_percentage cannot be nil'
|
85
|
+
end
|
86
|
+
|
87
|
+
if traffic_percentage > 100
|
88
|
+
raise ArgumentError, 'invalid value for "traffic_percentage", must be smaller than or equal to 100.'
|
89
|
+
end
|
90
|
+
|
91
|
+
if traffic_percentage < 0
|
92
|
+
raise ArgumentError, 'invalid value for "traffic_percentage", must be greater than or equal to 0.'
|
93
|
+
end
|
94
|
+
|
95
|
+
@traffic_percentage = traffic_percentage
|
96
|
+
end
|
97
|
+
|
80
98
|
# Checks equality by comparing each attribute.
|
81
99
|
# @param [Object] Object to be compared
|
82
100
|
def ==(other)
|
@@ -6,13 +6,13 @@ require 'time'
|
|
6
6
|
module Algolia
|
7
7
|
module Abtesting
|
8
8
|
class AbTestsVariantSearchParams
|
9
|
-
# A/B test
|
9
|
+
# Index name of the A/B test variant (case-sensitive).
|
10
10
|
attr_accessor :index
|
11
11
|
|
12
|
-
#
|
12
|
+
# Percentage of search requests each variant receives.
|
13
13
|
attr_accessor :traffic_percentage
|
14
14
|
|
15
|
-
#
|
15
|
+
# Description for this variant.
|
16
16
|
attr_accessor :description
|
17
17
|
|
18
18
|
attr_accessor :custom_search_parameters
|
@@ -95,6 +95,24 @@ module Algolia
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
98
|
+
# Custom attribute writer method with validation
|
99
|
+
# @param [Object] traffic_percentage Value to be assigned
|
100
|
+
def traffic_percentage=(traffic_percentage)
|
101
|
+
if traffic_percentage.nil?
|
102
|
+
raise ArgumentError, 'traffic_percentage cannot be nil'
|
103
|
+
end
|
104
|
+
|
105
|
+
if traffic_percentage > 100
|
106
|
+
raise ArgumentError, 'invalid value for "traffic_percentage", must be smaller than or equal to 100.'
|
107
|
+
end
|
108
|
+
|
109
|
+
if traffic_percentage < 0
|
110
|
+
raise ArgumentError, 'invalid value for "traffic_percentage", must be greater than or equal to 0.'
|
111
|
+
end
|
112
|
+
|
113
|
+
@traffic_percentage = traffic_percentage
|
114
|
+
end
|
115
|
+
|
98
116
|
# Checks equality by comparing each attribute.
|
99
117
|
# @param [Object] Object to be compared
|
100
118
|
def ==(other)
|
@@ -12,7 +12,7 @@ module Algolia
|
|
12
12
|
# A/B test variants.
|
13
13
|
attr_accessor :variants
|
14
14
|
|
15
|
-
# End date
|
15
|
+
# End date and time of the A/B test, in RFC 3339 format.
|
16
16
|
attr_accessor :end_at
|
17
17
|
|
18
18
|
# Attribute mapping from ruby-style variable name to JSON key.
|
@@ -5,7 +5,7 @@ require 'time'
|
|
5
5
|
|
6
6
|
module Algolia
|
7
7
|
module Abtesting
|
8
|
-
#
|
8
|
+
# Search parameters to add to the test variant. Only use this parameter if the two variants use the same index.
|
9
9
|
class CustomSearchParams
|
10
10
|
attr_accessor :custom_search_parameters
|
11
11
|
|
@@ -0,0 +1,35 @@
|
|
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 Abtesting
|
8
|
+
class Effect
|
9
|
+
ADD_TO_CART_RATE = "addToCartRate".freeze
|
10
|
+
CLICK_THROUGH_RATE = "clickThroughRate".freeze
|
11
|
+
CONVERSION_RATE = "conversionRate".freeze
|
12
|
+
PURCHASE_RATE = "purchaseRate".freeze
|
13
|
+
|
14
|
+
def self.all_vars
|
15
|
+
@all_vars ||= [ADD_TO_CART_RATE, CLICK_THROUGH_RATE, CONVERSION_RATE, PURCHASE_RATE].freeze
|
16
|
+
end
|
17
|
+
|
18
|
+
# Builds the enum from string
|
19
|
+
# @param [String] The enum value in the form of the string
|
20
|
+
# @return [String] The enum value
|
21
|
+
def self.build_from_hash(value)
|
22
|
+
new.build_from_hash(value)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Builds the enum from string
|
26
|
+
# @param [String] The enum value in the form of the string
|
27
|
+
# @return [String] The enum value
|
28
|
+
def build_from_hash(value)
|
29
|
+
return value if Effect.all_vars.include?(value)
|
30
|
+
|
31
|
+
raise "Invalid ENUM value #{value} for class #Effect"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,198 @@
|
|
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 Abtesting
|
8
|
+
# Configuration for handling empty searches.
|
9
|
+
class EmptySearch
|
10
|
+
# Whether to exclude empty searches when calculating A/B test results.
|
11
|
+
attr_accessor :exclude
|
12
|
+
|
13
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
14
|
+
def self.attribute_map
|
15
|
+
{
|
16
|
+
:exclude => :exclude
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
# Returns all the JSON keys this model knows about
|
21
|
+
def self.acceptable_attributes
|
22
|
+
attribute_map.values
|
23
|
+
end
|
24
|
+
|
25
|
+
# Attribute type mapping.
|
26
|
+
def self.types_mapping
|
27
|
+
{
|
28
|
+
:exclude => :Boolean
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
# List of attributes with nullable: true
|
33
|
+
def self.openapi_nullable
|
34
|
+
Set.new([])
|
35
|
+
end
|
36
|
+
|
37
|
+
# Initializes the object
|
38
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
39
|
+
def initialize(attributes = {})
|
40
|
+
unless attributes.is_a?(Hash)
|
41
|
+
raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::EmptySearch` initialize method"
|
42
|
+
end
|
43
|
+
|
44
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
45
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
46
|
+
unless self.class.attribute_map.key?(k.to_sym)
|
47
|
+
raise ArgumentError,
|
48
|
+
"`#{k}` is not a valid attribute in `Algolia::EmptySearch`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
49
|
+
end
|
50
|
+
|
51
|
+
h[k.to_sym] = v
|
52
|
+
end
|
53
|
+
|
54
|
+
if attributes.key?(:exclude)
|
55
|
+
self.exclude = attributes[:exclude]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Checks equality by comparing each attribute.
|
60
|
+
# @param [Object] Object to be compared
|
61
|
+
def ==(other)
|
62
|
+
return true if equal?(other)
|
63
|
+
|
64
|
+
self.class == other.class &&
|
65
|
+
exclude == other.exclude
|
66
|
+
end
|
67
|
+
|
68
|
+
# @see the `==` method
|
69
|
+
# @param [Object] Object to be compared
|
70
|
+
def eql?(other)
|
71
|
+
self == other
|
72
|
+
end
|
73
|
+
|
74
|
+
# Calculates hash code according to all attributes.
|
75
|
+
# @return [Integer] Hash code
|
76
|
+
def hash
|
77
|
+
[exclude].hash
|
78
|
+
end
|
79
|
+
|
80
|
+
# Builds the object from hash
|
81
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
82
|
+
# @return [Object] Returns the model itself
|
83
|
+
def self.build_from_hash(attributes)
|
84
|
+
return nil unless attributes.is_a?(Hash)
|
85
|
+
|
86
|
+
attributes = attributes.transform_keys(&:to_sym)
|
87
|
+
transformed_hash = {}
|
88
|
+
types_mapping.each_pair do |key, type|
|
89
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
90
|
+
transformed_hash[key.to_sym] = nil
|
91
|
+
elsif type =~ /\AArray<(.*)>/i
|
92
|
+
# check to ensure the input is an array given that the attribute
|
93
|
+
# is documented as an array but the input is not
|
94
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
95
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
|
96
|
+
end
|
97
|
+
elsif !attributes[attribute_map[key]].nil?
|
98
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
99
|
+
end
|
100
|
+
end
|
101
|
+
new(transformed_hash)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Deserializes the data based on type
|
105
|
+
# @param string type Data type
|
106
|
+
# @param string value Value to be deserialized
|
107
|
+
# @return [Object] Deserialized data
|
108
|
+
def self._deserialize(type, value)
|
109
|
+
case type.to_sym
|
110
|
+
when :Time
|
111
|
+
Time.parse(value)
|
112
|
+
when :Date
|
113
|
+
Date.parse(value)
|
114
|
+
when :String
|
115
|
+
value.to_s
|
116
|
+
when :Integer
|
117
|
+
value.to_i
|
118
|
+
when :Float
|
119
|
+
value.to_f
|
120
|
+
when :Boolean
|
121
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
122
|
+
true
|
123
|
+
else
|
124
|
+
false
|
125
|
+
end
|
126
|
+
when :Object
|
127
|
+
# generic object (usually a Hash), return directly
|
128
|
+
value
|
129
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
130
|
+
inner_type = Regexp.last_match[:inner_type]
|
131
|
+
value.map { |v| _deserialize(inner_type, v) }
|
132
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
133
|
+
k_type = Regexp.last_match[:k_type]
|
134
|
+
v_type = Regexp.last_match[:v_type]
|
135
|
+
{}.tap do |hash|
|
136
|
+
value.each do |k, v|
|
137
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
else # model
|
141
|
+
# models (e.g. Pet) or oneOf
|
142
|
+
klass = Algolia::Abtesting.const_get(type)
|
143
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# Returns the string representation of the object
|
148
|
+
# @return [String] String presentation of the object
|
149
|
+
def to_s
|
150
|
+
to_hash.to_s
|
151
|
+
end
|
152
|
+
|
153
|
+
# to_body is an alias to to_hash (backward compatibility)
|
154
|
+
# @return [Hash] Returns the object in the form of hash
|
155
|
+
def to_body
|
156
|
+
to_hash
|
157
|
+
end
|
158
|
+
|
159
|
+
def to_json(*_args)
|
160
|
+
to_hash.to_json
|
161
|
+
end
|
162
|
+
|
163
|
+
# Returns the object in the form of hash
|
164
|
+
# @return [Hash] Returns the object in the form of hash
|
165
|
+
def to_hash
|
166
|
+
hash = {}
|
167
|
+
self.class.attribute_map.each_pair do |attr, param|
|
168
|
+
value = send(attr)
|
169
|
+
if value.nil?
|
170
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
171
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
172
|
+
end
|
173
|
+
|
174
|
+
hash[param] = _to_hash(value)
|
175
|
+
end
|
176
|
+
hash
|
177
|
+
end
|
178
|
+
|
179
|
+
# Outputs non-array value in the form of hash
|
180
|
+
# For object, use to_hash. Otherwise, just return the value
|
181
|
+
# @param [Object] value Any valid value
|
182
|
+
# @return [Hash] Returns the value in the form of hash
|
183
|
+
def _to_hash(value)
|
184
|
+
if value.is_a?(Array)
|
185
|
+
value.compact.map { |v| _to_hash(v) }
|
186
|
+
elsif value.is_a?(Hash)
|
187
|
+
{}.tap do |hash|
|
188
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
189
|
+
end
|
190
|
+
elsif value.respond_to? :to_hash
|
191
|
+
value.to_hash
|
192
|
+
else
|
193
|
+
value
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
@@ -0,0 +1,247 @@
|
|
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 Abtesting
|
8
|
+
# Configuration for the smallest difference between test variants you want to detect.
|
9
|
+
class MinimumDetectableEffect
|
10
|
+
# Smallest difference in an observable metric between variants. For example, to detect a 10% difference between variants, set this value to 0.1.
|
11
|
+
attr_accessor :size
|
12
|
+
|
13
|
+
attr_accessor :effect
|
14
|
+
|
15
|
+
class EnumAttributeValidator
|
16
|
+
attr_reader :datatype
|
17
|
+
attr_reader :allowable_values
|
18
|
+
|
19
|
+
def initialize(datatype, allowable_values)
|
20
|
+
@allowable_values = allowable_values.map do |value|
|
21
|
+
case datatype.to_s
|
22
|
+
when /Integer/i
|
23
|
+
value.to_i
|
24
|
+
when /Float/i
|
25
|
+
value.to_f
|
26
|
+
else
|
27
|
+
value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def valid?(value)
|
33
|
+
!value || allowable_values.include?(value)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
38
|
+
def self.attribute_map
|
39
|
+
{
|
40
|
+
:size => :size,
|
41
|
+
:effect => :effect
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# Returns all the JSON keys this model knows about
|
46
|
+
def self.acceptable_attributes
|
47
|
+
attribute_map.values
|
48
|
+
end
|
49
|
+
|
50
|
+
# Attribute type mapping.
|
51
|
+
def self.types_mapping
|
52
|
+
{
|
53
|
+
:size => :Float,
|
54
|
+
:effect => :Effect
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
# List of attributes with nullable: true
|
59
|
+
def self.openapi_nullable
|
60
|
+
Set.new([])
|
61
|
+
end
|
62
|
+
|
63
|
+
# Initializes the object
|
64
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
65
|
+
def initialize(attributes = {})
|
66
|
+
unless attributes.is_a?(Hash)
|
67
|
+
raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::MinimumDetectableEffect` initialize method"
|
68
|
+
end
|
69
|
+
|
70
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
71
|
+
attributes = attributes.each_with_object({}) do |(k, v), h|
|
72
|
+
unless self.class.attribute_map.key?(k.to_sym)
|
73
|
+
raise ArgumentError,
|
74
|
+
"`#{k}` is not a valid attribute in `Algolia::MinimumDetectableEffect`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
75
|
+
end
|
76
|
+
|
77
|
+
h[k.to_sym] = v
|
78
|
+
end
|
79
|
+
|
80
|
+
if attributes.key?(:size)
|
81
|
+
self.size = attributes[:size]
|
82
|
+
end
|
83
|
+
|
84
|
+
if attributes.key?(:effect)
|
85
|
+
self.effect = attributes[:effect]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Custom attribute writer method with validation
|
90
|
+
# @param [Object] size Value to be assigned
|
91
|
+
def size=(size)
|
92
|
+
if size.nil?
|
93
|
+
raise ArgumentError, 'size cannot be nil'
|
94
|
+
end
|
95
|
+
|
96
|
+
if size > 1
|
97
|
+
raise ArgumentError, 'invalid value for "size", must be smaller than or equal to 1.'
|
98
|
+
end
|
99
|
+
|
100
|
+
if size < 0
|
101
|
+
raise ArgumentError, 'invalid value for "size", must be greater than or equal to 0.'
|
102
|
+
end
|
103
|
+
|
104
|
+
@size = size
|
105
|
+
end
|
106
|
+
|
107
|
+
# Checks equality by comparing each attribute.
|
108
|
+
# @param [Object] Object to be compared
|
109
|
+
def ==(other)
|
110
|
+
return true if equal?(other)
|
111
|
+
|
112
|
+
self.class == other.class &&
|
113
|
+
size == other.size &&
|
114
|
+
effect == other.effect
|
115
|
+
end
|
116
|
+
|
117
|
+
# @see the `==` method
|
118
|
+
# @param [Object] Object to be compared
|
119
|
+
def eql?(other)
|
120
|
+
self == other
|
121
|
+
end
|
122
|
+
|
123
|
+
# Calculates hash code according to all attributes.
|
124
|
+
# @return [Integer] Hash code
|
125
|
+
def hash
|
126
|
+
[size, effect].hash
|
127
|
+
end
|
128
|
+
|
129
|
+
# Builds the object from hash
|
130
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
131
|
+
# @return [Object] Returns the model itself
|
132
|
+
def self.build_from_hash(attributes)
|
133
|
+
return nil unless attributes.is_a?(Hash)
|
134
|
+
|
135
|
+
attributes = attributes.transform_keys(&:to_sym)
|
136
|
+
transformed_hash = {}
|
137
|
+
types_mapping.each_pair do |key, type|
|
138
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
139
|
+
transformed_hash[key.to_sym] = nil
|
140
|
+
elsif type =~ /\AArray<(.*)>/i
|
141
|
+
# check to ensure the input is an array given that the attribute
|
142
|
+
# is documented as an array but the input is not
|
143
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
144
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
|
145
|
+
end
|
146
|
+
elsif !attributes[attribute_map[key]].nil?
|
147
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
148
|
+
end
|
149
|
+
end
|
150
|
+
new(transformed_hash)
|
151
|
+
end
|
152
|
+
|
153
|
+
# Deserializes the data based on type
|
154
|
+
# @param string type Data type
|
155
|
+
# @param string value Value to be deserialized
|
156
|
+
# @return [Object] Deserialized data
|
157
|
+
def self._deserialize(type, value)
|
158
|
+
case type.to_sym
|
159
|
+
when :Time
|
160
|
+
Time.parse(value)
|
161
|
+
when :Date
|
162
|
+
Date.parse(value)
|
163
|
+
when :String
|
164
|
+
value.to_s
|
165
|
+
when :Integer
|
166
|
+
value.to_i
|
167
|
+
when :Float
|
168
|
+
value.to_f
|
169
|
+
when :Boolean
|
170
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
171
|
+
true
|
172
|
+
else
|
173
|
+
false
|
174
|
+
end
|
175
|
+
when :Object
|
176
|
+
# generic object (usually a Hash), return directly
|
177
|
+
value
|
178
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
179
|
+
inner_type = Regexp.last_match[:inner_type]
|
180
|
+
value.map { |v| _deserialize(inner_type, v) }
|
181
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
182
|
+
k_type = Regexp.last_match[:k_type]
|
183
|
+
v_type = Regexp.last_match[:v_type]
|
184
|
+
{}.tap do |hash|
|
185
|
+
value.each do |k, v|
|
186
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
else # model
|
190
|
+
# models (e.g. Pet) or oneOf
|
191
|
+
klass = Algolia::Abtesting.const_get(type)
|
192
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
# Returns the string representation of the object
|
197
|
+
# @return [String] String presentation of the object
|
198
|
+
def to_s
|
199
|
+
to_hash.to_s
|
200
|
+
end
|
201
|
+
|
202
|
+
# to_body is an alias to to_hash (backward compatibility)
|
203
|
+
# @return [Hash] Returns the object in the form of hash
|
204
|
+
def to_body
|
205
|
+
to_hash
|
206
|
+
end
|
207
|
+
|
208
|
+
def to_json(*_args)
|
209
|
+
to_hash.to_json
|
210
|
+
end
|
211
|
+
|
212
|
+
# Returns the object in the form of hash
|
213
|
+
# @return [Hash] Returns the object in the form of hash
|
214
|
+
def to_hash
|
215
|
+
hash = {}
|
216
|
+
self.class.attribute_map.each_pair do |attr, param|
|
217
|
+
value = send(attr)
|
218
|
+
if value.nil?
|
219
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
220
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
221
|
+
end
|
222
|
+
|
223
|
+
hash[param] = _to_hash(value)
|
224
|
+
end
|
225
|
+
hash
|
226
|
+
end
|
227
|
+
|
228
|
+
# Outputs non-array value in the form of hash
|
229
|
+
# For object, use to_hash. Otherwise, just return the value
|
230
|
+
# @param [Object] value Any valid value
|
231
|
+
# @return [Hash] Returns the value in the form of hash
|
232
|
+
def _to_hash(value)
|
233
|
+
if value.is_a?(Array)
|
234
|
+
value.compact.map { |v| _to_hash(v) }
|
235
|
+
elsif value.is_a?(Hash)
|
236
|
+
{}.tap do |hash|
|
237
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
238
|
+
end
|
239
|
+
elsif value.respond_to? :to_hash
|
240
|
+
value.to_hash
|
241
|
+
else
|
242
|
+
value
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|