From 3258707dce79baa03e6ff4095ff0dba50dd2e71d Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Mon, 25 Jun 2018 12:54:10 -0600 Subject: [PATCH 1/3] Custom fields should be a slice of structs in time.go --- 3.0/connectwise/time.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3.0/connectwise/time.go b/3.0/connectwise/time.go index a87c288..64ebbd5 100644 --- a/3.0/connectwise/time.go +++ b/3.0/connectwise/time.go @@ -73,7 +73,7 @@ type TimeEntry struct { UpdatedBy string `json:"updatedBy"` ChargeToMobileGUID string `json:"chargeToMobileGuid"` } `json:"_info"` - CustomFields struct { + CustomFields []struct { ID int Caption string Type string From b35fcbbbb09bd7a839119bd80af5272e82e92cf2 Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Tue, 26 Jun 2018 09:03:36 -0600 Subject: [PATCH 2/3] TIL about struct tagging using string literals... I thought those were just weird fancy comments. --- 3.0/connectwise/service.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/3.0/connectwise/service.go b/3.0/connectwise/service.go index e6755e7..7366211 100644 --- a/3.0/connectwise/service.go +++ b/3.0/connectwise/service.go @@ -171,13 +171,12 @@ type Ticket struct { ContactPhoneExtension string `json:"contactPhoneExtension,omitempty"` } -//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 type TimeEntryReference struct { ID int Info struct { - Notes string - TimeHref string - } + Notes string `json:"notes"` + TimeHref string `json:"time_href"` + } `json:"_info"` } func (cw *ConnectwiseSite) GetTicketByID(ticketID int) *Ticket { From ab8a24800f1f1789b3aca8e12cc3f8ccfc1ba415 Mon Sep 17 00:00:00 2001 From: Steven Polley Date: Tue, 26 Jun 2018 10:03:11 -0600 Subject: [PATCH 3/3] Added ConfigurationReference struct and GetTicketConfigurationsByID(ticketID) receiver --- 3.0/connectwise/service.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/3.0/connectwise/service.go b/3.0/connectwise/service.go index 7366211..de66b7f 100644 --- a/3.0/connectwise/service.go +++ b/3.0/connectwise/service.go @@ -179,6 +179,15 @@ type TimeEntryReference struct { } `json:"_info"` } +type ConfigurationReference struct { + ID int `json:"id"` + DeviceIdentifier string `json:"deviceIdentifier"` + Info struct { + Name string `json:"name"` + ConfigurationHref string `json:"configuration_href"` + } `json:"_info"` +} + func (cw *ConnectwiseSite) GetTicketByID(ticketID int) *Ticket { Url := cw.BuildUrl(fmt.Sprintf("/service/tickets/%d", ticketID)) @@ -200,3 +209,14 @@ func (cw *ConnectwiseSite) GetTicketTimeEntriesByID(ticketID int) *[]TimeEntryRe return &timeEntryReference } + +func (cw *ConnectwiseSite) GetTicketConfigurationsByID(ticketID int) *[]ConfigurationReference { + + Url := cw.BuildUrl(fmt.Sprintf("/service/tickets/%d/configurations", ticketID)) + + body := cw.GetRequest(Url) + configurationReference := []ConfigurationReference{} + check(json.Unmarshal(body, &configurationReference)) + + return &configurationReference +}