Module: PyBossa::App

Defined in:
lib/pybossa-api/app.rb

Class Method Summary collapse

Class Method Details

.create(opts = {}) ⇒ Hash

Creates an app.

Parameters:

  • opts (Hash) (defaults to: {})

    optional arguments

Options Hash (opts):

  • :name (String)

    a name

  • :short_name (String)

    a URL slug

  • :description (String)

    a short description

  • :long_description (String)

    a long HTML description

  • :long_tasks (Integer)

    [not in use]

  • :hidden (Boolean)

    whether to hide the app from the public

  • :time_estimate (Integer)

    estimated time to complete [not in use]

  • :time_limit (Integer)

    time limit to complete task [not in use]

  • :calibration_frac (Float)

    [not in use]

  • :bolt_course_id (Integer)

    [not in use]

  • :info (Hash)

    all other task details

  • :api_key (String)

    an API key

Returns:

  • (Hash)

    an app

See Also:



38
39
40
41
42
43
# File 'lib/pybossa-api/app.rb', line 38

def create(opts = {})
  if opts.has_key? :hidden
    opts[:hidden] = opts[:hidden] ? 1 : 0
  end
  PyBossa::API.create 'app', opts
end

.delete(id, opts = {}) ⇒ Object

Deletes an app.

Parameters:

  • id (Integer)

    an app ID

  • opts (Hash) (defaults to: {})

    optional arguments

Options Hash (opts):

  • :api_key (String)

    an API key



62
63
64
# File 'lib/pybossa-api/app.rb', line 62

def delete(id, opts = {})
  PyBossa::API.destroy 'app', id, opts
end

.get(id, opts = {}) ⇒ Hash

Returns an app.

Parameters:

  • id (Integer)

    an app ID

  • opts (Hash) (defaults to: {})

    optional arguments

Options Hash (opts):

  • :api_key (String)

    an API key

Returns:

  • (Hash)

    an app



16
17
18
# File 'lib/pybossa-api/app.rb', line 16

def get(id, opts = {})
  PyBossa::API.retrieve 'app', id, opts
end

.list(opts = {}) ⇒ Array

Returns a list of apps.

Parameters:

  • opts (Hash) (defaults to: {})

    optional arguments

Options Hash (opts):

  • :limit (Integer)

    number of results to return [default 20]

  • :api_key (String)

    an API key

Returns:

  • (Array)

    a list of apps



8
9
10
# File 'lib/pybossa-api/app.rb', line 8

def list(opts = {})
  PyBossa::API.many 'app', opts
end

.update(id, opts = {}) ⇒ Object

Updates an app.

Parameters:

  • id (Integer)

    an app ID

See Also:

  • #create


50
51
52
53
54
55
# File 'lib/pybossa-api/app.rb', line 50

def update(id, opts = {})
  if opts.has_key? :calibration
    opts[:calibration] = opts[:calibration] ? 1 : 0
  end
  PyBossa::API.update 'app', id, opts
end