Sha256: 93c7a0d4b3c0bc9e06d680ccd12adb8e95090ed812f2144a4378fb8ad0df7571

Contents?: true

Size: 774 Bytes

Versions: 1

Compression:

Stored size: 774 Bytes

Contents

require 'bc3client'

module Bc3client

  class Resource

    def initialize(*args)
      args = args.flatten(1) unless !args[0].is_a?(Array)
      @access_token = args[0]
      @user_agent = args[1]
      @account_id = args[2]
      @base_uri = "https://3.basecampapi.com"
    end

    def test
      puts "account id = #{@account_id}"
    end

    def build_uri(path)
      URI.parse(@base_uri + path)
    end

    private

      def get(uri)
        http = Net::HTTP.new(uri.host, uri.port)
        http.use_ssl = true
        request = Net::HTTP::Get.new(uri.request_uri)
        request['Authorization'] = "Bearer #{@access_token}"
        request['User-Agent'] = @user_agent
        response = http.request(request)
        JSON.parse(response.body)
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bc3client-0.1.0 lib/bc3client/resource.rb