Class: Algolia::Analytics

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

Constant Summary collapse

API_URL =
'https://analytics.algolia.com'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, params) ⇒ Analytics

Returns a new instance of Analytics.



7
8
9
10
# File 'lib/algolia/analytics.rb', line 7

def initialize(client, params)
  @client   = client
  @headers  = params[:headers]
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



4
5
6
# File 'lib/algolia/analytics.rb', line 4

def headers
  @headers
end

#sslObject (readonly)

Returns the value of attribute ssl.



4
5
6
# File 'lib/algolia/analytics.rb', line 4

def ssl
  @ssl
end

#ssl_versionObject (readonly)

Returns the value of attribute ssl_version.



4
5
6
# File 'lib/algolia/analytics.rb', line 4

def ssl_version
  @ssl_version
end

Instance Method Details

#add_ab_test(ab_test) ⇒ Object



27
28
29
# File 'lib/algolia/analytics.rb', line 27

def add_ab_test(ab_test)
  perform_request(:POST, Protocol.ab_tests_uri, {}, ab_test.to_json)
end

#delete_ab_test(ab_test_id) ⇒ Object

Raises:

  • (ArgumentError)


37
38
39
40
41
# File 'lib/algolia/analytics.rb', line 37

def delete_ab_test(ab_test_id)
  raise ArgumentError.new('ab_test_id cannot be empty') if ab_test_id.nil? || ab_test_id == ''

  perform_request(:DELETE, Protocol.ab_tests_uri(ab_test_id))
end

#get_ab_test(ab_test_id) ⇒ Object

Raises:

  • (ArgumentError)


21
22
23
24
25
# File 'lib/algolia/analytics.rb', line 21

def get_ab_test(ab_test_id)
  raise ArgumentError.new('ab_test_id cannot be empty') if ab_test_id.nil? || ab_test_id == ''

  perform_request(:GET, Protocol.ab_tests_uri(ab_test_id))
end

#get_ab_tests(params = {}) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/algolia/analytics.rb', line 12

def get_ab_tests(params = {})
  params = {
    :offset => 0,
    :limit => 10,
  }.merge(params)

  perform_request(:GET, Protocol.ab_tests_uri, params)
end

#stop_ab_test(ab_test_id) ⇒ Object

Raises:

  • (ArgumentError)


31
32
33
34
35
# File 'lib/algolia/analytics.rb', line 31

def stop_ab_test(ab_test_id)
  raise ArgumentError.new('ab_test_id cannot be empty') if ab_test_id.nil? || ab_test_id == ''

  perform_request(:POST, Protocol.ab_tests_stop_uri(ab_test_id))
end

#wait_task(index_name, taskID, time_before_retry = WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options = {}) ⇒ Object



43
44
45
# File 'lib/algolia/analytics.rb', line 43

def wait_task(index_name, taskID, time_before_retry = WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options = {})
  @client.wait_task(index_name, taskID, time_before_retry, request_options)
end