class Toggl::Connection
Public Class Methods
base_url()
click to toggle source
# File lib/toggl/reports/connection.rb, line 8 def base_url 'https://toggl.com/reports/api/v2' end
new(base_url=nil)
click to toggle source
# File lib/toggl/reports/connection.rb, line 13 def initialize(base_url=nil) @connection = Faraday.new(:url => base_url || self.class.base_url) do |faraday| faraday.request :url_encoded faraday.adapter Faraday.default_adapter faraday.response :logger, Logger.new('faraday.log') faraday.headers = {'Content-Type' => 'application/json'} faraday.basic_auth Toggl::Reports.api_token, 'api_token' # this needs to be after headers end end
Public Instance Methods
get(path, params)
click to toggle source
# File lib/toggl/reports/connection.rb, line 23 def get(path, params) response = @connection.get path, params JSON.parse(response.body) end