swiftype-app-search 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -7
- data/lib/swiftype-app-search/client.rb +3 -3
- data/lib/swiftype-app-search/version.rb +1 -1
- data/spec/client_spec.rb +6 -1
- data/spec/spec_helper.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a2254f5b17c63dc6aad243e5b4a7e165cdfc7fd29f75ef20f3a7d8b46f57403
|
4
|
+
data.tar.gz: 4f5967113edc23e4d9b1a521d06e14c64e7cb69a37d57d6ef342b5003be70f2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec871c6e1c1e798cb91e749cde14e86a7fdca6c119855fa84a23cf29a09962018ee4022849017450d201784dce32023e47fb4ebf83390cd63aea7ffdcbd2853d
|
7
|
+
data.tar.gz: f9a52b4a5d73328230c55498a9bef95b6045271ecf49ca29fe2b2b7eeea7c16be4a92efdccc98c8ad4f7aa68fb7c4e4a392657e8cf6dfd72aa3638464e569f6c
|
data/README.md
CHANGED
@@ -14,12 +14,14 @@ Or place `gem 'swiftype-app-search', '~> 0.1.3` in your `Gemfile` and run `bundl
|
|
14
14
|
|
15
15
|
### Setup: Configuring the client and authentication
|
16
16
|
|
17
|
-
Create a new instance of the Swiftype App Search Client. This requires your `
|
17
|
+
Create a new instance of the Swiftype App Search Client. This requires your `[HOST_IDENTIFIER]`, which
|
18
18
|
identifies the unique hostname of the Swiftype API that is associated with your Swiftype account.
|
19
|
-
It also requires a valid `API_KEY`, which authenticates requests to the API
|
19
|
+
It also requires a valid `[API_KEY]`, which authenticates requests to the API. You can use any key type with the client, however each has a different scope. For more information on keys, check out the [documentation](https://swiftype.com/documentation/app-search/credentials).
|
20
|
+
|
21
|
+
You can find your `[API_KEY]` and your `[HOST_IDENTIFIER]` within the [Credentials](https://app.swiftype.com/as/credentials) menu:
|
20
22
|
|
21
23
|
```ruby
|
22
|
-
client = SwiftypeAppSearch::Client.new(:
|
24
|
+
client = SwiftypeAppSearch::Client.new(:host_identifier => 'host-c5s2mj', :api_key => 'api-mu75psc5egt9ppzuycnc2mc3')
|
23
25
|
```
|
24
26
|
|
25
27
|
### API Methods
|
@@ -171,16 +173,16 @@ end
|
|
171
173
|
## Running Tests
|
172
174
|
|
173
175
|
```bash
|
174
|
-
export AS_API_KEY="
|
175
|
-
export
|
176
|
+
export AS_API_KEY="[API_KEY]"
|
177
|
+
export AS_HOST_IDENTIFIER="[HOST_IDENTIFIER]"
|
176
178
|
bundle exec rspec
|
177
179
|
```
|
178
180
|
|
179
181
|
You can also run tests against a local environment by passing a `AS_API_ENDPOINT` environment variable
|
180
182
|
|
181
183
|
```bash
|
182
|
-
export AS_API_KEY="
|
183
|
-
export AS_API_ENDPOINT="http
|
184
|
+
export AS_API_KEY="[API_KEY]"
|
185
|
+
export AS_API_ENDPOINT="http://[HOST_IDENTIFIER].api.127.0.0.1.ip.es.io:3002/api/as/v1"
|
184
186
|
bundle exec rspec
|
185
187
|
```
|
186
188
|
|
@@ -19,13 +19,13 @@ module SwiftypeAppSearch
|
|
19
19
|
# Create a new SwiftypeAppSearch::Client client
|
20
20
|
#
|
21
21
|
# @param options [Hash] a hash of configuration options that will override what is set on the SwiftypeAppSearch class.
|
22
|
-
# @option options [String] :account_host_key
|
23
|
-
# @option options [String] :api_key
|
22
|
+
# @option options [String] :account_host_key or :host_identifier is your Host Identifier to use with this client.
|
23
|
+
# @option options [String] :api_key can be any of your API Keys. Each has a different scope, so ensure you are using the correct key.
|
24
24
|
# @option options [Numeric] :overall_timeout overall timeout for requests in seconds (default: 15s)
|
25
25
|
# @option options [Numeric] :open_timeout the number of seconds Net::HTTP (default: 15s)
|
26
26
|
# will wait while opening a connection before raising a Timeout::Error
|
27
27
|
def initialize(options = {})
|
28
|
-
@api_endpoint = options.fetch(:api_endpoint) { "https://#{options.fetch(:account_host_key)}.api.swiftype.com/api/as/v1/" }
|
28
|
+
@api_endpoint = options.fetch(:api_endpoint) { "https://#{options.fetch(:account_host_key) { options.fetch(:host_identifier) }}.api.swiftype.com/api/as/v1/" }
|
29
29
|
@api_key = options.fetch(:api_key)
|
30
30
|
@open_timeout = options.fetch(:open_timeout, DEFAULT_TIMEOUT).to_f
|
31
31
|
@overall_timeout = options.fetch(:overall_timeout, DEFAULT_TIMEOUT).to_f
|
data/spec/client_spec.rb
CHANGED
@@ -148,8 +148,13 @@ describe SwiftypeAppSearch::Client do
|
|
148
148
|
end
|
149
149
|
|
150
150
|
context 'Configuration' do
|
151
|
-
context '
|
151
|
+
context 'host_identifier' do
|
152
152
|
it 'sets the base url correctly' do
|
153
|
+
client = SwiftypeAppSearch::Client.new(:host_identifier => 'host-asdf', :api_key => 'foo')
|
154
|
+
expect(client.api_endpoint).to eq('https://host-asdf.api.swiftype.com/api/as/v1/')
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'sets the base url correctly using deprecated as_host_key' do
|
153
158
|
client = SwiftypeAppSearch::Client.new(:account_host_key => 'host-asdf', :api_key => 'foo')
|
154
159
|
expect(client.api_endpoint).to eq('https://host-asdf.api.swiftype.com/api/as/v1/')
|
155
160
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,12 +6,13 @@ require 'swiftype-app-search'
|
|
6
6
|
|
7
7
|
RSpec.shared_context "App Search Credentials" do
|
8
8
|
let(:as_api_key) { ENV.fetch('AS_API_KEY', 'API_KEY') }
|
9
|
-
|
9
|
+
# AS_ACCOUNT_HOST_KEY is deprecated
|
10
|
+
let(:as_host_identifier) { ENV['AS_ACCOUNT_HOST_KEY'] || ENV['AS_HOST_IDENTIFIER'] || 'ACCOUNT_HOST_KEY' }
|
10
11
|
let(:as_api_endpoint) { ENV.fetch('AS_API_ENDPOINT', nil) }
|
11
12
|
let(:client_options) do
|
12
13
|
{
|
13
14
|
:api_key => as_api_key,
|
14
|
-
:
|
15
|
+
:host_identifier => as_host_identifier
|
15
16
|
}.tap do |opts|
|
16
17
|
opts[:api_endpoint] = as_api_endpoint unless as_api_endpoint.nil?
|
17
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swiftype-app-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Quin Hoxie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|