guidepost 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/guidepost/provider/zendesk.rb +32 -0
- 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: 12d91bd8f27f00b6c1115101abff0049121815b70fd4a1223518eafdd17cb138
|
4
|
+
data.tar.gz: c42f368aebda8b3f19acf800010202918726e03d34c37156ff0bbc8fbe0ebc1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25fcf491c96d16b379a4c2c1adf57d474c48ed607eb2bf790a5bd7f6654a1155165aee66b7192f8cf942cad1502aa04557a83ba0c8cd2734e16765b06e4a976f
|
7
|
+
data.tar.gz: 354413ea4349e1042f51ea1952c941670dc922971cfb9f5ba0f337dea797a6b624f17ab24e5947c8aded1c9352dc7574824549be19171c3ed8a028ed98cc7183
|
data/README.md
CHANGED
@@ -10,6 +10,7 @@ Your knowledge base is an incredibly important component of your company, provid
|
|
10
10
|
|
11
11
|
* [Back up your knowledge base to S3](#back-up-your-knowledge-base-to-s3)
|
12
12
|
* [Import your knowledge base into your application](#import-your-knowledge-base-into-your-application)
|
13
|
+
* [Search your knowledge base with keywords](#search-your-knowledge-base-with-keywords)
|
13
14
|
|
14
15
|
## Table of Contents
|
15
16
|
|
@@ -114,6 +115,22 @@ zendesk.backup_all_articles(sideload: true)
|
|
114
115
|
|
115
116
|
$ rake zendesk_guide:import_guides_into_database[spotify,employee-portal]
|
116
117
|
|
118
|
+
#### Search your knowledge base with keywords
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
# The subdomain of your Zendesk account
|
122
|
+
subdomain = "spotify"
|
123
|
+
|
124
|
+
# The name you want to give to your project (name your environment variables accordingly)
|
125
|
+
project_name = "employee-portal"
|
126
|
+
|
127
|
+
# The keyword(s) you're searching for in articles
|
128
|
+
query = "analytics"
|
129
|
+
|
130
|
+
zendesk = Guidepost::Provider::Zendesk.new(subdomain: subdomain, project_name: project_name)
|
131
|
+
zendesk.search(query: query)
|
132
|
+
```
|
133
|
+
|
117
134
|
## Contact
|
118
135
|
|
119
136
|
If you find and want to address any security issues with the project, email [me](mailto:srinitude@gmail.com.com)! For anything else, like bug identifications or feature requests, feel free to file a Github issue or tweet me [@srinitude](https://twitter.com/srinitude).
|
@@ -17,6 +17,38 @@ module Guidepost
|
|
17
17
|
@password = ENV["#{@project_name}_GUIDEPOST_ZENDESK_PASSWORD_TOKEN"]
|
18
18
|
end
|
19
19
|
|
20
|
+
def search(options={})
|
21
|
+
query = options.fetch(:query, "")
|
22
|
+
return [] if query.empty?
|
23
|
+
|
24
|
+
url = "#{self.base_api_url}/help_center/articles/search.json?query=#{query}&per_page=5"
|
25
|
+
uri = URI.parse(url)
|
26
|
+
|
27
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
28
|
+
http.use_ssl = true
|
29
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
30
|
+
|
31
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
32
|
+
request.basic_auth(@email, @password)
|
33
|
+
response = http.request(request)
|
34
|
+
|
35
|
+
body = response.body.force_encoding("UTF-8")
|
36
|
+
|
37
|
+
j_body = JSON.parse(body)
|
38
|
+
results = j_body.fetch("results", [])
|
39
|
+
|
40
|
+
slimmed_down_results = results.map do |result|
|
41
|
+
slimmed_down_result = Hash.new
|
42
|
+
slimmed_down_result[:id] = result["id"]
|
43
|
+
slimmed_down_result[:title] = result["title"]
|
44
|
+
slimmed_down_result[:snippet] = result["snippet"]
|
45
|
+
|
46
|
+
slimmed_down_result
|
47
|
+
end
|
48
|
+
|
49
|
+
slimmed_down_results
|
50
|
+
end
|
51
|
+
|
20
52
|
def backup_all_articles(options={})
|
21
53
|
# Get all articles (with pagination)
|
22
54
|
sideload = options[:sideload] || false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: guidepost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kiren Srinivasan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|