Skip to content

Commit

Permalink
add archived user endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
gosticks committed Oct 22, 2019
1 parent 340391f commit d7c0fad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ Get customer by name

### Users

Get all users
Get all users. When `archived` is true, the archived users will be returned.

```
users, errUsers := miteAPI.GetUsers()
users, errUsers := miteAPI.GetUsers(archived)
```

Get a user by ID
Expand Down
8 changes: 6 additions & 2 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ type getUsersResponseWrapper struct {
// -------------------------------------------------------------

// GetUsers returns all users in a mite workspace
func (m *Mite) GetUsers() ([]*User, error) {
func (m *Mite) GetUsers(archived bool) ([]*User, error) {
var usersResponse []*getUsersResponseWrapper
err := m.getAndDecodeFromSuffix("users.json", &usersResponse, nil)
var resource = "users.json"
if archived {
resource = "/users/archived.json"
}
err := m.getAndDecodeFromSuffix(resource, &usersResponse, nil)
if err != nil {
return nil, err
}
Expand Down
9 changes: 7 additions & 2 deletions user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@ func TestGetUsers(t *testing.T) {

mite := mite.NewMiteAPI(username, team, key, "test@go-mite")

_, errUser := mite.GetUsers()
_, errUser := mite.GetUsers(false)
if errUser != nil {
t.Error(username, team, key, errUser)
}

_, errArchivedUser := mite.GetUsers(true)
if errArchivedUser != nil {
t.Error(username, team, key, errUser)
}
}
func TestGetUser(t *testing.T) {
username, okUser := os.LookupEnv("MITE_USER")
Expand All @@ -34,7 +39,7 @@ func TestGetUser(t *testing.T) {

mite := mite.NewMiteAPI(username, team, key, "test@go-mite")

users, errUser := mite.GetUsers()
users, errUser := mite.GetUsers(false)
if errUser != nil {
t.Error(username, team, key, errUser)
}
Expand Down

0 comments on commit d7c0fad

Please sign in to comment.