aboutsummaryrefslogtreecommitdiff
path: root/src/guff/api
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-04-01 15:58:08 -0400
committerPaul Duncan <pabs@pablotron.org>2016-04-01 15:58:08 -0400
commit6b9ca27c67d043a8737da652bf7915645628db4c (patch)
tree928ead16b4d04a695de6642c9dc818edab74b0d3 /src/guff/api
parent974d7c1d8ae71d50566dc8c2857520dde139a191 (diff)
downloadold-guff-6b9ca27c67d043a8737da652bf7915645628db4c.tar.bz2
old-guff-6b9ca27c67d043a8737da652bf7915645628db4c.zip
add_user test
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