class Tictail::Client
Attributes
access_token[RW]
Public Class Methods
new(url = 'https://api.tictail.com')
click to toggle source
Creates a new instance of Tictail::Api::Client
@param url [String] The url to Tictail
api (api.tictail.com)
# File lib/tictail/api/client.rb, line 35 def initialize(url = 'https://api.tictail.com') @url = url end
Public Instance Methods
delete(url, params)
click to toggle source
Does a DELETE request to the url with the params
@param url [String] the relative path in the Tictail
API
# File lib/tictail/api/client.rb, line 77 def delete(url, params) params = convert_hash_keys(params) @access_token = params.delete('access_token') if params['access_token'] return connection.delete(url) end
get(url, params = {})
click to toggle source
Does a GET request to the url with the params
@param url [String] the relative path in the Tictail
API @param params [Hash] the url params that should be passed in the request
# File lib/tictail/api/client.rb, line 45 def get(url, params = {}) params = convert_hash_keys(params) @access_token = params.delete('access_token') if params['access_token'] return connection.get(url, params) end
post(url, params)
click to toggle source
Does a POST request to the url with the params
@param url [String] the relative path in the Tictail
API @param params [Hash] the body of the request
# File lib/tictail/api/client.rb, line 56 def post(url, params) params = convert_hash_keys(params) @access_token = params.delete('access_token') if params['access_token'] return connection.post(url, params) end
put(url, params)
click to toggle source
Does a PUT request to the url with the params
@param url [String] the relative path in the Tictail
API @param params [Hash] the body of the request
# File lib/tictail/api/client.rb, line 67 def put(url, params) params = convert_hash_keys(params) @access_token = params.delete('access_token') if params['access_token'] return connection.put(url, params) end
Private Instance Methods
connection()
click to toggle source
# File lib/tictail/api/client.rb, line 84 def connection header = {:tictail_api_connector => 'Ruby-'+ Tictail::Api::VERSION, 'Content-Type' => 'application/json' } header.merge!({:Authorization => 'Bearer ' + access_token}) unless access_token.nil? @connection ||= Faraday.new(url: @url, headers: header, ssl: {verify: true}) do |conn| conn.use Tictail::ResponseParser # Setting response parser to oj conn.response :oj conn.adapter :typhoeus end end