diff --git a/3.0/connectwise/company.go b/3.0/connectwise/company.go index 7b0c9a8..4efe5e5 100644 --- a/3.0/connectwise/company.go +++ b/3.0/connectwise/company.go @@ -150,14 +150,13 @@ type Company struct { //Will return a pointer to a slice of Company's. func (cw *ConnectwiseSite) GetCompanyByName(companyName string) *[]Company { - companies := []Company{} - cwurl := cw.BuildURL("/company/companies") parameters := url.Values{} parameters.Add("conditions", "name=\""+companyName+"\"") cwurl.RawQuery = parameters.Encode() body := cw.GetRequest(cwurl) + companies := []Company{} check(json.Unmarshal(body, &companies)) return &companies diff --git a/3.0/connectwise/finance.go b/3.0/connectwise/finance.go index 93dbe84..1195741 100644 --- a/3.0/connectwise/finance.go +++ b/3.0/connectwise/finance.go @@ -3,6 +3,7 @@ package connectwise import ( "encoding/json" "fmt" + "net/url" ) //Agreement is a struct to hold the unmarshaled JSON data when making a call to the Finance API @@ -129,6 +130,20 @@ func (cw *ConnectwiseSite) GetAgreements() *[]Agreement { } +func (cw *ConnectwiseSite) GetAgreementsByCompanyName(companyName string) *[]Agreement { + + cwurl := cw.BuildURL("/finance/agreements") + parameters := url.Values{} + parameters.Add("conditions", "company/name=\""+companyName+"\"") + cwurl.RawQuery = parameters.Encode() + + body := cw.GetRequest(cwurl) + agreements := []Agreement{} + check(json.Unmarshal(body, &agreements)) + + return &agreements +} + //GetBillingCycles is not complete //TBD: Finish this. func (cw *ConnectwiseSite) GetBillingCycles() { diff --git a/3.0/connectwise/service.go b/3.0/connectwise/service.go index 672946c..b326670 100644 --- a/3.0/connectwise/service.go +++ b/3.0/connectwise/service.go @@ -172,11 +172,8 @@ type Ticket struct { ContactPhoneExtension string `json:"contactPhoneExtension,omitempty"` } -<<<<<<< HEAD //TimeEntryReference is a struct to hold the unmarshaled JSON data when making a call to the Service API //TBD: For some reason the Info struct contained in TimeEntryReference does get data when the JSON is unmarshaled into this struct. The ID works fine -======= ->>>>>>> ab8a24800f1f1789b3aca8e12cc3f8ccfc1ba415 type TimeEntryReference struct { ID int Info struct { @@ -220,9 +217,9 @@ func (cw *ConnectwiseSite) GetTicketTimeEntriesByID(ticketID int) *[]TimeEntryRe func (cw *ConnectwiseSite) GetTicketConfigurationsByID(ticketID int) *[]ConfigurationReference { - Url := cw.BuildUrl(fmt.Sprintf("/service/tickets/%d/configurations", ticketID)) + cwurl := cw.BuildURL(fmt.Sprintf("/service/tickets/%d/configurations", ticketID)) - body := cw.GetRequest(Url) + body := cw.GetRequest(cwurl) configurationReference := []ConfigurationReference{} check(json.Unmarshal(body, &configurationReference))