Module: ActiveProject::Adapters::Basecamp::Connection
- Includes:
- Connections::Rest
- Included in:
- ActiveProject::Adapters::BasecampAdapter
- Defined in:
- lib/active_project/adapters/basecamp/connection.rb
Constant Summary collapse
- BASE_URL_TEMPLATE =
"https://3.basecampapi.com/%<account_id>s/"
Constants included from Connections::HttpClient
Connections::HttpClient::DEFAULT_HEADERS, Connections::HttpClient::DEFAULT_RETRY_OPTS
Instance Attribute Summary
Attributes included from Connections::HttpClient
Instance Method Summary collapse
-
#initialize(config:) ⇒ Object
Initializes the Basecamp Adapter.
Methods included from Connections::Rest
Methods included from Connections::Pagination
Methods included from Connections::HttpClient
Methods included from Connections::Base
Instance Method Details
#initialize(config:) ⇒ Object
Initializes the Basecamp Adapter.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/active_project/adapters/basecamp/connection.rb', line 12 def initialize(config:) # For now, Basecamp uses the base config. If specific Basecamp options are added, # create BasecampConfiguration and check for that type. unless config.is_a?(ActiveProject::Configurations::BaseAdapterConfiguration) raise ArgumentError, "BasecampAdapter requires a BaseAdapterConfiguration object" end super(config: config) account_id = @config..fetch(:account_id) access_token = @config..fetch(:access_token) init_rest( base_url: format(BASE_URL_TEMPLATE, account_id: account_id), auth_middleware: ->(conn) { conn.request :authorization, :bearer, access_token } ) return if account_id && !account_id.empty? && access_token && !access_token.empty? raise ArgumentError, "BasecampAdapter configuration requires :account_id and :access_token" end |