aboutsummaryrefslogtreecommitdiff
path: root/src/guff/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/guff/api')
-rw-r--r--src/guff/api/methods.cr37
-rw-r--r--src/guff/api/test.cr9
2 files changed, 44 insertions, 2 deletions
diff --git a/src/guff/api/methods.cr b/src/guff/api/methods.cr
index 8df48d5..970e41f 100644
--- a/src/guff/api/methods.cr
+++ b/src/guff/api/methods.cr
@@ -366,6 +366,42 @@ module Guff
},
},
},
+
+ "add_user": {
+ text: "Add new user",
+
+ args: {
+ "name": {
+ text: "Name of user",
+ type: :text,
+ required: true,
+ },
+
+ "active": {
+ text: "Is this user active?",
+ type: :bool,
+ required: false,
+ },
+
+ "role": {
+ text: "Role of user",
+ type: :text,
+ required: false,
+ },
+
+ "email": {
+ text: "Email address of user",
+ type: :text,
+ required: false,
+ },
+
+ "password": {
+ text: "Password of user",
+ type: :text,
+ required: false,
+ },
+ },
+ },
}
}
@@ -375,6 +411,7 @@ module Guff
int: /^\d+$/,
int_list: /^\d+(?:,\d+)*$/,
state: /^(?:draft|posted|deleted)$/,
+ bool: /^t|f$/,
# FIXME: lock these down more
json: /.*/,
diff --git a/src/guff/api/test.cr b/src/guff/api/test.cr
index 3a53bd1..059f670 100644
--- a/src/guff/api/test.cr
+++ b/src/guff/api/test.cr
@@ -79,7 +79,12 @@ module Guff::API::TestAPI
context : HTTP::Server::Context,
args : Hash(String, String)
)
- user_id = @models.user.add_user(args["name"])
+ user_id = @models.user.add_user(args["name"].not_nil!,
+ active: args["active"]? ? args["active"] == "t" : nil,
+ role: args["role"]?,
+ email: args["name"]?,
+ password: args["password"]?,
+ )
{ "ok": true, "user_id": user_id }
end
@@ -87,7 +92,7 @@ module Guff::API::TestAPI
context : HTTP::Server::Context,
args : Hash(String, String)
)
- @models.user.update_user(args["user_id"].to_i,
+ @models.user.update_user(args["user_id"].to_i64,
name: args["name"]? ? args["name"] : nil,
active: args["active"]? ? args["active"] == "t" : nil,
role: args["role"]? ? args["role"] : nil