help-scout-docs 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +56 -0
- data/README.rdoc +62 -0
- data/help_scout_docs.gemspec +33 -0
- data/lib/help_scout_docs.rb +14 -0
- data/lib/help_scout_docs/client.rb +95 -0
- data/lib/help_scout_docs/configurable.rb +78 -0
- data/lib/help_scout_docs/default.rb +55 -0
- data/lib/help_scout_docs/error.rb +5 -0
- data/lib/help_scout_docs/error/authentication_error.rb +6 -0
- data/lib/help_scout_docs/error/configuration_error.rb +6 -0
- data/lib/help_scout_docs/error/errors.rb +6 -0
- data/lib/help_scout_docs/error/options_error.rb +6 -0
- data/lib/help_scout_docs/error/parser_error.rb +6 -0
- data/lib/help_scout_docs/error/resource_not_found_error.rb +6 -0
- data/lib/help_scout_docs/method.rb +54 -0
- data/lib/help_scout_docs/methods/article.rb +45 -0
- data/lib/help_scout_docs/methods/category.rb +16 -0
- data/lib/help_scout_docs/methods/collection.rb +15 -0
- data/lib/help_scout_docs/methods/methods.rb +6 -0
- data/lib/help_scout_docs/methods/site.rb +15 -0
- data/lib/help_scout_docs/response/parse_json.rb +33 -0
- data/lib/help_scout_docs/result.rb +31 -0
- data/lib/help_scout_docs/version.rb +3 -0
- data/spec/cassettes/HelpScoutDocs_Article/_get/should_return_the_article.yml +46 -0
- data/spec/cassettes/HelpScoutDocs_Article/_get/when_using_an_id/should_return_the_article.yml +46 -0
- data/spec/cassettes/HelpScoutDocs_Article/_list_by_category/should_return_the_list_of_articles_by_category.yml +46 -0
- data/spec/cassettes/HelpScoutDocs_Article/_list_by_collection/should_return_the_list_of_articles_by_collection.yml +47 -0
- data/spec/cassettes/HelpScoutDocs_Article/_related/should_return_related_articles.yml +46 -0
- data/spec/cassettes/HelpScoutDocs_Article/_revisions/should_return_article_revisions.yml +46 -0
- data/spec/cassettes/HelpScoutDocs_Category/_get/should_return_the_category.yml +46 -0
- data/spec/cassettes/HelpScoutDocs_Category/_list/should_return_the_list_of_categories.yml +46 -0
- data/spec/cassettes/HelpScoutDocs_Client/_get/for_a_missing_request/should_raise_an_exception.yml +46 -0
- data/spec/cassettes/HelpScoutDocs_Client/_get/should_return_back_a_result.yml +65 -0
- data/spec/cassettes/HelpScoutDocs_Client/_get/with_invalid_authentication_params/should_raise_an_exception.yml +38 -0
- data/spec/cassettes/HelpScoutDocs_Client/_get/with_valid_params/should_call_the_requested_method.yml +65 -0
- data/spec/cassettes/HelpScoutDocs_Collection/_get/should_return_the_collection.yml +46 -0
- data/spec/cassettes/HelpScoutDocs_Collection/_list/should_return_the_list_of_collections.yml +48 -0
- data/spec/cassettes/HelpScoutDocs_Site/_get/should_return_the_site.yml +46 -0
- data/spec/cassettes/HelpScoutDocs_Site/_list/should_return_the_list_of_sites.yml +65 -0
- data/spec/client_spec.rb +78 -0
- data/spec/method_spec.rb +26 -0
- data/spec/methods/article_spec.rb +71 -0
- data/spec/methods/category_spec.rb +24 -0
- data/spec/methods/collection_spec.rb +23 -0
- data/spec/methods/site_spec.rb +23 -0
- data/spec/result_spec.rb +21 -0
- data/spec/spec_helper.rb +18 -0
- metadata +245 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://<api-key>:<api-password>@docsapi.helpscout.net/v1/sites/540221a1e4b019254d1ec25a
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.0
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
Accept-Charset:
|
15
|
+
- utf-8
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Date:
|
24
|
+
- Sun, 31 Aug 2014 19:02:54 GMT
|
25
|
+
Access-Control-Allow-Origin:
|
26
|
+
- "*"
|
27
|
+
Access-Control-Allow-Headers:
|
28
|
+
- Authorization
|
29
|
+
Access-Control-Allow-Methods:
|
30
|
+
- GET, POST, PUT, DELETE
|
31
|
+
Access-Control-Allow-Credentials:
|
32
|
+
- 'true'
|
33
|
+
Content-Type:
|
34
|
+
- application/json; charset=utf-8
|
35
|
+
Vary:
|
36
|
+
- Accept-Encoding,User-Agent
|
37
|
+
Content-Length:
|
38
|
+
- '355'
|
39
|
+
"<api-password>-Frame-Options":
|
40
|
+
- SAMEORIGIN
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '{"site":{"id":"540221a1e4b019254d1ec25a","subDomain":"rubydocsapi","cname":null,"hasPublicSite":true,"companyName":"Guestfolio","homePageContent":"articles","title":"RubyDocsAPI","description":null,"logoUrl":null,"logoWidth":null,"logoHeight":null,"favIconUrl":null,"touchIconUrl":null,"homeUrl":null,"homeLinkText":null,"pageBgColor":null,"headerBgColor":null,"navTextColor":null,"navActiveColor":null,"linkColor":null,"articleTextColor":null,"hasContactForm":false,"mailboxId":0,"contactEmail":null,"styleSheetUrl":null,"headerCode":null,"metaDescription":null,"createdBy":20055,"updatedBy":20055,"createdAt":"2014-08-30T19:10:25Z","updatedAt":"2014-08-30T19:10:25Z"}}'
|
44
|
+
http_version:
|
45
|
+
recorded_at: Sun, 31 Aug 2014 19:02:54 GMT
|
46
|
+
recorded_with: VCR 2.9.0
|
@@ -0,0 +1,65 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://<api-key>:<api-password>@docsapi.helpscout.net/v1/sites
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.0
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
Accept-Charset:
|
15
|
+
- utf-8
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Date:
|
24
|
+
- Sun, 31 Aug 2014 19:02:53 GMT
|
25
|
+
Access-Control-Allow-Origin:
|
26
|
+
- "*"
|
27
|
+
Access-Control-Allow-Headers:
|
28
|
+
- Authorization
|
29
|
+
Access-Control-Allow-Methods:
|
30
|
+
- GET, POST, PUT, DELETE
|
31
|
+
Access-Control-Allow-Credentials:
|
32
|
+
- 'true'
|
33
|
+
Content-Type:
|
34
|
+
- application/json; charset=utf-8
|
35
|
+
Vary:
|
36
|
+
- Accept-Encoding,User-Agent
|
37
|
+
Content-Length:
|
38
|
+
- '1563'
|
39
|
+
"<api-password>-Frame-Options":
|
40
|
+
- SAMEORIGIN
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '{"sites":{"page":1,"pages":1,"count":3,"items":[{"id":"5265aaffe4b0d77ef66a525d","subDomain":"guestfolio","cname":"help.guestfolio.com","hasPublicSite":true,"companyName":"Guestfolio","homePageContent":"categories","title":"Guestfolio
|
44
|
+
Knowledge Base","description":"Search the Guestfolio documentation","logoUrl":"https://s3.amazonaws.com/helpscout.net/docs/assets/5265aaffe4b0d77ef66a525c/images/5335ebb7e4b0cf4cd65802d2/Guestfolio-50.png","logoWidth":188,"logoHeight":50,"favIconUrl":"https://s3.amazonaws.com/helpscout.net/docs/assets/5265aaffe4b0d77ef66a525c/images/526afc70e4b09e5feddf352b/butterfly.png","touchIconUrl":"https://s3.amazonaws.com/helpscout.net/docs/assets/5265aaffe4b0d77ef66a525c/images/526afc9de4b09e5feddf352e/butterfly-200-1.png","homeUrl":"http://support.guestfolio.com","homeLinkText":"Documentation","pageBgColor":"#f5f5f5","headerBgColor":"#f8f8f8","navTextColor":"#888888","navActiveColor":"#30a5eb","linkColor":"#30a5eb","articleTextColor":null,"hasContactForm":false,"mailboxId":null,"contactEmail":null,"styleSheetUrl":"","headerCode":"<script>\nwindow.addEventListener(''load'',
|
45
|
+
function (){\n var li = document.createElement(''li'');\n var a = document.createElement(''a'');\n var
|
46
|
+
link = document.createTextNode(\"Contact Support\");\n a.appendChild(link);\n a.href
|
47
|
+
= \"http://support.guestfolio.com/contact\";\n li.appendChild(a);\n var
|
48
|
+
home = document.getElementById(\"home\");\n home.parentNode.insertBefore(li,
|
49
|
+
home.nextSibling);\n});\n</script>\n<link rel=''stylesheet'' id=''options_typography_Source+Sans+Pro-regular-css'' href=''https://fonts.googleapis.com/css?family=Source+Sans+Pro:regular''
|
50
|
+
type=''text/css'' media=''all'' />\n<link rel=''stylesheet'' id=''options_typography_Source+Sans+Pro-300-css'' href=''https://fonts.googleapis.com/css?family=Source+Sans+Pro:300''
|
51
|
+
type=''text/css'' media=''all'' />\n<link rel=''stylesheet'' id=''options_typography_Source+Sans+Pro-700-css'' href=''https://fonts.googleapis.com/css?family=Source+Sans+Pro:700''
|
52
|
+
type=''text/css'' media=''all'' />\n<style>\nbody {\n margin-top: 0;\n}\ndiv.navbar-inner
|
53
|
+
{\n border-bottom: 1px solid #ddd;\n}\nh1, h2, h3 {\n font-family: ''Source
|
54
|
+
Sans Pro'', ''Helvetica Neue'', Helvetica, Helvetica, Arial, sans-serif;\n}\n#sidebar
|
55
|
+
h3 {\n color: #00a9dc;\n font-weight: 200;\n line-height: 1.25;\n margin-bottom:
|
56
|
+
8px;\n font-size: 1.2em;\n}\np.lu {\n font-size: 0.6em;\n text-align: right;\n}\nol,
|
57
|
+
li, ul {\n margin-left: 20px;\n}\n.navbar .nav a {\n font-family: ''Source
|
58
|
+
Sans Pro'', ''Helvetica Neue'', Helvetica, Helvetica, Arial, sans-serif;\n text-transform:
|
59
|
+
uppercase;\n font-size: 17px;\n color: #888;\n}\n.navbar .nav a:hover {\n color:
|
60
|
+
#00a9dc;\n}\n\n</style>\n\n<script src=\"//cdn.sublimevideo.net/js/q4o9lqsy.js\"
|
61
|
+
type=\"text/javascript\"></script>","metaDescription":"Frequently asked questions
|
62
|
+
and support documentation for Guestfolio","createdBy":20055,"updatedBy":20055,"createdAt":"2014-03-28T21:50:34Z","updatedAt":"2014-07-17T23:33:20Z"},{"id":"540221a1e4b019254d1ec25a","subDomain":"rubydocsapi","cname":null,"hasPublicSite":true,"companyName":"Guestfolio","homePageContent":"articles","title":"RubyDocsAPI","description":null,"logoUrl":null,"logoWidth":null,"logoHeight":null,"favIconUrl":null,"touchIconUrl":null,"homeUrl":null,"homeLinkText":null,"pageBgColor":null,"headerBgColor":null,"navTextColor":null,"navActiveColor":null,"linkColor":null,"articleTextColor":null,"hasContactForm":false,"mailboxId":0,"contactEmail":null,"styleSheetUrl":null,"headerCode":null,"metaDescription":null,"createdBy":20055,"updatedBy":20055,"createdAt":"2014-08-30T19:10:25Z","updatedAt":"2014-08-30T19:10:25Z"},{"id":"5339e189e4b0cf4cd6580473","subDomain":"lasso","cname":"help.lasso.in","hasPublicSite":true,"companyName":"Guestfolio","homePageContent":"articles","title":"Lasso","description":"","logoUrl":"https://s3.amazonaws.com/helpscout.net/docs/assets/5265aaffe4b0d77ef66a525c/images/5400bb85e4b003be53bdcb6c/logo-large.png","logoWidth":75,"logoHeight":75,"favIconUrl":null,"touchIconUrl":"https://s3.amazonaws.com/helpscout.net/docs/assets/5265aaffe4b0d77ef66a525c/images/5400bb73e4b003be53bdcb6b/logo-large.png","homeUrl":"http://www.lasso.in","homeLinkText":"Home","pageBgColor":"#ffffff","headerBgColor":"#22a0a6","navTextColor":"#ffffff","navActiveColor":"#e7e7e7","linkColor":"#e41e25","articleTextColor":"#222222","hasContactForm":true,"mailboxId":20878,"contactEmail":null,"styleSheetUrl":"","headerCode":"","metaDescription":"","createdBy":20055,"updatedBy":20055,"createdAt":"2014-08-29T17:45:25Z","updatedAt":"2014-08-29T17:45:25Z"}]}}'
|
63
|
+
http_version:
|
64
|
+
recorded_at: Sun, 31 Aug 2014 19:02:53 GMT
|
65
|
+
recorded_with: VCR 2.9.0
|
data/spec/client_spec.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module HelpScoutDocs
|
5
|
+
describe Client do
|
6
|
+
let(:config) {
|
7
|
+
{
|
8
|
+
api_key: "api-key",
|
9
|
+
api_password: "api-password"
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
describe "#initialize" do
|
14
|
+
context "by default" do
|
15
|
+
it "should initialize a logger" do
|
16
|
+
expect(subject.logger).not_to be_nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should allow the default attributes to be set" do
|
21
|
+
expect(Client.new(config).instance_variable_get("@api_key")).to eq config[:api_key]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#get" do
|
26
|
+
it "should return back a result", :vcr do
|
27
|
+
expect(subject.get("sites")).to be_kind_of(Result)
|
28
|
+
end
|
29
|
+
|
30
|
+
context "with invalid authentication params", :vcr do
|
31
|
+
subject(:client) { Client.new(api_key: "invalid") }
|
32
|
+
|
33
|
+
it "should raise an exception" do
|
34
|
+
expect { subject.get("sites") }.to raise_error Error::AuthenticationError
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "with missing path params", :vcr do
|
39
|
+
it "should raise an exception" do
|
40
|
+
expect { subject.get(nil) }.to raise_error ArgumentError
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "with valid params", :vcr do
|
45
|
+
it "should call the requested method" do
|
46
|
+
result = subject.get("sites")
|
47
|
+
expect(result.success?).to be true
|
48
|
+
expect(result.response).to be_a_kind_of(Hash)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "for a missing request", :vcr do
|
53
|
+
it "should raise an exception" do
|
54
|
+
expect{ subject.get("sites/1") }.to raise_error HelpScoutDocs::Error::ResourceNotFoundError
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "when the response cannot be parsed" do
|
59
|
+
it "should throw an exception and log the error" do
|
60
|
+
logger = double(:logger)
|
61
|
+
expect(logger).to receive(:error).with(an_instance_of(String)) do |error|
|
62
|
+
expect(error).to eq "Unable to parse Help Scout Docs API response: JSON::ParserError"
|
63
|
+
end
|
64
|
+
expect(logger).to receive(:debug)
|
65
|
+
|
66
|
+
subject = Client.new(config.merge(logger: logger))
|
67
|
+
|
68
|
+
expect_any_instance_of(Faraday::Connection).to receive(:get) { raise JSON::ParserError }
|
69
|
+
expect { subject.get("sites") }.to raise_error HelpScoutDocs::Error::ParserError
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "#post" do
|
75
|
+
# See .get
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/spec/method_spec.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module HelpScoutDocs
|
4
|
+
describe Method do
|
5
|
+
describe "#initialize" do
|
6
|
+
context "by default" do
|
7
|
+
it "should initialize a new client" do
|
8
|
+
expect(Method.new.client).to be_kind_of(Client)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should pass through options to the client" do
|
12
|
+
method = HelpScoutDocs::Method.new(nil, api_key: "api-key")
|
13
|
+
expect(method.client.instance_variable_get("@api_key")).to eq "api-key"
|
14
|
+
end
|
15
|
+
|
16
|
+
context "when the client is already initialized" do
|
17
|
+
let(:client) { Client.new }
|
18
|
+
|
19
|
+
it "should intiialize using the existing client" do
|
20
|
+
expect(Method.new(client).client).to eq client
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module HelpScoutDocs
|
4
|
+
describe Article do
|
5
|
+
let(:article_id) { "54027853e4b019254d1ec268" }
|
6
|
+
let(:category_id) { "540227d7e4b003be53bdcd28" }
|
7
|
+
let(:collection_id) { "540221e9e4b019254d1ec25b" }
|
8
|
+
|
9
|
+
describe "#list_by_category", :vcr do
|
10
|
+
it "should return the list of articles by category" do
|
11
|
+
articles = subject.list_by_category(category_id).response
|
12
|
+
expect(articles).to be_kind_of(Hash)
|
13
|
+
expect(articles).to have_key(:articles)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#list_by_collection", :vcr do
|
18
|
+
it "should return the list of articles by collection" do
|
19
|
+
articles = subject.list_by_collection(collection_id).response
|
20
|
+
expect(articles).to be_kind_of(Hash)
|
21
|
+
expect(articles).to have_key(:articles)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#list" do
|
26
|
+
it "should call #list_by_category by default" do
|
27
|
+
expect(subject).to receive(:list_by_category).with(category_id, {})
|
28
|
+
subject.list(category_id)
|
29
|
+
end
|
30
|
+
|
31
|
+
context "passing :collection as type" do
|
32
|
+
it "should call #list_by_collection" do
|
33
|
+
expect(subject).to receive(:list_by_collection).with(collection_id, {})
|
34
|
+
subject.list(collection_id, :collection)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#get", :vcr do
|
40
|
+
it "should return the article" do
|
41
|
+
article = subject.get(article_id).response
|
42
|
+
expect(article).to be_kind_of(Hash)
|
43
|
+
expect(article).to have_key(:article)
|
44
|
+
end
|
45
|
+
|
46
|
+
context "when using an id" do
|
47
|
+
it "should return the article" do
|
48
|
+
article = subject.get(article_id).response
|
49
|
+
expect(article).to be_kind_of(Hash)
|
50
|
+
expect(article).to have_key(:article)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "#related", :vcr do
|
56
|
+
it "should return related articles" do
|
57
|
+
related = subject.related(article_id).response
|
58
|
+
expect(related).to be_kind_of(Hash)
|
59
|
+
expect(related).to have_key(:articles)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "#revisions", :vcr do
|
64
|
+
it "should return article revisions" do
|
65
|
+
revisions = subject.related(article_id).response
|
66
|
+
expect(revisions).to be_kind_of(Hash)
|
67
|
+
expect(revisions).to have_key(:articles)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module HelpScoutDocs
|
4
|
+
describe Category do
|
5
|
+
let(:category_id) { "540227d7e4b003be53bdcd28" }
|
6
|
+
let(:collection_id) { "540221e9e4b019254d1ec25b" }
|
7
|
+
|
8
|
+
describe "#list", :vcr do
|
9
|
+
it "should return the list of categories" do
|
10
|
+
categories = subject.list(collection_id).response
|
11
|
+
expect(categories).to be_kind_of(Hash)
|
12
|
+
expect(categories).to have_key(:categories)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#get", :vcr do
|
17
|
+
it "should return the category" do
|
18
|
+
category = subject.get(category_id).response
|
19
|
+
expect(category).to be_kind_of(Hash)
|
20
|
+
expect(category).to have_key(:category)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module HelpScoutDocs
|
4
|
+
describe Collection do
|
5
|
+
describe "#list", :vcr do
|
6
|
+
it "should return the list of collections" do
|
7
|
+
collections = subject.list.response
|
8
|
+
expect(collections).to be_kind_of(Hash)
|
9
|
+
expect(collections).to have_key(:collections)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#get", :vcr do
|
14
|
+
let(:collection_id) { "540221e9e4b019254d1ec25b" }
|
15
|
+
|
16
|
+
it "should return the collection" do
|
17
|
+
collection = subject.get(collection_id).response
|
18
|
+
expect(collection).to be_kind_of(Hash)
|
19
|
+
expect(collection).to have_key(:collection)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module HelpScoutDocs
|
4
|
+
describe Site do
|
5
|
+
describe "#list", :vcr do
|
6
|
+
it "should return the list of sites" do
|
7
|
+
sites = subject.list.response
|
8
|
+
expect(sites).to be_kind_of(Hash)
|
9
|
+
expect(sites).to have_key(:sites)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#get", :vcr do
|
14
|
+
let(:site_id) { "540221a1e4b019254d1ec25a" }
|
15
|
+
|
16
|
+
it "should return the site" do
|
17
|
+
site = subject.get(site_id).response
|
18
|
+
expect(site).to be_kind_of(Hash)
|
19
|
+
expect(site).to have_key(:site)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/result_spec.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module HelpScoutDocs
|
4
|
+
describe Result do
|
5
|
+
describe "#success?" do
|
6
|
+
it "should return true for a successful response" do
|
7
|
+
expect(Result.new({message: "success"}).success?).to be true
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return false for an unsuccessful response" do
|
11
|
+
expect(Result.new({status: "401"}).success?).to be false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#message" do
|
16
|
+
it "should return the error message for a failed response" do
|
17
|
+
expect(Result.new({status: "404", message: "Message"}).message).to eq "Message"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
ENV['HELP_SCOUT_DOCS_API_KEY'] = "api-key";
|
2
|
+
|
3
|
+
require 'help_scout_docs'
|
4
|
+
require 'webmock'
|
5
|
+
require 'multi_json'
|
6
|
+
require 'vcr'
|
7
|
+
require 'pry'
|
8
|
+
|
9
|
+
VCR.configure do |c|
|
10
|
+
c.allow_http_connections_when_no_cassette = true
|
11
|
+
c.cassette_library_dir = 'spec/cassettes'
|
12
|
+
c.hook_into :webmock
|
13
|
+
c.filter_sensitive_data('<api-key>') { ENV['HELP_SCOUT_DOCS_API_KEY'] }
|
14
|
+
c.filter_sensitive_data('<api-password>') { "X" }
|
15
|
+
c.configure_rspec_metadata!
|
16
|
+
end
|
17
|
+
|
18
|
+
Log4r::Logger.global.outputters = Log4r::Outputter.stdout
|
metadata
ADDED
@@ -0,0 +1,245 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: help-scout-docs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mark Edmondson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: multi_json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: webmock
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.15'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.15'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: vcr
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.9'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.9'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json_spec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.1'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.1'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: log4r
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.1'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.1'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: faraday_middleware
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.9'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.9'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: json
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.8'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.8'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: net-http-persistent
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.9'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.9'
|
139
|
+
description: This limited (read-only) Help Scout Docs API integration provides functionality
|
140
|
+
for extracting existing documentation content
|
141
|
+
email:
|
142
|
+
- mark@guestfolio.com
|
143
|
+
executables: []
|
144
|
+
extensions: []
|
145
|
+
extra_rdoc_files: []
|
146
|
+
files:
|
147
|
+
- ".rspec"
|
148
|
+
- Gemfile
|
149
|
+
- Gemfile.lock
|
150
|
+
- README.rdoc
|
151
|
+
- help_scout_docs.gemspec
|
152
|
+
- lib/help_scout_docs.rb
|
153
|
+
- lib/help_scout_docs/client.rb
|
154
|
+
- lib/help_scout_docs/configurable.rb
|
155
|
+
- lib/help_scout_docs/default.rb
|
156
|
+
- lib/help_scout_docs/error.rb
|
157
|
+
- lib/help_scout_docs/error/authentication_error.rb
|
158
|
+
- lib/help_scout_docs/error/configuration_error.rb
|
159
|
+
- lib/help_scout_docs/error/errors.rb
|
160
|
+
- lib/help_scout_docs/error/options_error.rb
|
161
|
+
- lib/help_scout_docs/error/parser_error.rb
|
162
|
+
- lib/help_scout_docs/error/resource_not_found_error.rb
|
163
|
+
- lib/help_scout_docs/method.rb
|
164
|
+
- lib/help_scout_docs/methods/article.rb
|
165
|
+
- lib/help_scout_docs/methods/category.rb
|
166
|
+
- lib/help_scout_docs/methods/collection.rb
|
167
|
+
- lib/help_scout_docs/methods/methods.rb
|
168
|
+
- lib/help_scout_docs/methods/site.rb
|
169
|
+
- lib/help_scout_docs/response/parse_json.rb
|
170
|
+
- lib/help_scout_docs/result.rb
|
171
|
+
- lib/help_scout_docs/version.rb
|
172
|
+
- spec/cassettes/HelpScoutDocs_Article/_get/should_return_the_article.yml
|
173
|
+
- spec/cassettes/HelpScoutDocs_Article/_get/when_using_an_id/should_return_the_article.yml
|
174
|
+
- spec/cassettes/HelpScoutDocs_Article/_list_by_category/should_return_the_list_of_articles_by_category.yml
|
175
|
+
- spec/cassettes/HelpScoutDocs_Article/_list_by_collection/should_return_the_list_of_articles_by_collection.yml
|
176
|
+
- spec/cassettes/HelpScoutDocs_Article/_related/should_return_related_articles.yml
|
177
|
+
- spec/cassettes/HelpScoutDocs_Article/_revisions/should_return_article_revisions.yml
|
178
|
+
- spec/cassettes/HelpScoutDocs_Category/_get/should_return_the_category.yml
|
179
|
+
- spec/cassettes/HelpScoutDocs_Category/_list/should_return_the_list_of_categories.yml
|
180
|
+
- spec/cassettes/HelpScoutDocs_Client/_get/for_a_missing_request/should_raise_an_exception.yml
|
181
|
+
- spec/cassettes/HelpScoutDocs_Client/_get/should_return_back_a_result.yml
|
182
|
+
- spec/cassettes/HelpScoutDocs_Client/_get/with_invalid_authentication_params/should_raise_an_exception.yml
|
183
|
+
- spec/cassettes/HelpScoutDocs_Client/_get/with_valid_params/should_call_the_requested_method.yml
|
184
|
+
- spec/cassettes/HelpScoutDocs_Collection/_get/should_return_the_collection.yml
|
185
|
+
- spec/cassettes/HelpScoutDocs_Collection/_list/should_return_the_list_of_collections.yml
|
186
|
+
- spec/cassettes/HelpScoutDocs_Site/_get/should_return_the_site.yml
|
187
|
+
- spec/cassettes/HelpScoutDocs_Site/_list/should_return_the_list_of_sites.yml
|
188
|
+
- spec/client_spec.rb
|
189
|
+
- spec/method_spec.rb
|
190
|
+
- spec/methods/article_spec.rb
|
191
|
+
- spec/methods/category_spec.rb
|
192
|
+
- spec/methods/collection_spec.rb
|
193
|
+
- spec/methods/site_spec.rb
|
194
|
+
- spec/result_spec.rb
|
195
|
+
- spec/spec_helper.rb
|
196
|
+
homepage: https://github.com/Guestfolio/help-scout-docs
|
197
|
+
licenses:
|
198
|
+
- MIT
|
199
|
+
metadata: {}
|
200
|
+
post_install_message:
|
201
|
+
rdoc_options: []
|
202
|
+
require_paths:
|
203
|
+
- lib
|
204
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
requirements: []
|
215
|
+
rubyforge_project:
|
216
|
+
rubygems_version: 2.2.2
|
217
|
+
signing_key:
|
218
|
+
specification_version: 4
|
219
|
+
summary: Integration with Help Scout Docs API
|
220
|
+
test_files:
|
221
|
+
- spec/cassettes/HelpScoutDocs_Article/_get/should_return_the_article.yml
|
222
|
+
- spec/cassettes/HelpScoutDocs_Article/_get/when_using_an_id/should_return_the_article.yml
|
223
|
+
- spec/cassettes/HelpScoutDocs_Article/_list_by_category/should_return_the_list_of_articles_by_category.yml
|
224
|
+
- spec/cassettes/HelpScoutDocs_Article/_list_by_collection/should_return_the_list_of_articles_by_collection.yml
|
225
|
+
- spec/cassettes/HelpScoutDocs_Article/_related/should_return_related_articles.yml
|
226
|
+
- spec/cassettes/HelpScoutDocs_Article/_revisions/should_return_article_revisions.yml
|
227
|
+
- spec/cassettes/HelpScoutDocs_Category/_get/should_return_the_category.yml
|
228
|
+
- spec/cassettes/HelpScoutDocs_Category/_list/should_return_the_list_of_categories.yml
|
229
|
+
- spec/cassettes/HelpScoutDocs_Client/_get/for_a_missing_request/should_raise_an_exception.yml
|
230
|
+
- spec/cassettes/HelpScoutDocs_Client/_get/should_return_back_a_result.yml
|
231
|
+
- spec/cassettes/HelpScoutDocs_Client/_get/with_invalid_authentication_params/should_raise_an_exception.yml
|
232
|
+
- spec/cassettes/HelpScoutDocs_Client/_get/with_valid_params/should_call_the_requested_method.yml
|
233
|
+
- spec/cassettes/HelpScoutDocs_Collection/_get/should_return_the_collection.yml
|
234
|
+
- spec/cassettes/HelpScoutDocs_Collection/_list/should_return_the_list_of_collections.yml
|
235
|
+
- spec/cassettes/HelpScoutDocs_Site/_get/should_return_the_site.yml
|
236
|
+
- spec/cassettes/HelpScoutDocs_Site/_list/should_return_the_list_of_sites.yml
|
237
|
+
- spec/client_spec.rb
|
238
|
+
- spec/method_spec.rb
|
239
|
+
- spec/methods/article_spec.rb
|
240
|
+
- spec/methods/category_spec.rb
|
241
|
+
- spec/methods/collection_spec.rb
|
242
|
+
- spec/methods/site_spec.rb
|
243
|
+
- spec/result_spec.rb
|
244
|
+
- spec/spec_helper.rb
|
245
|
+
has_rdoc: true
|