Class: PyBossa::API
- Inherits:
-
Object
- Object
- PyBossa::API
- Includes:
- HTTParty
- Defined in:
- lib/pybossa-api.rb,
lib/pybossa-api/version.rb
Overview
A Ruby wrapper for the PyBossa API.
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.0.1"
Class Attribute Summary collapse
-
.api_key ⇒ Object
Returns the value of attribute api_key.
Class Method Summary collapse
-
.create(klass, opts = {}) ⇒ Hash
Creates an object.
-
.destroy(klass, id, opts = {}) ⇒ Object
Deletes an object.
-
.many(klass, opts = {}) ⇒ Array
Lists objects.
-
.retrieve(klass, id, opts = {}) ⇒ Hash
Gets an object by ID.
-
.update(klass, id, opts = {}) ⇒ Object
Updates an object.
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
21 22 23 |
# File 'lib/pybossa-api.rb', line 21 def api_key @api_key end |
Class Method Details
.create(klass, opts = {}) ⇒ Hash
Creates an object.
56 57 58 |
# File 'lib/pybossa-api.rb', line 56 def create(klass, opts = {}) request :post, "/#{klass}", opts end |
.destroy(klass, id, opts = {}) ⇒ Object
Deletes an object.
82 83 84 |
# File 'lib/pybossa-api.rb', line 82 def destroy(klass, id, opts = {}) request :delete, "/#{klass}/#{id}", opts end |
.many(klass, opts = {}) ⇒ Array
Lists objects. To filter objects, add key-value pairs to the :opts argument in which each key is the name of a field on which you want to filter. For example, you may want to filter tasks by app_id.
32 33 34 |
# File 'lib/pybossa-api.rb', line 32 def many(klass, opts = {}) request :get, "/#{klass}", opts end |
.retrieve(klass, id, opts = {}) ⇒ Hash
Gets an object by ID.
43 44 45 |
# File 'lib/pybossa-api.rb', line 43 def retrieve(klass, id, opts = {}) request :get, "/#{klass}/#{id}", opts end |
.update(klass, id, opts = {}) ⇒ Object
Updates an object.
69 70 71 |
# File 'lib/pybossa-api.rb', line 69 def update(klass, id, opts = {}) request :put, "/#{klass}/#{id}", opts end |