Sha256: 327d91829c4ecdec02e21f1a962c5c620820d1d4b27928ea43e856ee4f1b9b1e

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

# ## HTTP Client
# 
# Provides a client to access the Basecamp Next API using HTTP authentication
#
#
# Example:
#
#     client = Bcx::Client::HTTP.new(login: 'username', password: 'secret')
#
module Bcx
  module Client
    class HTTP < Rapidash::Client
      method :http

      extension :json
      encode_request_with :json

      raise_errors

      resource :projects, class_name: 'Bcx::Resources::Project'
      resource :todolists, class_name: 'Bcx::Resources::Todolist'
      resource :people, class_name: 'Bcx::Resources::Person'

      def initialize(options = {})
        @account = Bcx.configuration.account
        @api_version = Bcx.configuration.api_version
        @user_agent = options[:user_agent] || Bcx.configuration.user_agent
        if @user_agent
          options[:request_default_options] ||= {}
          options[:request_default_options][:header] ||= {}
          options[:request_default_options][:header][:user_agent] ||= @user_agent
        end

        self.class.site("https://basecamp.com/#{@account}/api/#{@api_version}/")

        super(options)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bcx-1.1.0 lib/bcx/client/http.rb