Class: Algolia::RestoreApiKeyResponse

Inherits:
BaseResponse show all
Defined in:
lib/algolia/responses/restore_api_key_response.rb

Instance Method Summary collapse

Methods included from Helpers

#check_array, #check_object, #chunk, #deserialize_settings, #get_object_id, #get_option, #handle_params, #hash_includes_subset?, included, #json_to_hash, #path_encode, #symbolize_hash, #to_json, #to_query_string

Constructor Details

#initialize(client, key) ⇒ RestoreApiKeyResponse

Returns a new instance of RestoreApiKeyResponse.

Parameters:

  • index (Search::Index)

    Algolia Search Index used for verification

  • key (String)

    the key to check



6
7
8
9
10
# File 'lib/algolia/responses/restore_api_key_response.rb', line 6

def initialize(client, key)
  @client = client
  @key    = key
  @done   = false
end

Instance Method Details

#wait(opts = {}) ⇒ Object

Wait for the task to complete

Parameters:

  • opts (Hash) (defaults to: {})

    contains extra parameters to send with your query



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/algolia/responses/restore_api_key_response.rb', line 16

def wait(opts = {})
  retries_count = 1

  until @done
    begin
      @client.get_api_key(@key, opts)
      @done = true
    rescue AlgoliaError => e
      if e.code != 404
        raise e
      end
      retries_count    += 1
      time_before_retry = retries_count * Defaults::WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY
      sleep(time_before_retry.to_f / 1000)
    end
  end

  self
end