help_spot_issues 0.0.1
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.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE +19 -0
- data/README +27 -0
- data/Rakefile +1 -0
- data/config/help_spot.yml.sample +6 -0
- data/help_spot_issues.gemspec +22 -0
- data/lib/help_spot.rb +6 -0
- data/lib/help_spot/base.rb +109 -0
- data/lib/help_spot/version.rb +3 -0
- metadata +71 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2012 Jon Phenow, Ian Ehlert
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
data/README
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
= HelpSpot
|
|
3
|
+
|
|
4
|
+
Ruby gem to talk to the API of a HelpSpot instance.
|
|
5
|
+
|
|
6
|
+
For information on HelpSpot: http://www.userscape.com/products/helpspot/
|
|
7
|
+
|
|
8
|
+
Details of HelpSpot's API are at: http://www.userscape.com/helpdesk/index.php?pg=kb.book&id=6
|
|
9
|
+
|
|
10
|
+
== License
|
|
11
|
+
|
|
12
|
+
Licensed under the MIT License. See the included LICENSE file.
|
|
13
|
+
|
|
14
|
+
= Usage
|
|
15
|
+
|
|
16
|
+
== Installation
|
|
17
|
+
|
|
18
|
+
Copy the <tt>config/help_spot.yml.sample</tt> file to <tt>THE_ROOT_DIR_OF_YOUR_APP/config/help_spot.yml</tt>. Edit the file to have some sensible values.
|
|
19
|
+
|
|
20
|
+
Somewhere in your application, you'll want to do this once:
|
|
21
|
+
|
|
22
|
+
<tt>HelpSpot.configure</tt>
|
|
23
|
+
|
|
24
|
+
In my app, it also turns out it's useful to do this once:
|
|
25
|
+
|
|
26
|
+
<tt>HELPSPOT_CATEGORIES = HelpSpot.category_key_value_pairs</tt>
|
|
27
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "help_spot/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "help_spot_issues"
|
|
7
|
+
s.version = HelpSpot::VERSION
|
|
8
|
+
s.authors = ["Jon Phenow"]
|
|
9
|
+
s.email = ["j.phenow@gmail.com"]
|
|
10
|
+
s.homepage = ""
|
|
11
|
+
s.summary = %q{Connector to Help Spot API}
|
|
12
|
+
s.description = %q{}
|
|
13
|
+
|
|
14
|
+
s.files = `git ls-files`.split("\n")
|
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
17
|
+
s.require_paths = ["lib"]
|
|
18
|
+
|
|
19
|
+
# specify any dependencies here; for example:
|
|
20
|
+
s.add_development_dependency "rake"
|
|
21
|
+
# s.add_runtime_dependency "rest-client"
|
|
22
|
+
end
|
data/lib/help_spot.rb
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
##
|
|
2
|
+
# help_spot
|
|
3
|
+
#
|
|
4
|
+
# A partial basic implementation of a HelpSpot API interface
|
|
5
|
+
#
|
|
6
|
+
# == Using help_spot
|
|
7
|
+
#
|
|
8
|
+
# === Basics
|
|
9
|
+
#
|
|
10
|
+
# Copy and edit the included config file. Include the gem in your app. Call the configure method. Hit the API.
|
|
11
|
+
#
|
|
12
|
+
# require 'help_spot'
|
|
13
|
+
# HelpSpot.configure(:app_root => '/my_app/')
|
|
14
|
+
# HelpSpot.forums_list
|
|
15
|
+
#
|
|
16
|
+
# => [{"xForumId"=>"1", "fClosed"=>"0", "sForumName"=>"The First Forum", "iOrder"=>"0", "sDescription"=>"A test forum"}, {"xForumId"=>"2", "fClosed"=>"0", "sForumName"=>"Secondary Forum", "iOrder"=>"0", "sDescription"=>"Forum #2"}]
|
|
17
|
+
#
|
|
18
|
+
|
|
19
|
+
module HelpSpot
|
|
20
|
+
class << self
|
|
21
|
+
|
|
22
|
+
# Loads the config file.
|
|
23
|
+
#
|
|
24
|
+
# == Options
|
|
25
|
+
# * app_root (optional)
|
|
26
|
+
# Path to the root directory of your app. Shouldn't be required when using merb or Rails.
|
|
27
|
+
# * config_file (optional)
|
|
28
|
+
# Defaults to '/config/help_spot.yml'
|
|
29
|
+
#
|
|
30
|
+
def configure(args={})
|
|
31
|
+
# work out the default app_root
|
|
32
|
+
app_root = args[:app_root] || '.'
|
|
33
|
+
|
|
34
|
+
config_file = args[:config_file] || '/config/help_spot.yml'
|
|
35
|
+
yml_file = app_root+config_file
|
|
36
|
+
|
|
37
|
+
raise yml_file+" not found" unless File.exist? yml_file
|
|
38
|
+
@config = YAML.load(File.open yml_file)
|
|
39
|
+
@config["api_url"] = @config["root_url"] + "/api/index.php?output=json"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def root_url
|
|
43
|
+
@config["root_url"]
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def get_request(request_id)
|
|
47
|
+
JSON.parse(api_request('private.request.get', 'GET', {:xRequest => request_id})) if request_id
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def get_changed(time, category)
|
|
51
|
+
requests = []
|
|
52
|
+
req_ids = JSON.parse(api_request('private.request.getChanged', 'GET', {:dtGMTChange => time.to_i}))["xRequest"]
|
|
53
|
+
req_ids.uniq!
|
|
54
|
+
req_ids.each do |req_id|
|
|
55
|
+
request = get_request(req_id)
|
|
56
|
+
requests << request if request["xCategory"] == category
|
|
57
|
+
end
|
|
58
|
+
requests
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def get_custom_fields(category=nil)
|
|
62
|
+
JSON.parse(api_request('private.request.getCustomFields', 'GET', {:xCategory => category}))["field"]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def get_categories(category=nil)
|
|
66
|
+
JSON.parse(api_request('request.getCategories', 'GET'))["category"]
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def categories(args={})
|
|
70
|
+
res = api_request('private.request.getCategories', 'GET')
|
|
71
|
+
res = JSON.parse(res)['category'] rescue []
|
|
72
|
+
|
|
73
|
+
unless args[:include_deleted] and args[:include_deleted] == true
|
|
74
|
+
res.reject!{|k, v| v['fDeleted'] == '1'} rescue []
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
return res
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def update_request(options)
|
|
81
|
+
JSON.parse(api_request('private.request.update', 'POST', options))
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def api_request(api_method, http_method='POST', args={})
|
|
85
|
+
api_params = {:method => api_method, :output => 'json'}.merge(args)
|
|
86
|
+
query_params = api_params.collect{|k,v| [k.to_s, v.to_s]} # [URI.encode(k.to_s),URI.encode(v.to_s.gsub(/\ /, '+'))]
|
|
87
|
+
built_query = query_params.collect{|i| i.join('=')}.join('&') # make a query string
|
|
88
|
+
|
|
89
|
+
ru = URI::parse(@config['api_url']) # where ru = ROOT_URL
|
|
90
|
+
merged_query = [built_query, (ru.query == '' ? nil : ru.query)].compact.join('&') # merge our generated query string with the ROOT_URL's query string
|
|
91
|
+
|
|
92
|
+
url = URI::HTTP.new(ru.scheme, ru.userinfo, ru.host, ru.port, ru.registry, ru.path, ru.opaque, merged_query, ru.fragment)
|
|
93
|
+
|
|
94
|
+
if http_method == 'POST'
|
|
95
|
+
req = Net::HTTP::Post.new(url.path)
|
|
96
|
+
req.set_form_data(query_params)
|
|
97
|
+
req.basic_auth @config['username'], @config['password']
|
|
98
|
+
res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
|
|
99
|
+
else
|
|
100
|
+
req = Net::HTTP::Get.new(url.path+'?'+url.query)
|
|
101
|
+
req.basic_auth @config['username'], @config['password']
|
|
102
|
+
res = Net::HTTP.start(url.host, url.port) {|http| http.request(req) }
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
res.body
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
end # class
|
|
109
|
+
end # module
|
metadata
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: help_spot_issues
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Jon Phenow
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-03-15 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: rake
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :development
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ! '>='
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '0'
|
|
30
|
+
description: ''
|
|
31
|
+
email:
|
|
32
|
+
- j.phenow@gmail.com
|
|
33
|
+
executables: []
|
|
34
|
+
extensions: []
|
|
35
|
+
extra_rdoc_files: []
|
|
36
|
+
files:
|
|
37
|
+
- .gitignore
|
|
38
|
+
- Gemfile
|
|
39
|
+
- LICENSE
|
|
40
|
+
- README
|
|
41
|
+
- Rakefile
|
|
42
|
+
- config/help_spot.yml.sample
|
|
43
|
+
- help_spot_issues.gemspec
|
|
44
|
+
- lib/help_spot.rb
|
|
45
|
+
- lib/help_spot/base.rb
|
|
46
|
+
- lib/help_spot/version.rb
|
|
47
|
+
homepage: ''
|
|
48
|
+
licenses: []
|
|
49
|
+
post_install_message:
|
|
50
|
+
rdoc_options: []
|
|
51
|
+
require_paths:
|
|
52
|
+
- lib
|
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
54
|
+
none: false
|
|
55
|
+
requirements:
|
|
56
|
+
- - ! '>='
|
|
57
|
+
- !ruby/object:Gem::Version
|
|
58
|
+
version: '0'
|
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
|
+
none: false
|
|
61
|
+
requirements:
|
|
62
|
+
- - ! '>='
|
|
63
|
+
- !ruby/object:Gem::Version
|
|
64
|
+
version: '0'
|
|
65
|
+
requirements: []
|
|
66
|
+
rubyforge_project:
|
|
67
|
+
rubygems_version: 1.8.19
|
|
68
|
+
signing_key:
|
|
69
|
+
specification_version: 3
|
|
70
|
+
summary: Connector to Help Spot API
|
|
71
|
+
test_files: []
|