Skip to content

renehernandez/camper

Repository files navigation

camper CI Gem Version

Camper is a Ruby wrapper for the Basecamp 3 API.

You can check out the gem documentation at https://www.rubydoc.org/gems/camper

Installation

Add this line to your application's Gemfile:

gem 'camper'

And then execute:

$ bundle

Or install it yourself as:

$ gem install camper

Status of API endpoints

The up-to-date list of Basecamp API endpoints can be found at here.

Currently, Camper supports the following endpoints:

Usage

Configuration

Getting a client and configuring it:

require 'camper'

client = Camper.client

client.configure do |config|
  config.client_id = 'client_id'
  config.client_secret = 'client_secret'
  config.account_number = 'account_number'
  config.refresh_token = 'refresh_token'
  config.access_token = 'access_token'
end

Alternatively, it is possible to invoke the top-level #configure method to get a client:

require 'camper'

client = Camper.configure do |config|
  config.client_id = 'client_id'
  config.client_secret = 'client_secret'
  config.account_number = 'account_number'
  config.refresh_token = 'refresh_token'
  config.access_token = 'access_token'
end

Also, the client can read directly the following environment variables:

  • BASECAMP_CLIENT_ID
  • BASECAMP_CLIENT_SECRET
  • BASECAMP_ACCOUNT_NUMBER
  • BASECAMP_REFRESH_TOKEN
  • BASECAMP_ACCESS_TOKEN

then the code would look like:

require 'camper'

client = Camper.client

Examples

Example getting list of TODOs:

require 'camper'

client = Camper.configure do |config|
  config.client_id = ENV['BASECAMP_CLIENT_ID']
  config.client_secret = ENV['BASECAMP_CLIENT_SECRET']
  config.account_number = ENV['BASECAMP_ACCOUNT_NUMBER']
  config.refresh_token = ENV['BASECAMP_REFRESH_TOKEN']
  config.access_token = ENV['BASECAMP_ACCESS_TOKEN']
end

# gets a paginated response
projects = client.projects

# iterate all projects
projects.auto_paginate do |p|
  puts "Project: #{p.inspect}"

  puts "Todo set: #{p.todoset.inspect}"

  todoset = client.todoset(p)

  # iterate over the first 5 todo lists
  client.todolists(todoset).auto_paginate(5) do |list|
    puts "Todolist: #{list.title}"

    client.todos(list).auto_paginate do |todo|
      puts todo.inspect
    end
  end
end

For more examples, check out the examples folder

Contributing

Check out the Contributing page.

Changelog

For inspecting the changes and tag releases, check the Changelog page

Appreciation

The gem code structure and documentation is based on the awesome NARKOZ/gitlab gem

License

Checkout the LICENSE for details