Sha256: 2e95a3868bf259d452faf096ff78fb35763802a6906353d1c1396e82241c3c17

Contents?: true

Size: 1.14 KB

Versions: 15

Compression:

Stored size: 1.14 KB

Contents

module Algolia
  class UpdateApiKeyResponse < BaseResponse
    include Helpers
    attr_reader :raw_response

    # @param client [Search::Client] Algolia Search Client used for verification
    # @param response [Hash] Raw response from the client
    # @param request_options [Hash] request_options used to find the api key
    #
    def initialize(client, response, request_options)
      @client          = client
      @raw_response    = response
      @request_options = request_options
      @done            = false
    end

    # Wait for the task to complete
    #
    # @param opts [Hash] contains extra parameters to send with your query
    #
    def wait(opts = {})
      retries_count = 1

      until @done
        begin
          api_key = @client.get_api_key(@raw_response[:key], opts)
          @done   = hash_includes_subset?(api_key, @request_options)
        rescue AlgoliaError => e
          raise e unless e.code == 404
          retries_count    += 1
          time_before_retry = retries_count * Defaults::WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY
          sleep(time_before_retry / 1000)
        end
      end

      self
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
algolia-2.2.2 lib/algolia/responses/update_api_key_response.rb
algolia-2.2.1 lib/algolia/responses/update_api_key_response.rb
algolia-2.2.0 lib/algolia/responses/update_api_key_response.rb
algolia-2.1.1 lib/algolia/responses/update_api_key_response.rb
algolia-2.0.4 lib/algolia/responses/update_api_key_response.rb
algolia-2.0.3 lib/algolia/responses/update_api_key_response.rb
algolia-2.0.2 lib/algolia/responses/update_api_key_response.rb
algolia-2.0.1 lib/algolia/responses/update_api_key_response.rb
algolia-2.0.0 lib/algolia/responses/update_api_key_response.rb
algolia-2.0.0.pre.beta.3 lib/algolia/responses/update_api_key_response.rb
algolia-2.0.0.pre.beta.2 lib/algolia/responses/update_api_key_response.rb
algolia-2.0.0.pre.beta.1 lib/algolia/responses/update_api_key_response.rb
algolia-2.0.0.pre.alpha.4 lib/algolia/responses/update_api_key_response.rb
algolia-2.0.0.pre.alpha.3 lib/algolia/responses/update_api_key_response.rb
algolia-2.0.0.pre.alpha.2 lib/algolia/responses/update_api_key_response.rb