Skip to content

Instantly share code, notes, and snippets.

@petyosi
Created October 20, 2009 15:11
Show Gist options
  • Save petyosi/214313 to your computer and use it in GitHub Desktop.
Save petyosi/214313 to your computer and use it in GitHub Desktop.
get "/API/Internal/Users/:UserID/Signatures" do
content_type :json
Signature.all(:UserID => params[:UserID]).to_json
end
get "/API/Internal/Users/:UserID/Signatures/:ID" do
content_type :json
Signature.first(:UserID => params[:UserID], :ID => params[:ID]).to_json
end
get "/API/Internal/Users/:UserID/Signatures/:ID/Resend" do
# nothing
end
post "/API/Internal/Users/:UserID/Signatures" do
content_type :json
signature = Signature.new
signature.attributes = JSON.parse(request.body.read)
signature.UserID = params[:UserID]
if signature.save
status 200
signature.to_json
else
status 422
end
end
put "/API/Internal/Users/:UserID/Signatures/:ID" do
signature = Signature.first(:UserID => params[:UserID], :ID => params[:ID])
if signature.update(JSON.parse(request.body.read))
status 200
signature.to_json
else
status 422
end
end
delete "/API/Internal/Users/:UserID/Signatures/:ID" do
signature = Signature.first(:UserID => params[:UserID], :ID => params[:ID])
signature.destroy!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment