Ruby wrapper for TaskRabbit API.
gem install taskrabbit
Or in a Gemfile:
gem 'taskrabbit'
In an initializer file.
Taskrabbit.configure do |config|
config.api_secret = 'your-client-secret'
config.api_key = 'your-client-key'
config.base_uri = 'https://sandbox.com'
config.endpoint = 'api/v2'
end
Available configuration options:
- api_secret: client secret that has been given to you by TaskRabbit
- api_key: client key that has been given by TaskRabbit
- base_uri: uri of the server (not mandatory, default to https://www.taskrabbit.com)
- endpoint: endpoint (not mandatory, default to api/v1)
tr = Taskrabbit::Api.new
or with a user token returned by TaskRabbit.
tr = Taskrabbit::Api.new(user_token)
tr = Taskrabbit::Api.new
# to get the /tasks
tasks = tr.tasks.all
# fetch the first task
tasks.first
tasks.all(:reload => true) # => will redo the query
tr = Taskrabbit::Api.new
t = tr.tasks.find(31231) # This actually wont do the request
To request the API:
t.fetch # force fetching
or simply access a property:
t.name # will do the query
tr.users.find(user_id).tasks
tr = Taskrabbit::Api.new(user_token)
task = tr.tasks.create({:named_price => 32, :name => 'Ikea'})
task.new_record? #=> false
or
task = tr.tasks.new({:named_price => 32, :name => 'Ikea'})
task.save
task = tr.tasks.find(32121)
task.named_price = 45
task.save
tr = Taskrabbit::Api.new(user_token)
task = tr.tasks.new
unless task.save
task.error # => "Task title can't be blank, \nAmount you are willing to pay is not a number"
task.errors # => { "messages" => ["Task title can't be blank", "Amount you are willing to pay is not a number"],
"fields" => [["name","can't be blank"], ["named_price","is not a number"]] }
end
In some case TaskRabbit will return an url which should be used for further operations (i.e: when the user doesn't have a credit card).
tr = Taskrabbit::Api.new(user_token)
task = tr.tasks.new
unless task.save
if task.redirect?
task.redirect_url #=> 'http://www.taskrabbit.com/somepath'
end
end
tr = Taskrabbit::Api.new(user_token)
tr.account # => Taskrabbit::User object
tr.account.tasks # => List of tasks
tr.account.tasks.create(some_params)
tr.cities.each do |city|
city.name
end
tr.cities.find(3).name # => "SF Bay Area"
More informations: http://taskrabbit.github.com
Add:
- Picture and sound upload
- Pages