Sha256: 5ccf28663434de176c07fb11e8c47cf4980d602f6d61df54df30be51309e1173

Contents?: true

Size: 972 Bytes

Versions: 3

Compression:

Stored size: 972 Bytes

Contents

# ## Oauth Client
# 
# Provides a client to access the Basecamp Next API via OAuth credentials
#
# Example:
#
#     client = Bcx::Client::OAuth.new(client_id: '1234567890', client_secret: '831994c4170', access_token: 'b02ff9345c3')
#
module Bcx
  module Client
    class OAuth < Rapidash::Client
      method :oauth

      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 = options[:account] || Bcx.configuration.account
        @api_version = Bcx.configuration.api_version

        options[:site] = "https://basecamp.com/#{@account}/api/#{@api_version}"
        options[:uid] ||= options[:client_id]
        options[:secret] ||= options[:client_secret]

        super(options)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bcx-1.0.0 lib/bcx/client/oauth.rb
bcx-0.4.0 lib/bcx/client/oauth.rb
bcx-0.3.0 lib/bcx/client/oauth.rb