From 094cbeedb81afde03d8f30f8928f98c13f1aa00a Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Fri, 1 Apr 2016 00:02:30 -0400 Subject: add user methods --- src/guff/api/test.cr | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/guff/api/test.cr') diff --git a/src/guff/api/test.cr b/src/guff/api/test.cr index 79d2d2e..71d614a 100644 --- a/src/guff/api/test.cr +++ b/src/guff/api/test.cr @@ -76,6 +76,47 @@ module Guff ) raise "some random error" end + + private def do_test_add_user( + context : HTTP::Server::Context, + args : Hash(String, String) + ) + user_id = @models.user.add_user(args["name"]) + { "ok": true, "user_id": user_id } + end + + private def do_test_update_user( + context : HTTP::Server::Context, + args : Hash(String, String) + ) + @models.user.update_user(args["user_id"].to_i, + name: args["name"]? ? args["name"] : nil, + active: args["active"]? ? args["active"] == "t" : nil, + role: args["role"]? ? args["role"] : nil + ) + + { "ok": true } + end + + private def do_test_add_login( + context : HTTP::Server::Context, + args : Hash(String, String) + ) + @models.user.add_login(args["user_id"].to_i, + email: args["name"], + password: args["password"], + ) + + { "ok": true } + end + + private def do_test_remove_login( + context : HTTP::Server::Context, + args : Hash(String, String) + ) + @models.user.remove_login(args["user_id"].to_i) + { "ok": true } + end end end end -- cgit v1.2.3