mirror of
https://github.com/unpoller/unpoller.git
synced 2026-10-22 05:09:10 +02:00
Wrap clients in a struct too.
This commit is contained in:
@@ -34,6 +34,11 @@ type Devices struct {
|
||||
USWs []USW
|
||||
}
|
||||
|
||||
// Clients conptains a list of all the unifi clients from a controller.
|
||||
type Clients struct {
|
||||
UCLs []UCL
|
||||
}
|
||||
|
||||
// Unifi is what you get in return for providing a password!
|
||||
type Unifi struct {
|
||||
*http.Client
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
// GetClients returns a response full of clients' data from the Unifi Controller.
|
||||
func (u *Unifi) GetClients() ([]UCL, error) {
|
||||
func (u *Unifi) GetClients() (*Clients, error) {
|
||||
var response struct {
|
||||
Clients []UCL `json:"data"`
|
||||
}
|
||||
@@ -28,7 +28,7 @@ func (u *Unifi) GetClients() ([]UCL, error) {
|
||||
} else if err = json.Unmarshal(body, &response); err != nil {
|
||||
return nil, errors.Wrap(err, "json.Unmarshal([]UCL)")
|
||||
}
|
||||
return response.Clients, nil
|
||||
return &Clients{UCLs: response.Clients}, nil
|
||||
}
|
||||
|
||||
// GetDevices returns a response full of devices' data from the Unifi Controller.
|
||||
|
||||
Reference in New Issue
Block a user