Skip to content

Commit ff9f1e4

Browse files
algolia-botfebeckmillotp
committed
feat(specs): add /schedule endpoint (generated)
algolia/api-clients-automation#3350 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Fernando Beck <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent c5d45f4 commit ff9f1e4

File tree

3 files changed

+528
-0
lines changed

3 files changed

+528
-0
lines changed

lib/algolia/api/abtesting_client.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,50 @@ def list_ab_tests(offset = nil, limit = nil, index_prefix = nil, index_suffix =
409409
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Abtesting::ListABTestsResponse")
410410
end
411411

412+
# Schedule an A/B test to be started at a later time.
413+
#
414+
# Required API Key ACLs:
415+
# - editSettings
416+
# @param schedule_ab_tests_request [ScheduleABTestsRequest] (required)
417+
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
418+
# @return [Http::Response] the response
419+
def schedule_ab_test_with_http_info(schedule_ab_tests_request, request_options = {})
420+
# verify the required parameter 'schedule_ab_tests_request' is set
421+
if @api_client.config.client_side_validation && schedule_ab_tests_request.nil?
422+
raise ArgumentError, "Parameter `schedule_ab_tests_request` is required when calling `schedule_ab_test`."
423+
end
424+
425+
path = "/2/abtests/schedule"
426+
query_params = {}
427+
query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
428+
header_params = {}
429+
header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?
430+
431+
post_body = request_options[:debug_body] || @api_client.object_to_http_body(schedule_ab_tests_request)
432+
433+
new_options = request_options.merge(
434+
:operation => :"AbtestingClient.schedule_ab_test",
435+
:header_params => header_params,
436+
:query_params => query_params,
437+
:body => post_body,
438+
:use_read_transporter => false
439+
)
440+
441+
@api_client.call_api(:POST, path, new_options)
442+
end
443+
444+
# Schedule an A/B test to be started at a later time.
445+
#
446+
# Required API Key ACLs:
447+
# - editSettings
448+
# @param schedule_ab_tests_request [ScheduleABTestsRequest] (required)
449+
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
450+
# @return [ScheduleABTestResponse]
451+
def schedule_ab_test(schedule_ab_tests_request, request_options = {})
452+
response = schedule_ab_test_with_http_info(schedule_ab_tests_request, request_options)
453+
@api_client.deserialize(response.body, request_options[:debug_return_type] || "Abtesting::ScheduleABTestResponse")
454+
end
455+
412456
# Stops an A/B test by its ID. You can&#39;t restart stopped A/B tests.
413457
#
414458
# Required API Key ACLs:
Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
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 ScheduleABTestResponse
9+
# Unique scheduled A/B test identifier.
10+
attr_accessor :ab_test_schedule_id
11+
12+
# Attribute mapping from ruby-style variable name to JSON key.
13+
def self.attribute_map
14+
{
15+
:ab_test_schedule_id => :abTestScheduleID
16+
}
17+
end
18+
19+
# Returns all the JSON keys this model knows about
20+
def self.acceptable_attributes
21+
attribute_map.values
22+
end
23+
24+
# Attribute type mapping.
25+
def self.types_mapping
26+
{
27+
:ab_test_schedule_id => :"Integer"
28+
}
29+
end
30+
31+
# List of attributes with nullable: true
32+
def self.openapi_nullable
33+
Set.new(
34+
[]
35+
)
36+
end
37+
38+
# Initializes the object
39+
# @param [Hash] attributes Model attributes in the form of hash
40+
def initialize(attributes = {})
41+
if (!attributes.is_a?(Hash))
42+
raise(
43+
ArgumentError,
44+
"The input argument (attributes) must be a hash in `Algolia::ScheduleABTestResponse` initialize method"
45+
)
46+
end
47+
48+
# check to see if the attribute exists and convert string to symbol for hash key
49+
attributes = attributes.each_with_object({}) { |(k, v), h|
50+
if (!self.class.attribute_map.key?(k.to_sym))
51+
raise(
52+
ArgumentError,
53+
"`#{k}` is not a valid attribute in `Algolia::ScheduleABTestResponse`. Please check the name to make sure it's valid. List of attributes: " +
54+
self.class.attribute_map.keys.inspect
55+
)
56+
end
57+
58+
h[k.to_sym] = v
59+
}
60+
61+
if attributes.key?(:ab_test_schedule_id)
62+
self.ab_test_schedule_id = attributes[:ab_test_schedule_id]
63+
else
64+
self.ab_test_schedule_id = nil
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 self.equal?(other)
72+
self.class == other.class &&
73+
ab_test_schedule_id == other.ab_test_schedule_id
74+
end
75+
76+
# @see the `==` method
77+
# @param [Object] Object to be compared
78+
def eql?(other)
79+
self == other
80+
end
81+
82+
# Calculates hash code according to all attributes.
83+
# @return [Integer] Hash code
84+
def hash
85+
[ab_test_schedule_id].hash
86+
end
87+
88+
# Builds the object from hash
89+
# @param [Hash] attributes Model attributes in the form of hash
90+
# @return [Object] Returns the model itself
91+
def self.build_from_hash(attributes)
92+
return nil unless attributes.is_a?(Hash)
93+
attributes = attributes.transform_keys(&:to_sym)
94+
transformed_hash = {}
95+
types_mapping.each_pair do |key, type|
96+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
97+
transformed_hash[key.to_sym] = nil
98+
elsif type =~ /\AArray<(.*)>/i
99+
# check to ensure the input is an array given that the attribute
100+
# is documented as an array but the input is not
101+
if attributes[attribute_map[key]].is_a?(Array)
102+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
103+
_deserialize(::Regexp.last_match(1), v)
104+
}
105+
end
106+
elsif !attributes[attribute_map[key]].nil?
107+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
108+
end
109+
end
110+
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+
137+
when :Object
138+
# generic object (usually a Hash), return directly
139+
value
140+
when /\AArray<(?<inner_type>.+)>\z/
141+
inner_type = Regexp.last_match[:inner_type]
142+
value.map { |v| _deserialize(inner_type, v) }
143+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
144+
k_type = Regexp.last_match[:k_type]
145+
v_type = Regexp.last_match[:v_type]
146+
{}.tap do |hash|
147+
value.each do |k, v|
148+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
149+
end
150+
end
151+
# model
152+
else
153+
# models (e.g. Pet) or oneOf
154+
klass = Algolia::Abtesting.const_get(type)
155+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
156+
.build_from_hash(value)
157+
end
158+
end
159+
160+
# Returns the string representation of the object
161+
# @return [String] String presentation of the object
162+
def to_s
163+
to_hash.to_s
164+
end
165+
166+
# to_body is an alias to to_hash (backward compatibility)
167+
# @return [Hash] Returns the object in the form of hash
168+
def to_body
169+
to_hash
170+
end
171+
172+
def to_json(*_args)
173+
to_hash.to_json
174+
end
175+
176+
# Returns the object in the form of hash
177+
# @return [Hash] Returns the object in the form of hash
178+
def to_hash
179+
hash = {}
180+
self.class.attribute_map.each_pair do |attr, param|
181+
value = send(attr)
182+
if value.nil?
183+
is_nullable = self.class.openapi_nullable.include?(attr)
184+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
185+
end
186+
187+
hash[param] = _to_hash(value)
188+
end
189+
190+
hash
191+
end
192+
193+
# Outputs non-array value in the form of hash
194+
# For object, use to_hash. Otherwise, just return the value
195+
# @param [Object] value Any valid value
196+
# @return [Hash] Returns the value in the form of hash
197+
def _to_hash(value)
198+
if value.is_a?(Array)
199+
value.compact.map { |v| _to_hash(v) }
200+
elsif value.is_a?(Hash)
201+
{}.tap do |hash|
202+
value.each { |k, v| hash[k] = _to_hash(v) }
203+
end
204+
elsif value.respond_to?(:to_hash)
205+
value.to_hash
206+
else
207+
value
208+
end
209+
end
210+
211+
end
212+
213+
end
214+
end

0 commit comments

Comments
 (0)