This gem is a simple Ruby wrapper for the Asana REST API. It's based on Ryan Bright's asana gem but it handles a few things differently and it supports more API calls, such as tag handling.
It uses ActiveResource to provide a simple, familiar interface for accessing your Asana account.
To learn more, check out the Asana API Documentation.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install asana-ruby
In order to access Asana, you need to provide your API key.
. do |client| client.api_key = 'your_asana_api_key' end
As a sanity check, you can fetch the object representing your user.
A user object represents an account in Asana that can be given access to various workspaces, projects, and tasks.
Like other objects in the system, users are referred to by numerical IDs. However, the special string identifier me can be used anywhere a user ID is accepted, to refer to the current authenticated user.
Note: It is not possible to create, update, or delete a user from the API.
# Get users from all of your workspaces users = ::.all # Get a specific user user = ::.find(:user_id) # Get the user associated with the API key being used user = ::. # Get all users in a given workspace workspace = ::.find(:workspace_id) users = workspace.users
A workspace is the most basic organizational unit in Asana. All projects and tasks have an associated workspace.
Note: It is not possible to create or delete a workspace from the API.
# Get all workspaces workspaces = ::.all # Get a specific workspace workspace = ::.find(:workspace_id) # Get all projects in a given workspace projects = workspace.projects # Get all tasks in a given workspace that are assigned to the given user tasks = workspace.tasks(:user_id) # Get all users with access to a given workspace users = workspace.users # Create a new task in a given workspace and assign it to the current user workspace.create_task(:name => 'Get milk from the grocery store')
A project represents a prioritized list of tasks in Asana. It exists in a single workspace and is accessible to a subset of users in that workspace depending on its permissions.
Note: It is not possible to create or delete a project from the API.
# Get all projects projects = ::.all # Get a specific project project = ::.find(:project_id) # Get all projects in a given workspace workspace = ::.find(:workspace_id) projects = workspace.projects
The task is the basic object around which many operations in Asana are centered. In the Asana application, multiple tasks populate the middle pane according to some view parameters, and the set of selected tasks determine the more detailed information presented in the details pane.
# Get all tasks in a given project project = ::.find(:project_id) tasks = project.tasks # Get all tasks in a given workspace workspace = ::.find(:workspace_id) tasks = workspace.tasks # Get all stories for a given task task = tasks.first stories = task.stories # Create a new task in a given workspace and assign it to the current user workspace.create_task(:name => 'Get milk from the grocery store') # Create a new story for the given task task.create_story(story_settings)
A story represents an activity associated with an object in the Asana system. Stories are generated by the system whenever users take actions such as creating or assigning tasks, or moving tasks between projects. Comments are also a form of user-generated story.
Note: It is not possible to update or delete a story from the API.
# Get all stories for a given task project = ::.find(:project_id) task = project.tasks.first stories = task.stories # Get a specific story story = Story.find(:story_id) # Create a new story for the given task task.create_story(story_settings)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request