Class: Cubscout::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/cubscout/config.rb

Overview

The Config class allows for API client configuration. Basic setup:

require 'cubscout'
Cubscout::Config.client_id = 'YOUR_APP_ID'
Cubscout::Config.client_secret = 'YOUR_APP_SECRET'

Constant Summary collapse

DEFAULT_API_PREFIX =
'https://api.helpscout.net/v2'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_prefixString

Returns Base url of Helpscout’s API V2.

Returns:

  • (String)

    Base url of Helpscout’s API V2.



17
18
19
# File 'lib/cubscout/config.rb', line 17

def api_prefix
  @api_prefix ||= DEFAULT_API_PREFIX
end

.client_id=(value) ⇒ Object (writeonly)

Sets the attribute client_id

Parameters:

  • value

    the value to set the attribute client_id to.



14
15
16
# File 'lib/cubscout/config.rb', line 14

def client_id=(value)
  @client_id = value
end

.client_secret=(value) ⇒ Object (writeonly)

Sets the attribute client_secret

Parameters:

  • value

    the value to set the attribute client_secret to.



14
15
16
# File 'lib/cubscout/config.rb', line 14

def client_secret=(value)
  @client_secret = value
end

Class Method Details

.oauth_tokenString

Returns OAuth token used in every request header: Authorization: Bearer #{Cubscout::Config.oauth_token}.

Returns:

  • (String)

    OAuth token used in every request header: Authorization: Bearer #{Cubscout::Config.oauth_token}



31
32
33
# File 'lib/cubscout/config.rb', line 31

def oauth_token
  access_token.token
end

.reset!Object

Resets client_id, client_secret, and oauth_client to null values, api_prefix to DEFAULT_API_PREFIX



23
24
25
26
27
# File 'lib/cubscout/config.rb', line 23

def reset!
  @client_id = @client_secret = nil
  @access_token = @oauth_client = nil
  @api_prefix = DEFAULT_API_PREFIX
end