Class: HelpSpot
- Inherits:
-
Object
- Object
- HelpSpot
- Includes:
- HTTParty
- Defined in:
- lib/help_spot.rb,
lib/help_spot/version.rb
Defined Under Namespace
Classes: ApiErrors
Constant Summary collapse
- VERSION =
'0.2.1'
Instance Method Summary collapse
-
#authenticated? ⇒ Boolean
Verify authentication credentials.
- #categories ⇒ Object
- #create_request(options = {}) ⇒ Object
- #custom_fields(options = {}) ⇒ Object
- #filter(id, options = {}) ⇒ Object
-
#initialize(base, user, pass) ⇒ HelpSpot
constructor
A new instance of HelpSpot.
- #request(id, options = {}) ⇒ Object
- #search_requests(options = {}) ⇒ Object
- #search_time_events(options = {}) ⇒ Object
- #status_types ⇒ Object
- #time_events(id, options = {}) ⇒ Object
- #update_request(id, options = {}) ⇒ Object
Constructor Details
#initialize(base, user, pass) ⇒ HelpSpot
Returns a new instance of HelpSpot.
13 14 15 16 |
# File 'lib/help_spot.rb', line 13 def initialize(base, user, pass) self.class.base_uri base self.class.basic_auth user, pass end |
Instance Method Details
#authenticated? ⇒ Boolean
Verify authentication credentials
20 21 22 23 24 25 26 27 |
# File 'lib/help_spot.rb', line 20 def authenticated? version = begin api_request(:get, 'private.version').results.version true rescue HelpSpot::ApiErrors => e return false end end |
#categories ⇒ Object
51 52 53 |
# File 'lib/help_spot.rb', line 51 def categories api_request(:get, 'private.request.getCategories', {:fDeleted => 0}, {:collection => 'categories', :item => 'category'}) end |
#create_request(options = {}) ⇒ Object
29 30 31 32 33 |
# File 'lib/help_spot.rb', line 29 def create_request( = {}) raise ArgumentError unless [:tNote] && [:xCategory] raise ArgumentError unless [:sFirstName] || [:sLastName] || [:sUserId] || [:sEmail] || [:sPhone] api_request(:post, 'private.request.create', , :item => 'request').xRequest.to_i end |
#custom_fields(options = {}) ⇒ Object
59 60 61 |
# File 'lib/help_spot.rb', line 59 def custom_fields( = {}) api_request(:get, 'private.request.getCustomFields', , {:collection => 'customfields', :item => 'field'}) end |
#filter(id, options = {}) ⇒ Object
63 64 65 |
# File 'lib/help_spot.rb', line 63 def filter(id, = {}) api_request(:get, 'private.filter.get', .merge(:xFilter => id), {:collection => 'filter', :item => 'request'}) end |
#request(id, options = {}) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/help_spot.rb', line 39 def request(id, = {}) response = api_request(:get, 'private.request.get', .merge(:xRequest => id), :item => 'request') #munge even further the request history response.request_history = response.request_history['item'] rescue [] response.request_history = [response.request_history] unless response.request_history.is_a?(Array) response end |
#search_requests(options = {}) ⇒ Object
47 48 49 |
# File 'lib/help_spot.rb', line 47 def search_requests( = {}) api_request(:get, 'private.request.search', , {:collection => 'requests', :item => 'request'}) end |
#search_time_events(options = {}) ⇒ Object
67 68 69 |
# File 'lib/help_spot.rb', line 67 def search_time_events( = {}) api_request(:get, 'private.timetracker.search', , {:collection => 'time_events', :item => 'event'}) end |
#status_types ⇒ Object
55 56 57 |
# File 'lib/help_spot.rb', line 55 def status_types api_request(:get, 'private.request.getStatusTypes', {:fActiveOnly => 1}, {:collection => 'results', :item => 'status'}) end |
#time_events(id, options = {}) ⇒ Object
71 72 73 |
# File 'lib/help_spot.rb', line 71 def time_events(id, = {}) api_request(:get, 'private.request.getTimeEvents', .merge(:xRequest => id), {:collection => 'time_events', :item => 'event'}) end |
#update_request(id, options = {}) ⇒ Object
35 36 37 |
# File 'lib/help_spot.rb', line 35 def update_request(id, = {}) api_request(:post, 'private.request.update', .merge(:xRequest => id), :item => 'request').xRequest.to_i end |