From 9eabee18ff1268b1c73c0d8b3d0130b1a739f723 Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Sat, 7 Jul 2018 16:31:45 -0600 Subject: [PATCH] -Fix ConnectWise parameters map -Added error checkign in GetCompanyByName if no companies returned by CW --- 3.0/connectwise/company.go | 3 +++ 3.0/connectwise/requests.go | 2 ++ 2 files changed, 5 insertions(+) diff --git a/3.0/connectwise/company.go b/3.0/connectwise/company.go index d708c10..f87d802 100644 --- a/3.0/connectwise/company.go +++ b/3.0/connectwise/company.go @@ -160,6 +160,9 @@ func (cw *Site) GetCompanyByName(companyName string) (*[]Company, error) { if err != nil { return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err) } + if len(*co) == 0 { + return nil, fmt.Errorf("ConnectWise returned no results for %s", companyName) + } return co, nil } diff --git a/3.0/connectwise/requests.go b/3.0/connectwise/requests.go index b1d14cc..e3cb840 100644 --- a/3.0/connectwise/requests.go +++ b/3.0/connectwise/requests.go @@ -21,6 +21,8 @@ type Request struct { //NewRequest is a function which takes the mandatory fields to perform a request to the CW API and returns a pointer to a Request struct func NewRequest(cw *Site, restAction, method string, body []byte) *Request { req := Request{CW: cw, RestAction: restAction, Method: method, Body: body} + req.Parameters = make(map[string]string) + return &req }