Add two new API methods: ListContexts and ListProjects. See http://0.0.0.0:3000/backend/invoke to experiment.

git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@234 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
lukemelia 2006-05-04 05:38:47 +00:00
parent 6dc32aa83b
commit 07aade6882
2 changed files with 25 additions and 0 deletions

View file

@ -2,4 +2,13 @@ class TodoApi < ActionWebService::API::Base
api_method :new_todo,
:expects => [{:username => :string}, {:token => :string}, {:context_id => :int}, {:description => :string}],
:returns => [:int]
api_method :list_contexts,
:expects => [{:username => :string}, {:token => :string}],
:returns => [[Context]]
api_method :list_projects,
:expects => [{:username => :string}, {:token => :string}],
:returns => [[Project]]
end

View file

@ -16,6 +16,22 @@ class BackendController < ApplicationController
item.id
end
def list_contexts(username, token)
if !check_token_against_user_word(username, token)
raise "invalid token"
end
@user.contexts
end
def list_projects(username, token)
if !check_token_against_user_word(username, token)
raise "invalid token"
end
@user.projects
end
protected
# Check whether the token in the URL matches the word in the User's table