Class: SwiftypeAppSearch::Client

Inherits:
Object
  • Object
show all
Includes:
Documents, Engines, QuerySuggestion, Search, SearchSettings, SignedSearchOptions, Request
Defined in:
lib/swiftype-app-search/client.rb,
lib/swiftype-app-search/client/search.rb,
lib/swiftype-app-search/client/engines.rb,
lib/swiftype-app-search/client/documents.rb,
lib/swiftype-app-search/client/search_settings.rb,
lib/swiftype-app-search/client/query_suggestion.rb

Overview

API client for the Swiftype App Search API.

Defined Under Namespace

Modules: Documents, Engines, QuerySuggestion, Search, SearchSettings, SignedSearchOptions

Constant Summary collapse

DEFAULT_TIMEOUT =
15

Constants included from SignedSearchOptions

SignedSearchOptions::ALGORITHM

Instance Attribute Summary collapse

Attributes included from Request

#last_request

Instance Method Summary collapse

Methods included from SearchSettings

#reset_settings, #show_settings, #update_settings

Methods included from QuerySuggestion

#query_suggestion

Methods included from SignedSearchOptions

included

Methods included from Search

#multi_search, #search

Methods included from Engines

#create_engine, #destroy_engine, #get_engine, #list_engines

Methods included from Documents

#destroy_documents, #get_documents, #index_document, #index_documents, #list_documents, #update_documents

Methods included from Request

#delete, #get, #patch, #post, #put, #request

Constructor Details

#initialize(options = {}) ⇒ Client

Create a new SwiftypeAppSearch::Client client

Parameters:

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

    a hash of configuration options that will override what is set on the SwiftypeAppSearch class.

Options Hash (options):

  • :account_host_key (String)

    or :host_identifier is your Host Identifier to use with this client.

  • :api_key (String)

    can be any of your API Keys. Each has a different scope, so ensure you are using the correct key.

  • :overall_timeout (Numeric)

    overall timeout for requests in seconds (default: 15s)

  • :open_timeout (Numeric)

    the number of seconds Net::HTTP (default: 15s) will wait while opening a connection before raising a Timeout::Error



29
30
31
32
33
34
# File 'lib/swiftype-app-search/client.rb', line 29

def initialize(options = {})
  @api_endpoint = options.fetch(:api_endpoint) { "https://#{options.fetch(:account_host_key) { options.fetch(:host_identifier) }}.api.swiftype.com/api/as/v1/" }
  @api_key = options.fetch(:api_key)
  @open_timeout = options.fetch(:open_timeout, DEFAULT_TIMEOUT).to_f
  @overall_timeout = options.fetch(:overall_timeout, DEFAULT_TIMEOUT).to_f
end

Instance Attribute Details

#api_endpointObject (readonly)

Returns the value of attribute api_endpoint.



19
20
21
# File 'lib/swiftype-app-search/client.rb', line 19

def api_endpoint
  @api_endpoint
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



19
20
21
# File 'lib/swiftype-app-search/client.rb', line 19

def api_key
  @api_key
end

#open_timeoutObject (readonly)

Returns the value of attribute open_timeout.



19
20
21
# File 'lib/swiftype-app-search/client.rb', line 19

def open_timeout
  @open_timeout
end

#overall_timeoutObject (readonly)

Returns the value of attribute overall_timeout.



19
20
21
# File 'lib/swiftype-app-search/client.rb', line 19

def overall_timeout
  @overall_timeout
end