module Bcx
## Bcx
Fully-fledged Ruby API wrapper for Basecamp Next
See the [README](github.com/paulspringett/bcx#readme) for usage
## HTTP Client
Provides a client to access the Basecamp Next API using HTTP authentication Example: client = Bcx::Client::HTTP.new(login: 'username', password: 'secret')
## 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')
Provides a configuration block for setting up the Bcx
client
Example:
Bcx.configure do |config| config.account = '1234567890' end
Provides access to accesses resource at per-project level
#### Get accesses for a project `GET /projects/1/accesses.json`
client.projects(1).accesses!
#### Grant access `POST /projects/1/accesses.json`
client.projects(1).accesses.create!(ids: [ 5, 6, 10])
#### Revoke access `DELETE /projects/1/accesses/1.json`
client.projects(1).accesses(1).delete!
## Comments
Provides access to comments resource on todo or todolist level
#### Create a new todolist comment `POST /projects/123/todolist/456/comments.json`
client.projects(123).todolists(456).comments.create!(content: 'New comment')
#### Create a new todo comment `POST /projects/123/todo/456/comments.json`
client.projects(123).todos(456).comments.create!(content: 'New comment')
#### Delete the comment `DELETE /projects/123/comments/456.json`
client.projects(123).comments(456).delete!
## People
Provides access to people resource
#### Get all people on the account `GET /people.json`
client.people!
#### Get a person `GET /people/123.json`
client.people!(123)
#### Get the current person `GET /people/me.json`
client.people.me!
#### Get assigned todos for a person `GET /people/1/assigned_todos.json`
client.people(1).assigned_todos
#### Delete a person `DELETE /people/123.json`
client.people(123).delete!
## Projects
Provides access to projects resoource and other nested resources
#### Fetch all projects `GET /projects.json`
client.projects!
#### Fetch archived projects `GET /projects/archived.json`
clients.projects.archived!
#### Fetch single project with ID of 123 `GET /projects/123.json`
client.projects!(123)
#### Create a project `POST /projects.json`
client.projects.create!(name: 'Acme project', description: 'This is a new project')
#### Update an existing project `PUT /projects/123.json`
client.projects(123).update!(description: 'A new description')
#### Delete a project `DELETE /projects/123.json`
client.projects(123).delete!
## Todo
Provides access to todolist resoource both at the client level and per-project
#### Get todos for a todolist `GET /todolists/1.json`
todolist = client.todolists!(1) todolist.todos.remaining todolist.todos.completed
#### Get a specific todo `GET /projects/1/todos/2.json`
client.projects(1).todos!(2)
#### Create a todo `POST /projects/1/todolists/2/todos.json`
client.projects(1).todolists(2).todos.create!(content: 'Update copy text')
#### Update a todo `PUT /projects/1/todos/2.json`
client.projects(1).todos(2).update!(completed: true)
#### Delete a todo `DELETE /projects/1/todos/2.json`
client.projects(1).todos(2).delete!
## Todolists
Provides access to todolist resoource both at the client level and per-project
#### Get all todolists for a project `GET /projects/123/todolists.json`
client.projects(123).todolists!
#### Get all completed todolists for a project `GET /projects/1/todolists/completed.json`
client.projects(123).todolists.completed!
#### Get todolists for all projects `GET /todolists.json`
client.todolists!
#### Get completed todolists for all projects `GET /todolists/completed.json`
client.todolists.completed!
#### Get specific todolist including the todos `GET /projects/123/todolists/456.json`
client.projects(123).todolists!(456)
#### Create a new todolist `POST /projects/1/todolists.json`
client.projects(123).todolists.create!(name: 'My todolist', description: 'This is a todolist')
#### Update an existing todolist `PUT /projects/123/todolists/456.json`
client.projects(123).todolists(456).update!(name: 'Updated todolist')
#### Delete a todolist `DELETE /projects/123/todolists/456.json`
client.projects(123).todolists(456).delete!
## Response Error
If the response whilst fetching a resource is a 4xx or 5xx, Bcx
will raise a `Bcx::ResponseError` exception.
Examples:
client.projects.create!(name: '') => Bcx::ResponseError: 422 POST https://basecamp.com/2274488/api/v1/projects.json | Errors: name can't be blank
You can rescue this exception to grab the status, method, URL and errors individually.
begin client.projects.create!(name: '') rescue Bcx::ResponseError => response response.method # => "POST" response.status # => 422 response.url # => "https://basecamp.com/2274488/api/v1/projects.json" response.errors # => ["name can't be blank"] end
Constants
- VERSION
Attributes
Public Class Methods
Create configuration block in case the user does not call configure
# File lib/bcx.rb, line 36 def self.configuration self.class.instance_variable_set('@configuration',Configuration.new) if self.class.instance_variable_get('@configuration').nil? self.class.instance_variable_get('@configuration') end
Expose configuration block
# File lib/bcx.rb, line 42 def self.configure yield(configuration) end