From c5397292320f06b2f759a7db82736088de28f79a Mon Sep 17 00:00:00 2001 From: steven Date: Thu, 21 Mar 2019 16:11:18 -0600 Subject: [PATCH] Add GetSystemMemberByID --- 3.0/connectwise/system.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/3.0/connectwise/system.go b/3.0/connectwise/system.go index 079ff08..b7d025f 100644 --- a/3.0/connectwise/system.go +++ b/3.0/connectwise/system.go @@ -289,6 +289,22 @@ func (cw *Site) GetSystemMembers() (*[]Member, error) { return members, nil } +func (cw *Site) GetSystemMemberByID(memberID int) (*Member, error) { + req := cw.NewRequest(fmt.Sprintf("/system/members/%d", memberID), "GET", nil) + err := req.Do() + if err != nil { + return nil, fmt.Errorf("request failed for %s: %s", req.RestAction, err) + } + + member := &Member{} + err = json.Unmarshal(req.Body, member) + if err != nil { + return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err) + } + + return member, nil +} + func (cw *Site) GetSystemMemberByIdentifier(identifier string) (*Member, error) { req := cw.NewRequest(fmt.Sprintf("/system/members/%s", identifier), "GET", nil) err := req.Do()