Class: Algolia::DictionaryResponse

Inherits:
BaseResponse show all
Includes:
CallType
Defined in:
lib/algolia/responses/dictionary_response.rb

Constant Summary

Constants included from CallType

CallType::READ, CallType::WRITE

Instance Attribute Summary collapse

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, response) ⇒ DictionaryResponse

Returns a new instance of DictionaryResponse.

Parameters:

  • client (Search::Client)

    Algolia Search Client used for verification

  • response (Hash)

    Raw response from the client



10
11
12
13
14
# File 'lib/algolia/responses/dictionary_response.rb', line 10

def initialize(client, response)
  @client       = client
  @raw_response = response
  @done         = false
end

Instance Attribute Details

#raw_responseObject (readonly)

Returns the value of attribute raw_response.



5
6
7
# File 'lib/algolia/responses/dictionary_response.rb', line 5

def raw_response
  @raw_response
end

Instance Method Details

#wait(_opts = {}) ⇒ Object

Wait for the task to complete

Parameters:

  • opts (Hash)

    contains extra parameters to send with your query



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/algolia/responses/dictionary_response.rb', line 20

def wait(_opts = {})
  until @done
    res    = @client.custom_request({}, path_encode('/1/task/%s', @raw_response[:taskID]), :GET, READ)
    status = get_option(res, 'status')
    if status == 'published'
      @done = true
    end
    sleep(Defaults::WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY / 1000)
  end

  self
end