diff --git a/3.0/connectwise/company.go b/3.0/connectwise/company.go index f51cbb8..ca4d660 100644 --- a/3.0/connectwise/company.go +++ b/3.0/connectwise/company.go @@ -152,7 +152,7 @@ func (cw *ConnectwiseSite) GetCompanyByName(companyName string) (*[]Company, err restAction := "/company/companies" cwurl, err := cw.BuildURL(restAction) if err != nil { - return nil, fmt.Errorf("could not build url %s: %g", restAction, err) + return nil, fmt.Errorf("could not build url %s: %s", restAction, err) } parameters := url.Values{} @@ -161,12 +161,12 @@ func (cw *ConnectwiseSite) GetCompanyByName(companyName string) (*[]Company, err body, err := cw.GetRequest(cwurl) if err != nil { - return nil, fmt.Errorf("could not get request %s: %g", cwurl, err) + return nil, fmt.Errorf("could not get request %s: %s", cwurl, err) } companies := []Company{} err = json.Unmarshal(body, &companies) if err != nil { - return nil, fmt.Errorf("failed to unmarshal body into struct: %g", err) + return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err) } return &companies, nil @@ -178,18 +178,18 @@ func (cw *ConnectwiseSite) GetCompanyByID(companyID int) (*Company, error) { restAction := fmt.Sprintf("/company/companies/%d", companyID) cwurl, err := cw.BuildURL(restAction) if err != nil { - return nil, fmt.Errorf("could not build url %s: %g", restAction, err) + return nil, fmt.Errorf("could not build url %s: %s", restAction, err) } body, err := cw.GetRequest(cwurl) if err != nil { - return nil, fmt.Errorf("could not get request %s: %g", cwurl, err) + return nil, fmt.Errorf("could not get request %s: %s", cwurl, err) } company := Company{} err = json.Unmarshal(body, &company) if err != nil { - return nil, fmt.Errorf("failed to unmarshal body into struct: %g", err) + return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err) } return &company, nil diff --git a/3.0/connectwise/finance.go b/3.0/connectwise/finance.go index d8710f3..1299509 100644 --- a/3.0/connectwise/finance.go +++ b/3.0/connectwise/finance.go @@ -121,17 +121,17 @@ func (cw *ConnectwiseSite) GetAgreements() (*[]Agreement, error) { restAction := "/finance/agreements" cwurl, err := cw.BuildURL(restAction) if err != nil { - return nil, fmt.Errorf("could not build url %s: %g", restAction, err) + return nil, fmt.Errorf("could not build url %s: %s", restAction, err) } body, err := cw.GetRequest(cwurl) if err != nil { - return nil, fmt.Errorf("could not get request %s: %g", cwurl, err) + return nil, fmt.Errorf("could not get request %s: %s", cwurl, err) } agreements := []Agreement{} err = json.Unmarshal(body, &agreements) if err != nil { - return nil, fmt.Errorf("failed to unmarshal body into struct: %g", err) + return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err) } return &agreements, nil @@ -144,7 +144,7 @@ func (cw *ConnectwiseSite) GetAgreementsByCompanyName(companyName string) (*[]Ag restAction := "/finance/agreements" cwurl, err := cw.BuildURL(restAction) if err != nil { - return nil, fmt.Errorf("could not build url %s: %g", restAction, err) + return nil, fmt.Errorf("could not build url %s: %s", restAction, err) } parameters := url.Values{} @@ -153,12 +153,12 @@ func (cw *ConnectwiseSite) GetAgreementsByCompanyName(companyName string) (*[]Ag body, err := cw.GetRequest(cwurl) if err != nil { - return nil, fmt.Errorf("could not get request %s: %g", cwurl, err) + return nil, fmt.Errorf("could not get request %s: %s", cwurl, err) } agreements := []Agreement{} err = json.Unmarshal(body, &agreements) if err != nil { - return nil, fmt.Errorf("failed to unmarshal body into struct: %g", err) + return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err) } return &agreements, nil diff --git a/3.0/connectwise/requests.go b/3.0/connectwise/requests.go index cdf645d..1ef84f5 100644 --- a/3.0/connectwise/requests.go +++ b/3.0/connectwise/requests.go @@ -13,7 +13,7 @@ func (cw *ConnectwiseSite) BuildURL(restAction string) (*url.URL, error) { var cwurl *url.URL cwurl, err := url.Parse(cw.Site) if err != nil { - return nil, fmt.Errorf("could not %s as url: %g", cw.Site, err) + return nil, fmt.Errorf("could not %s as url: %s", cw.Site, err) } cwurl.Path += restAction @@ -24,7 +24,7 @@ func (cw *ConnectwiseSite) BuildURL(restAction string) (*url.URL, error) { //TBD: Needs to accept 201 and 204 (returned for Create and Delete operations) func getHTTPResponseBody(resp *http.Response) ([]byte, error) { if (resp.StatusCode != http.StatusOK) && (resp.StatusCode != http.StatusCreated) && (resp.StatusCode != http.StatusNoContent) { - return nil, fmt.Errorf("cw api returned unexpected http status %i - %s", resp.StatusCode, resp.Status) + return nil, fmt.Errorf("cw api returned unexpected http status %d - %s", resp.StatusCode, resp.Status) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) @@ -40,18 +40,18 @@ func (cw *ConnectwiseSite) GetRequest(cwurl *url.URL) ([]byte, error) { client := &http.Client{} req, err := http.NewRequest("GET", cwurl.String(), nil) if err != nil { - return nil, fmt.Errorf("could not construct http request: %g", err) + return nil, fmt.Errorf("could not construct http request: %s", err) } req.Header.Set("Authorization", cw.Auth) req.Header.Set("Content-Type", "application/json") response, err := client.Do(req) if err != nil { - return nil, fmt.Errorf("could not perform http get request: %g", err) + return nil, fmt.Errorf("could not perform http get request: %s", err) } body, err := getHTTPResponseBody(response) if err != nil { - return nil, fmt.Errorf("could not get http response body: %g", err) + return nil, fmt.Errorf("could not get http response body: %s", err) } return body, nil @@ -62,18 +62,18 @@ func (cw *ConnectwiseSite) PostRequest(cwurl *url.URL, reqBody io.Reader) ([]byt client := &http.Client{} req, err := http.NewRequest("POST", cwurl.String(), reqBody) if err != nil { - return nil, fmt.Errorf("could not construct http request: %g", err) + return nil, fmt.Errorf("could not construct http request: %s", err) } req.Header.Set("Authorization", cw.Auth) req.Header.Set("Content-Type", "application/json") response, err := client.Do(req) if err != nil { - return nil, fmt.Errorf("could not perform http post request: %g", err) + return nil, fmt.Errorf("could not perform http post request: %s", err) } body, err := getHTTPResponseBody(response) if err != nil { - return nil, fmt.Errorf("could not get http response body: %g", err) + return nil, fmt.Errorf("could not get http response body: %s", err) } return body, nil @@ -84,18 +84,18 @@ func (cw *ConnectwiseSite) DeleteRequest(cwurl *url.URL) ([]byte, error) { client := &http.Client{} req, err := http.NewRequest("DELETE", cwurl.String(), nil) if err != nil { - return nil, fmt.Errorf("could not construct http request: %g", err) + return nil, fmt.Errorf("could not construct http request: %s", err) } req.Header.Set("Authorization", cw.Auth) req.Header.Set("Content-Type", "application/json") response, err := client.Do(req) if err != nil { - return nil, fmt.Errorf("could not perform http delete request: %g", err) + return nil, fmt.Errorf("could not perform http delete request: %s", err) } body, err := getHTTPResponseBody(response) if err != nil { - return nil, fmt.Errorf("could not get http response body: %g", err) + return nil, fmt.Errorf("could not get http response body: %s", err) } return body, nil diff --git a/3.0/connectwise/service.go b/3.0/connectwise/service.go index 2600cc5..e6d1419 100644 --- a/3.0/connectwise/service.go +++ b/3.0/connectwise/service.go @@ -196,17 +196,17 @@ func (cw *ConnectwiseSite) GetTicketByID(ticketID int) (*Ticket, error) { restAction := fmt.Sprintf("/service/tickets/%d", ticketID) cwurl, err := cw.BuildURL(restAction) if err != nil { - return nil, fmt.Errorf("could not build url %s: %g", restAction, err) + return nil, fmt.Errorf("could not build url %s: %s", restAction, err) } body, err := cw.GetRequest(cwurl) if err != nil { - return nil, fmt.Errorf("could not get request %s: %g", cwurl, err) + return nil, fmt.Errorf("could not get request %s: %s", cwurl, err) } ticket := Ticket{} err = json.Unmarshal(body, &ticket) if err != nil { - return nil, fmt.Errorf("failed to unmarshal body into struct: %g", err) + return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err) } return &ticket, nil @@ -217,17 +217,17 @@ func (cw *ConnectwiseSite) GetTicketTimeEntriesByID(ticketID int) (*[]TimeEntryR restAction := fmt.Sprintf("/service/tickets/%d/timeentries", ticketID) cwurl, err := cw.BuildURL(restAction) if err != nil { - return nil, fmt.Errorf("could not build url %s: %g", restAction, err) + return nil, fmt.Errorf("could not build url %s: %s", restAction, err) } body, err := cw.GetRequest(cwurl) if err != nil { - return nil, fmt.Errorf("could not get request %s: %g", cwurl, err) + return nil, fmt.Errorf("could not get request %s: %s", cwurl, err) } timeEntryReference := []TimeEntryReference{} err = json.Unmarshal(body, &timeEntryReference) if err != nil { - return nil, fmt.Errorf("failed to unmarshal body into struct: %g", err) + return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err) } return &timeEntryReference, nil @@ -237,17 +237,17 @@ func (cw *ConnectwiseSite) GetTicketConfigurationsByID(ticketID int) (*[]Configu restAction := fmt.Sprintf("/service/tickets/%d/configurations", ticketID) cwurl, err := cw.BuildURL(restAction) if err != nil { - return nil, fmt.Errorf("could not build url %s: %g", restAction, err) + return nil, fmt.Errorf("could not build url %s: %s", restAction, err) } body, err := cw.GetRequest(cwurl) if err != nil { - return nil, fmt.Errorf("could not get request %s: %g", cwurl, err) + return nil, fmt.Errorf("could not get request %s: %s", cwurl, err) } configurationReference := []ConfigurationReference{} err = json.Unmarshal(body, &configurationReference) if err != nil { - return nil, fmt.Errorf("failed to unmarshal body into struct: %g", err) + return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err) } return &configurationReference, nil diff --git a/3.0/connectwise/system.go b/3.0/connectwise/system.go index 028b450..69397b4 100644 --- a/3.0/connectwise/system.go +++ b/3.0/connectwise/system.go @@ -21,17 +21,17 @@ func (cw *ConnectwiseSite) GetCallbacks() (*[]Callback, error) { restAction := "/system/callbacks" cwurl, err := cw.BuildURL(restAction) if err != nil { - return nil, fmt.Errorf("could not build url %s: %g", restAction, err) + return nil, fmt.Errorf("could not build url %s: %s", restAction, err) } body, err := cw.GetRequest(cwurl) if err != nil { - return nil, fmt.Errorf("could not get request %s: %g", cwurl, err) + return nil, fmt.Errorf("could not get request %s: %s", cwurl, err) } callbacks := []Callback{} err = json.Unmarshal(body, &callbacks) if err != nil { - return nil, fmt.Errorf("failed to unmarshal body into struct: %g", err) + return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err) } return &callbacks, nil @@ -43,19 +43,19 @@ func (cw *ConnectwiseSite) NewCallback(callback Callback) error { restAction := "/system/callbacks" cwurl, err := cw.BuildURL(restAction) if err != nil { - return fmt.Errorf("could not build url %s: %g", restAction, err) + return fmt.Errorf("could not build url %s: %s", restAction, err) } jsonCallback, err := json.Marshal(callback) if err != nil { - return fmt.Errorf("could not marshal json data: %g", err) + return fmt.Errorf("could not marshal json data: %s", err) } jsonBuffer := bytes.NewReader(jsonCallback) _, err = cw.PostRequest(cwurl, jsonBuffer) if err != nil { - return fmt.Errorf("could not post request %s: %g", cwurl, err) + return fmt.Errorf("could not post request %s: %s", cwurl, err) } return nil @@ -66,11 +66,11 @@ func (cw *ConnectwiseSite) DeleteCallback(callback int) error { restAction := fmt.Sprintf("/system/callbacks/%d", callback) cwurl, err := cw.BuildURL(restAction) if err != nil { - return fmt.Errorf("could not build url %s: %g", restAction, err) + return fmt.Errorf("could not build url %s: %s", restAction, err) } _, err = cw.DeleteRequest(cwurl) if err != nil { - return fmt.Errorf("could not delete request %s: %g", cwurl, err) + return fmt.Errorf("could not delete request %s: %s", cwurl, err) } return nil diff --git a/3.0/connectwise/time.go b/3.0/connectwise/time.go index 985c8cc..b2b11c3 100644 --- a/3.0/connectwise/time.go +++ b/3.0/connectwise/time.go @@ -87,18 +87,18 @@ func (cw *ConnectwiseSite) GetTimeEntryByID(timeEntryID int) (*TimeEntry, error) restAction := fmt.Sprintf("/time/entries/%d", timeEntryID) cwurl, err := cw.BuildURL(restAction) if err != nil { - return nil, fmt.Errorf("could not build url %s: %g", restAction, err) + return nil, fmt.Errorf("could not build url %s: %s", restAction, err) } body, err := cw.GetRequest(cwurl) if err != nil { - return nil, fmt.Errorf("could not get request %s: %g", cwurl, err) + return nil, fmt.Errorf("could not get request %s: %s", cwurl, err) } timeEntry := TimeEntry{} err = json.Unmarshal(body, &timeEntry) if err != nil { - return nil, fmt.Errorf("failed to unmarshal body into struct: %g", err) + return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err) } return &timeEntry, nil