thisnthat 5 years ago
parent
commit
3a5a334b8e
4 changed files with 33 additions and 0 deletions
  1. 7 0
      client.go
  2. 6 0
      discourse.go
  3. 4 0
      groups.go
  4. 16 0
      users.go

+ 7 - 0
client.go

@@ -0,0 +1,7 @@
+package discourse
+
+type Config struct {
+	Endpoint string
+	ApiKey   string
+	ApiUser  string
+}

+ 6 - 0
discourse.go

@@ -2,6 +2,12 @@ package discourse
 
 import "github.com/google/uuid"
 
+type ApiConfig struct {
+	Endpoint string
+	ApiKey   string
+	ApiUser  string
+}
+
 type SsoConfig struct {
 	Endpoint       string
 	ReturnEndpoint string

+ 4 - 0
groups.go

@@ -0,0 +1,4 @@
+package discourse
+
+type Group struct {
+}

+ 16 - 0
users.go

@@ -0,0 +1,16 @@
+package discourse
+
+import "fmt"
+
+type User struct {
+	ID        string  `json:"id"`
+	Username  string  `json:"username"`
+	Moderator bool    `json:"moderator"`
+	Admin     bool    `json:"admin"`
+	Groups    []Group `json:"group"`
+}
+
+func GetUser(config ApiConfig, username string) {
+	url := fmt.Sprintf("%s/users/%s.json?api_key=%s&api_username=%s", config.Endpoint, username, config.ApiKey, config.ApiUser)
+	fmt.Println(url)
+}