module GrooveHQ::Client::Connection
Public Instance Methods
delete(path, options = {})
click to toggle source
# File lib/groovehq/client/connection.rb, line 19 def delete(path, options = {}) request :delete, path, options end
get(path, options = {})
click to toggle source
# File lib/groovehq/client/connection.rb, line 7 def get(path, options = {}) request :get, path, options end
post(path, options = {})
click to toggle source
# File lib/groovehq/client/connection.rb, line 11 def post(path, options = {}) request :post, path, options end
put(path, options = {})
click to toggle source
# File lib/groovehq/client/connection.rb, line 15 def put(path, options = {}) request :put, path, options end
Private Instance Methods
parse_data(original_data)
click to toggle source
# File lib/groovehq/client/connection.rb, line 31 def parse_data(original_data) return unless original_data # This hack is added primaraly to deal with API response inconsistencies: # https://www.groovehq.com/docs/ticket-counts#listing-ticket-counts (one key per folder) # https://www.groovehq.com/docs/tickets#listing-tickets (has two keys: 'tickets' and 'meta') # https://www.groovehq.com/docs/tickets#finding-one-ticket (one key: 'ticket') # :( data = original_data.keys.count <= 2 ? original_data.values.first : original_data case data when Hash then Resource.new(self, data) when Array then ResourceCollection.new(self, original_data) when nil then nil else data end end
request(http_method, path, options)
click to toggle source
# File lib/groovehq/client/connection.rb, line 25 def request(http_method, path, options) response = self.class.send(http_method, path, { body: options }) data = response.parsed_response parse_data(data) end