Class: Algolia::AbtestingClient

Inherits:
Object
  • Object
show all
Defined in:
lib/algolia/api/abtesting_client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config = nil) ⇒ AbtestingClient

Returns a new instance of AbtestingClient.



7
8
9
10
11
12
13
# File 'lib/algolia/api/abtesting_client.rb', line 7

def initialize(config = nil)
  raise '`config` is missing.' if config.nil?
  raise '`app_id` is missing.' if config.app_id.nil? || config.app_id == ''
  raise '`api_key` is missing.' if config.api_key.nil? || config.api_key == ''

  @api_client = Algolia::ApiClient.new(config)
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



5
6
7
# File 'lib/algolia/api/abtesting_client.rb', line 5

def api_client
  @api_client
end

Class Method Details

.create(app_id, api_key, region = nil, opts = {}) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/algolia/api/abtesting_client.rb', line 15

def self.create(app_id, api_key, region = nil, opts = {})
  hosts = []
  regions = ['de', 'us']

  if region.is_a?(Hash) && (opts.nil? || opts.empty?)
    opts = region
    region = nil
  end

  raise "`region` must be one of the following: #{regions.join(', ')}" if !region.nil? && (!region.is_a?(String) || !regions.include?(region))

  hosts << Transport::StatefulHost.new(region.nil? ? 'analytics.algolia.com' : 'analytics.{region}.algolia.com'.sub!('{region}', region),
                                       accept: CallType::READ | CallType::WRITE)

  config = Algolia::Configuration.new(app_id, api_key, hosts, 'Abtesting', opts)
  create_with_config(config)
end

.create_with_config(config) ⇒ Object



33
34
35
# File 'lib/algolia/api/abtesting_client.rb', line 33

def self.create_with_config(config)
  new(config)
end

Instance Method Details

#add_ab_tests(add_ab_tests_request, request_options = {}) ⇒ ABTestResponse

Creates an A/B test.

Required API Key ACLs:

- editSettings

Parameters:

  • add_ab_tests_request (AddABTestsRequest)

    (required)

  • 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)

Returns:

  • (ABTestResponse)


76
77
78
79
# File 'lib/algolia/api/abtesting_client.rb', line 76

def add_ab_tests(add_ab_tests_request, request_options = {})
  response = add_ab_tests_with_http_info(add_ab_tests_request, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || 'Abtesting::ABTestResponse')
end

#add_ab_tests_with_http_info(add_ab_tests_request, request_options = {}) ⇒ Http::Response

Creates an A/B test.

Required API Key ACLs:

- editSettings

Parameters:

  • add_ab_tests_request (AddABTestsRequest)

    (required)

  • 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)

Returns:



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/algolia/api/abtesting_client.rb', line 44

def add_ab_tests_with_http_info(add_ab_tests_request, request_options = {})
  # verify the required parameter 'add_ab_tests_request' is set
  if @api_client.config.client_side_validation && add_ab_tests_request.nil?
    raise ArgumentError, "Parameter `add_ab_tests_request` is required when calling `add_ab_tests`."
  end

  path = '/2/abtests'
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(add_ab_tests_request)

  new_options = request_options.merge(
    :operation => :'AbtestingClient.add_ab_tests',
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#custom_delete(path, parameters = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String)

    Path of the endpoint, anything after &quot;/1&quot; must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • 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)

Returns:

  • (Object)


119
120
121
122
# File 'lib/algolia/api/abtesting_client.rb', line 119

def custom_delete(path, parameters = nil, request_options = {})
  response = custom_delete_with_http_info(path, parameters, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || 'Object')
end

#custom_delete_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String)

    Path of the endpoint, anything after &quot;/1&quot; must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • 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)

Returns:



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/algolia/api/abtesting_client.rb', line 87

def custom_delete_with_http_info(path, parameters = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_delete`."
  end

  path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :'AbtestingClient.custom_delete',
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:DELETE, path, new_options)
end

#custom_get(path, parameters = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String)

    Path of the endpoint, anything after &quot;/1&quot; must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • 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)

Returns:

  • (Object)


162
163
164
165
# File 'lib/algolia/api/abtesting_client.rb', line 162

def custom_get(path, parameters = nil, request_options = {})
  response = custom_get_with_http_info(path, parameters, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || 'Object')
end

#custom_get_with_http_info(path, parameters = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String)

    Path of the endpoint, anything after &quot;/1&quot; must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • 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)

Returns:



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/algolia/api/abtesting_client.rb', line 130

def custom_get_with_http_info(path, parameters = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_get`."
  end

  path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :'AbtestingClient.custom_get',
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#custom_post(path, parameters = nil, body = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String)

    Path of the endpoint, anything after &quot;/1&quot; must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil)

    Parameters to send with the custom request.

  • 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)

Returns:

  • (Object)


207
208
209
210
# File 'lib/algolia/api/abtesting_client.rb', line 207

def custom_post(path, parameters = nil, body = nil, request_options = {})
  response = custom_post_with_http_info(path, parameters, body, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || 'Object')
end

#custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String)

    Path of the endpoint, anything after &quot;/1&quot; must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil)

    Parameters to send with the custom request.

  • 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)

Returns:



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/algolia/api/abtesting_client.rb', line 174

def custom_post_with_http_info(path, parameters = nil, body = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_post`."
  end

  path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(body)

  new_options = request_options.merge(
    :operation => :'AbtestingClient.custom_post',
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end

#custom_put(path, parameters = nil, body = nil, request_options = {}) ⇒ Object

Parameters:

  • path (String)

    Path of the endpoint, anything after &quot;/1&quot; must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil)

    Parameters to send with the custom request.

  • 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)

Returns:

  • (Object)


252
253
254
255
# File 'lib/algolia/api/abtesting_client.rb', line 252

def custom_put(path, parameters = nil, body = nil, request_options = {})
  response = custom_put_with_http_info(path, parameters, body, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || 'Object')
end

#custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {}) ⇒ Http::Response

Returns the response.

Parameters:

  • path (String)

    Path of the endpoint, anything after &quot;/1&quot; must be specified. (required)

  • parameters (Hash<String, Object>) (defaults to: nil)

    Query parameters to apply to the current query.

  • body (Object) (defaults to: nil)

    Parameters to send with the custom request.

  • 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)

Returns:



219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/algolia/api/abtesting_client.rb', line 219

def custom_put_with_http_info(path, parameters = nil, body = nil, request_options = {})
  # verify the required parameter 'path' is set
  if @api_client.config.client_side_validation && path.nil?
    raise ArgumentError, "Parameter `path` is required when calling `custom_put`."
  end

  path = '/1{path}'.sub('{' + 'path' + '}', path.to_s)
  query_params = {}
  query_params = query_params.merge(parameters) unless parameters.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body] || @api_client.object_to_http_body(body)

  new_options = request_options.merge(
    :operation => :'AbtestingClient.custom_put',
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:PUT, path, new_options)
end

#delete_ab_test(id, request_options = {}) ⇒ ABTestResponse

Delete an A/B test. To determine the ‘id` for an A/B test, use the [`listABTests` operation](#tag/abtest/operation/listABTests).

Required API Key ACLs:

- editSettings

Parameters:

  • id (Integer)

    Unique A/B test ID. (required)

  • 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)

Returns:

  • (ABTestResponse)


296
297
298
299
# File 'lib/algolia/api/abtesting_client.rb', line 296

def delete_ab_test(id, request_options = {})
  response = delete_ab_test_with_http_info(id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || 'Abtesting::ABTestResponse')
end

#delete_ab_test_with_http_info(id, request_options = {}) ⇒ Http::Response

Delete an A/B test. To determine the &#x60;id&#x60; for an A/B test, use the [&#x60;listABTests&#x60; operation](#tag/abtest/operation/listABTests).

Required API Key ACLs:

- editSettings

Parameters:

  • id (Integer)

    Unique A/B test ID. (required)

  • 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)

Returns:



264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/algolia/api/abtesting_client.rb', line 264

def delete_ab_test_with_http_info(id, request_options = {})
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    raise ArgumentError, "Parameter `id` is required when calling `delete_ab_test`."
  end

  path = '/2/abtests/{id}'.sub('{' + 'id' + '}', Transport.encode_uri(id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :'AbtestingClient.delete_ab_test',
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:DELETE, path, new_options)
end

#get_ab_test(id, request_options = {}) ⇒ ABTest

Get specific details for an A/B test. To determine the ‘id` for an A/B test, use the [`listABTests` operation](#tag/abtest/operation/listABTests).

Required API Key ACLs:

- analytics

Parameters:

  • id (Integer)

    Unique A/B test ID. (required)

  • 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)

Returns:

  • (ABTest)


340
341
342
343
# File 'lib/algolia/api/abtesting_client.rb', line 340

def get_ab_test(id, request_options = {})
  response = get_ab_test_with_http_info(id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || 'Abtesting::ABTest')
end

#get_ab_test_with_http_info(id, request_options = {}) ⇒ Http::Response

Get specific details for an A/B test. To determine the &#x60;id&#x60; for an A/B test, use the [&#x60;listABTests&#x60; operation](#tag/abtest/operation/listABTests).

Required API Key ACLs:

- analytics

Parameters:

  • id (Integer)

    Unique A/B test ID. (required)

  • 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)

Returns:



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# File 'lib/algolia/api/abtesting_client.rb', line 308

def get_ab_test_with_http_info(id, request_options = {})
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    raise ArgumentError, "Parameter `id` is required when calling `get_ab_test`."
  end

  path = '/2/abtests/{id}'.sub('{' + 'id' + '}', Transport.encode_uri(id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :'AbtestingClient.get_ab_test',
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#list_ab_tests(offset = nil, limit = nil, index_prefix = nil, index_suffix = nil, request_options = {}) ⇒ ListABTestsResponse

List all A/B tests.

Required API Key ACLs:

- analytics

Parameters:

  • offset (Integer) (defaults to: nil)

    Position of the starting record. Used for paging. 0 is the first record. (default to 0)

  • limit (Integer) (defaults to: nil)

    Number of records to return (page size). (default to 10)

  • index_prefix (String) (defaults to: nil)

    Only return A/B tests for indices starting with this prefix.

  • index_suffix (String) (defaults to: nil)

    Only return A/B tests for indices ending with this suffix.

  • 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)

Returns:

  • (ListABTestsResponse)


389
390
391
392
# File 'lib/algolia/api/abtesting_client.rb', line 389

def list_ab_tests(offset = nil, limit = nil, index_prefix = nil, index_suffix = nil, request_options = {})
  response = list_ab_tests_with_http_info(offset, limit, index_prefix, index_suffix, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || 'Abtesting::ListABTestsResponse')
end

#list_ab_tests_with_http_info(offset = nil, limit = nil, index_prefix = nil, index_suffix = nil, request_options = {}) ⇒ Http::Response

List all A/B tests.

Required API Key ACLs:

- analytics

Parameters:

  • offset (Integer) (defaults to: nil)

    Position of the starting record. Used for paging. 0 is the first record. (default to 0)

  • limit (Integer) (defaults to: nil)

    Number of records to return (page size). (default to 10)

  • index_prefix (String) (defaults to: nil)

    Only return A/B tests for indices starting with this prefix.

  • index_suffix (String) (defaults to: nil)

    Only return A/B tests for indices ending with this suffix.

  • 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)

Returns:



355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/algolia/api/abtesting_client.rb', line 355

def list_ab_tests_with_http_info(offset = nil, limit = nil, index_prefix = nil, index_suffix = nil, request_options = {})
  path = '/2/abtests'
  query_params = {}
  query_params[:offset] = offset unless offset.nil?
  query_params[:limit] = limit unless limit.nil?
  query_params[:indexPrefix] = index_prefix unless index_prefix.nil?
  query_params[:indexSuffix] = index_suffix unless index_suffix.nil?
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :'AbtestingClient.list_ab_tests',
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:GET, path, new_options)
end

#stop_ab_test(id, request_options = {}) ⇒ ABTestResponse

If stopped, the test is over and can’t be restarted. There is now only one index, receiving 100% of all search requests. The data gathered for stopped A/B tests is retained. To determine the ‘id` for an A/B test, use the [`listABTests` operation](#tag/abtest/operation/listABTests).

Required API Key ACLs:

- editSettings

Parameters:

  • id (Integer)

    Unique A/B test ID. (required)

  • 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)

Returns:

  • (ABTestResponse)


433
434
435
436
# File 'lib/algolia/api/abtesting_client.rb', line 433

def stop_ab_test(id, request_options = {})
  response = stop_ab_test_with_http_info(id, request_options)
  @api_client.deserialize(response.body, request_options[:debug_return_type] || 'Abtesting::ABTestResponse')
end

#stop_ab_test_with_http_info(id, request_options = {}) ⇒ Http::Response

If stopped, the test is over and can&#39;t be restarted. There is now only one index, receiving 100% of all search requests. The data gathered for stopped A/B tests is retained. To determine the &#x60;id&#x60; for an A/B test, use the [&#x60;listABTests&#x60; operation](#tag/abtest/operation/listABTests).

Required API Key ACLs:

- editSettings

Parameters:

  • id (Integer)

    Unique A/B test ID. (required)

  • 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)

Returns:



401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
# File 'lib/algolia/api/abtesting_client.rb', line 401

def stop_ab_test_with_http_info(id, request_options = {})
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    raise ArgumentError, "Parameter `id` is required when calling `stop_ab_test`."
  end

  path = '/2/abtests/{id}/stop'.sub('{' + 'id' + '}', Transport.encode_uri(id.to_s))
  query_params = {}
  query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
  header_params = {}
  header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?

  post_body = request_options[:debug_body]

  new_options = request_options.merge(
    :operation => :'AbtestingClient.stop_ab_test',
    :header_params => header_params,
    :query_params => query_params,
    :body => post_body,
    :use_read_transporter => false
  )

  @api_client.call_api(:POST, path, new_options)
end