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.2"
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.
16 17 18 |
# File 'lib/pybossa-api.rb', line 16 def api_key @api_key end |
Class Method Details
.create(klass, opts = {}) ⇒ Hash
Creates an object.
51 52 53 |
# File 'lib/pybossa-api.rb', line 51 def create(klass, opts = {}) request :post, "/#{klass}", opts end |
.destroy(klass, id, opts = {}) ⇒ Object
Deletes an object.
77 78 79 |
# File 'lib/pybossa-api.rb', line 77 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+.
27 28 29 |
# File 'lib/pybossa-api.rb', line 27 def many(klass, opts = {}) request :get, "/#{klass}", opts end |
.retrieve(klass, id, opts = {}) ⇒ Hash
Gets an object by ID.
38 39 40 |
# File 'lib/pybossa-api.rb', line 38 def retrieve(klass, id, opts = {}) request :get, "/#{klass}/#{id}", opts end |
.update(klass, id, opts = {}) ⇒ Object
Updates an object.
64 65 66 |
# File 'lib/pybossa-api.rb', line 64 def update(klass, id, opts = {}) request :put, "/#{klass}/#{id}", opts end |