Class: Harvest::Client
- Inherits:
-
Object
- Object
- Harvest::Client
- Includes:
- TimeEntries, Users
- Defined in:
- lib/harvest/client.rb,
lib/harvest/client/users.rb,
lib/harvest/client/base_api.rb,
lib/harvest/client/helpers/all.rb,
lib/harvest/client/helpers/find.rb,
lib/harvest/client/time_entries.rb,
lib/harvest/client/helpers/create.rb,
lib/harvest/client/helpers/delete.rb,
lib/harvest/client/helpers/update.rb
Defined Under Namespace
Modules: Helpers, TimeEntries, Users Classes: BaseApi
Constant Summary collapse
- BASE_URL =
'https://api.harvestapp.com/v2'.freeze
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
-
#initialize(access_token: nil, account_id: nil, user_agent: nil) ⇒ Client
constructor
A new instance of Client.
Methods included from Users
Methods included from TimeEntries
Constructor Details
#initialize(access_token: nil, account_id: nil, user_agent: nil) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/harvest/client.rb', line 13 def initialize access_token: nil, account_id: nil, user_agent: nil @connection = Faraday.new(url: BASE_URL) do |conn| conn.request :json conn.request :oauth2, access_token, token_type: :bearer conn.headers = { 'Harvest-Account-Id' => account_id, 'User-Agent' => user_agent } conn.response :json, :content_type => /\bjson$/ conn.adapter Faraday.default_adapter end end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
11 12 13 |
# File 'lib/harvest/client.rb', line 11 def connection @connection end |