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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82358c2aedf2cf4ff5be38ecadf44b320a3ceb57b708f3693726b160710fcb3e
4
- data.tar.gz: 4cf42bd484d7d14a18b30acac71aca261fc54f4b624626beaaf0b835046d16af
3
+ metadata.gz: 12d91bd8f27f00b6c1115101abff0049121815b70fd4a1223518eafdd17cb138
4
+ data.tar.gz: c42f368aebda8b3f19acf800010202918726e03d34c37156ff0bbc8fbe0ebc1a
5
5
  SHA512:
6
- metadata.gz: 23195e608a8a0deb9764da52ef4c347dfdb4143aa2655a703230a25986260548f2d0b00956fe125ea64f6861c0ae3d70779fb36be044f1610690309b64933c39
7
- data.tar.gz: faf2a13bafd4990077c3b341cf3b91cb65b5dee4f06a0828abad7590ab2eb5076629edb017251b7ee5255720c5007c95ffa388bf3322729f5238e3e6216a8ecd
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.1
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-13 00:00:00.000000000 Z
11
+ date: 2019-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk