Moved getHTTPResponseBody to requests.go what am i doing lol
This commit is contained in:
		@@ -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{}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										22
									
								
								3.0/connectwise/requests.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								3.0/connectwise/requests.go
									
									
									
									
									
										Normal file
									
								
							@@ -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
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user