Class: TogglBillable::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/toggl_billable/client.rb

Class Method Summary collapse

Class Method Details

.api_baseObject



11
12
13
# File 'lib/toggl_billable/client.rb', line 11

def self.api_base
  'https://www.toggl.com/api/v8'
end

.api_get(end_point) ⇒ Object



23
24
25
# File 'lib/toggl_billable/client.rb', line 23

def self.api_get(end_point)
  connection.get("#{api_base}/#{end_point}")
end

.connectionObject



19
20
21
# File 'lib/toggl_billable/client.rb', line 19

def self.connection
  @connection
end

.report_get(end_point) ⇒ Object



27
28
29
# File 'lib/toggl_billable/client.rb', line 27

def self.report_get(end_point)
  connection.get("#{reports_base}/#{end_point}")
end

.reports_baseObject



15
16
17
# File 'lib/toggl_billable/client.rb', line 15

def self.reports_base
  'https://toggl.com/reports/api/v2'
end

.start(api_token) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/toggl_billable/client.rb', line 3

def self.start(api_token)
  @connection = Faraday.new(url: 'https://www.toggle.com') do |faraday|
    faraday.use Faraday::Request::BasicAuthentication, api_token, 'api_token'
    faraday.request :url_encoded
    faraday.adapter Faraday.default_adapter
  end
end