Fix naming of url variables

This commit is contained in:
Steven Polley 2018-06-29 16:56:22 -06:00
parent 13e1366985
commit 56f730eadc
2 changed files with 12 additions and 12 deletions

View File

@ -45,20 +45,20 @@ func getHTTPResponseBody(resp *http.Response) []byte {
//BuildURL expects a restaction to be passed to it
//Returns the full request URL containing the ITG API domain prepended to the rest action
func (itg *ITGAPI) BuildURL(restAction string) *url.URL {
var URL *url.URL
URL, err := url.Parse(itg.Site)
var itgurl *url.URL
itgurl, err := url.Parse(itg.Site)
check(err)
URL.Path += restAction
return URL
itgurl.Path += restAction
return itgurl
}
//GetRequest allows a custom GET request to the API to be made.
//Also used internally by this package by the binding functions
//Expects URL to be passed
//Returns the response body as a byte slice
func (itg *ITGAPI) GetRequest(URL *url.URL) []byte {
func (itg *ITGAPI) GetRequest(itgurl *url.URL) []byte {
client := &http.Client{}
req, err := http.NewRequest("GET", URL.String(), nil)
req, err := http.NewRequest("GET", itgurl.String(), nil)
check(err)
req.Header.Set("Content-Type", "application/vnd.api+json")
req.Header.Set("x-api-key", itg.APIKey)
@ -74,9 +74,9 @@ func (itg *ITGAPI) GetRequest(URL *url.URL) []byte {
//Also used internally by this package by the binding functions
//Expects a URL and a body to be passed
//Returns the response body as a byte slice
func (itg *ITGAPI) PostRequest(URL *url.URL, body io.Reader) []byte {
func (itg *ITGAPI) PostRequest(itgurl *url.URL, body io.Reader) []byte {
client := &http.Client{}
req, err := http.NewRequest("POST", URL.String(), body)
req, err := http.NewRequest("POST", itgurl.String(), body)
check(err)
req.Header.Set("Content-Type", "application/vnd.api+json")
req.Header.Set("x-api-key", itg.APIKey)
@ -93,9 +93,9 @@ func (itg *ITGAPI) PostRequest(URL *url.URL, body io.Reader) []byte {
//Also used internally by this package by the binding functions
//Expects a URL and a body to be passed
//Returns the response body as a byte slice
func (itg *ITGAPI) PatchRequest(URL *url.URL, body io.Reader) []byte {
func (itg *ITGAPI) PatchRequest(itgurl *url.URL, body io.Reader) []byte {
client := &http.Client{}
req, err := http.NewRequest("PATCH", URL.String(), body)
req, err := http.NewRequest("PATCH", itgurl.String(), body)
check(err)
req.Header.Set("Content-Type", "application/vnd.api+json")
req.Header.Set("x-api-key", itg.APIKey)

View File

@ -26,9 +26,9 @@ type Organization struct {
//GetOrganizationByID expects an ITG organization ID
//Returns a pointer to an Organization struct
func (itg *ITGAPI) GetOrganizationByID(organizationID int) {
URL := itg.BuildURL(fmt.Sprintf("/organizations/%d", organizationID))
itgurl := itg.BuildURL(fmt.Sprintf("/organizations/%d", organizationID))
body := itg.GetRequest(URL)
body := itg.GetRequest(itgurl)
fmt.Print(string(body))
//organization := Organization{}