Split the client up into resource-specific files

This commit is contained in:
Ian Gulliver
2021-09-23 04:30:50 +00:00
parent 31985ee5c6
commit e85fbd5df9
10 changed files with 459 additions and 432 deletions

26
client/user.go Normal file
View File

@@ -0,0 +1,26 @@
package client
import "fmt"
type User struct {
GID string `json:"gid"`
Name string `json:"name"`
Email string `json:"email"`
}
type userResponse struct {
Data *User `json:"data"`
}
func (wc *WorkspaceClient) GetMe() (*User, error) {
resp := &userResponse{}
err := wc.client.get("users/me", nil, resp)
if err != nil {
return nil, err
}
return resp.Data, nil
}
func (u *User) String() string {
return fmt.Sprintf("%s (%s <%s>)", u.GID, u.Name, u.Email)
}