Class: HelpScout::API::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(authorize: true) ⇒ Client

Returns a new instance of Client.



8
9
10
# File 'lib/help_scout/api/client.rb', line 8

def initialize(authorize: true)
  @authorize = authorize
end

Instance Attribute Details

#authorizeObject (readonly)

Returns the value of attribute authorize.



6
7
8
# File 'lib/help_scout/api/client.rb', line 6

def authorize
  @authorize
end

Instance Method Details

#connectionObject



12
13
14
15
16
17
18
19
# File 'lib/help_scout/api/client.rb', line 12

def connection
  @_connection ||= build_connection.tap do |conn|
    if authorize?
      HelpScout::API::AccessToken.refresh!
      conn.request(:authorization, 'Bearer', access_token) if access_token
    end
  end
end