From c5c1907be7e88a230e09b3ede68bc58f33711e52 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sat, 26 Jan 2019 12:51:08 -0800 Subject: [PATCH] Wrap clients in a struct too. --- core/unifi/unidev.go | 5 +++++ core/unifi/unifi.go | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/unifi/unidev.go b/core/unifi/unidev.go index 7f2d7f54..0738e0fa 100644 --- a/core/unifi/unidev.go +++ b/core/unifi/unidev.go @@ -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 diff --git a/core/unifi/unifi.go b/core/unifi/unifi.go index 5c2645af..2c62af33 100644 --- a/core/unifi/unifi.go +++ b/core/unifi/unifi.go @@ -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.