summaryrefslogtreecommitdiff
path: root/grocy
diff options
context:
space:
mode:
authorCara Salter <cara@devcara.com>2023-09-03 12:30:50 -0400
committerCara Salter <cara@devcara.com>2023-09-03 12:30:50 -0400
commit87678ecf435874e7771b0e47911ffb2aa2c4d33e (patch)
tree83ac91d6633f80f738d9d6a3cfccab55b2d5e8f9 /grocy
parent1a69cd2e8b919ab450b42802ae578c2d23948a07 (diff)
downloadgrocy-reminders-master.tar.gz
grocy-reminders-master.zip
chore remindersHEADmaster
Sends a discord webhook with reminders as to who has what chore!
Diffstat (limited to 'grocy')
-rw-r--r--grocy/user.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/grocy/user.go b/grocy/user.go
index 58d3d08..493c4d5 100644
--- a/grocy/user.go
+++ b/grocy/user.go
@@ -2,6 +2,7 @@ package grocy
import (
"context"
+ "errors"
"fmt"
"net/http"
)
@@ -35,6 +36,23 @@ func (c *Client) GetUsers(ctx context.Context) ([]User, error) {
return res, nil
}
+func (c *Client) GetUser(ctx context.Context, userId int) (User, error) {
+ // This is kinda hacky because grocy doesn't support getting LDAP users by
+ // grocy ID :(
+ res, err := c.GetUsers(ctx)
+ if err != nil {
+ return *new(User), err
+ }
+
+ for _, u := range res {
+ if u.Id == userId {
+ return u, nil
+ }
+ }
+
+ return *new(User), errors.New("User Not Found")
+}
+
func (c *Client) GetUserFields(ctx context.Context, userId int) (map[string]string, error) {
req, err := http.NewRequest("GET", fmt.Sprintf("%s/userfields/users/%d", c.BaseUrl, userId), nil)