class Camper::Configuration
Defines constants and methods related to configuration.
Constants
- DEFAULT_USER_AGENT
The user agent that will be sent to the API endpoint if none is set.
- VALID_OPTIONS_KEYS
An array of valid keys in the options hash when configuring a Basecamp::API.
Public Class Methods
base_api_endpoint()
click to toggle source
# File lib/camper/configuration.rb, line 69 def self.base_api_endpoint "https://3.basecampapi.com" end
new(options = {})
click to toggle source
# File lib/camper/configuration.rb, line 25 def initialize(options = {}) default_from_environment VALID_OPTIONS_KEYS.each do |key| send("#{key}=", options[key]) if options[key] end end
Public Instance Methods
api_endpoint()
click to toggle source
# File lib/camper/configuration.rb, line 59 def api_endpoint raise Camper::Error::InvalidConfiguration, "missing basecamp account" unless self.account_number "#{self.base_api_endpoint}/#{self.account_number}" end
authz_endpoint()
click to toggle source
# File lib/camper/configuration.rb, line 51 def authz_endpoint 'https://launchpad.37signals.com/authorization/new' end
base_api_endpoint()
click to toggle source
# File lib/camper/configuration.rb, line 65 def base_api_endpoint self.class.base_api_endpoint end
default_from_environment()
click to toggle source
Resets all configuration options to the defaults.
# File lib/camper/configuration.rb, line 40 def default_from_environment logger.debug 'Setting attributes to default environment values' self.client_id = ENV['BASECAMP3_CLIENT_ID'] self.client_secret = ENV['BASECAMP3_CLIENT_SECRET'] self.redirect_uri = ENV['BASECAMP3_REDIRECT_URI'] self.account_number = ENV['BASECAMP3_ACCOUNT_NUMBER'] self.refresh_token = ENV['BASECAMP3_REFRESH_TOKEN'] self.access_token = ENV['BASECAMP3_ACCESS_TOKEN'] self.user_agent = ENV['BASECAMP3_USER_AGENT'] || DEFAULT_USER_AGENT end
options()
click to toggle source
Creates a hash of options and their values.
# File lib/camper/configuration.rb, line 33 def options VALID_OPTIONS_KEYS.inject({}) do |option, key| option.merge!(key => send(key)) end end
token_endpoint()
click to toggle source
# File lib/camper/configuration.rb, line 55 def token_endpoint 'https://launchpad.37signals.com/authorization/token' end