mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-08 18:28:50 +01:00
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:
parent
6dc32aa83b
commit
07aade6882
2 changed files with 25 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue