From 3c8e0a424f2d5279761f48e3d91fcf37fe2bdb3c Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Wed, 20 Jun 2018 13:24:47 -0600 Subject: [PATCH] Moved getHTTPResponseBody to requests.go what am i doing lol --- 3.0/connectwise/companies.go | 16 ---------------- 3.0/connectwise/requests.go | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 3.0/connectwise/requests.go diff --git a/3.0/connectwise/companies.go b/3.0/connectwise/companies.go index 3178ffa..4aaf302 100644 --- a/3.0/connectwise/companies.go +++ b/3.0/connectwise/companies.go @@ -3,8 +3,6 @@ package connectwise import ( "encoding/json" "fmt" - "io/ioutil" - "log" "net/http" "net/url" "time" @@ -151,20 +149,6 @@ type Company struct { } `json:"customFields"` } -//Checks for HTTP errors, and if all looks good, returns the body of the HTTP response as a byte slice -func getHTTPResponseBody(resp *http.Response) (body []byte) { - if resp.StatusCode != http.StatusOK { - out := fmt.Sprintf("CW API returned HTTP Status Code %s\n%s", resp.Status, resp.Body) - log.Fatal(out) - return make([]byte, 0) - } else { - body, err := ioutil.ReadAll(resp.Body) - check(err) - - return body - } -} - func GetCompaniesByName(site *ConnectwiseSite, companyName string) *Companies { companies := Companies{} diff --git a/3.0/connectwise/requests.go b/3.0/connectwise/requests.go new file mode 100644 index 0000000..882dc17 --- /dev/null +++ b/3.0/connectwise/requests.go @@ -0,0 +1,22 @@ +package connectwise + +import ( + "fmt" + "io/ioutil" + "log" + "net/http" +) + +//Checks for HTTP errors, and if all looks good, returns the body of the HTTP response as a byte slice +func getHTTPResponseBody(resp *http.Response) (body []byte) { + if resp.StatusCode != http.StatusOK { + out := fmt.Sprintf("CW API returned HTTP Status Code %s\n%s", resp.Status, resp.Body) + log.Fatal(out) + return make([]byte, 0) + } else { + body, err := ioutil.ReadAll(resp.Body) + check(err) + + return body + } +}