add getTicketNotes - Lots of dates are now strings

This commit is contained in:
Steven Polley 2018-08-23 19:34:39 -06:00
parent 386a7d75ca
commit c341f047a5

View File

@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"strconv"
"time"
)
//ServiceTeam is a struct to hold the unmarshaled JSON data when making a call to the service API
@ -36,9 +35,9 @@ type ServiceTeam struct {
} `json:"department"`
DeleteNotifyFlag bool `json:"deleteNotifyFlag"`
Info struct {
LastUpdated time.Time `json:"lastUpdated"`
LastUpdated string `json:"lastUpdated"`
UpdatedBy string `json:"updatedBy"`
DateEntered time.Time `json:"dateEntered"`
DateEntered string `json:"dateEntered"`
EnteredBy string `json:"enteredBy"`
} `json:"_info"`
}
@ -62,7 +61,7 @@ type BoardTeam struct {
LocationID int `json:"locationId"`
BusinessUnitID int `json:"businessUnitId"`
Info struct {
LastUpdated time.Time `json:"lastUpdated"`
LastUpdated string `json:"lastUpdated"`
UpdatedBy string `json:"updatedBy"`
} `json:"_info"`
}
@ -102,9 +101,9 @@ type BoardStatus struct {
} `json:"_info"`
} `json:"emailTemplate,omitempty"`
Info struct {
LastUpdated time.Time `json:"lastUpdated"`
LastUpdated string `json:"lastUpdated"`
UpdatedBy string `json:"updatedBy"`
DateEntered time.Time `json:"dateEntered"`
DateEntered string `json:"dateEntered"`
EnteredBy string `json:"enteredBy"`
} `json:"_info"`
}
@ -196,10 +195,10 @@ type Ticket struct {
AutomaticEmailContactFlag bool `json:"automaticEmailContactFlag"`
AutomaticEmailResourceFlag bool `json:"automaticEmailResourceFlag"`
AutomaticEmailCcFlag bool `json:"automaticEmailCcFlag"`
ClosedDate time.Time `json:"closedDate"`
ClosedDate string `json:"closedDate"`
ClosedBy string `json:"closedBy"`
ClosedFlag bool `json:"closedFlag"`
DateEntered time.Time `json:"dateEntered"`
DateEntered string `json:"dateEntered"`
EnteredBy string `json:"enteredBy"`
ActualHours float64 `json:"actualHours,omitempty"`
Approved bool `json:"approved"`
@ -211,9 +210,9 @@ type Ticket struct {
EstimatedTimeRevenue float64 `json:"estimatedTimeRevenue"`
BillingMethod string `json:"billingMethod"`
SubBillingMethod string `json:"subBillingMethod"`
DateResolved time.Time `json:"dateResolved"`
DateResplan time.Time `json:"dateResplan"`
DateResponded time.Time `json:"dateResponded"`
DateResolved string `json:"dateResolved"`
DateResplan string `json:"dateResplan"`
DateResponded string `json:"dateResponded"`
ResolveMinutes int `json:"resolveMinutes"`
ResPlanMinutes int `json:"resPlanMinutes"`
RespondMinutes int `json:"respondMinutes"`
@ -242,7 +241,7 @@ type Ticket struct {
} `json:"_info"`
} `json:"currency"`
Info struct {
LastUpdated time.Time `json:"lastUpdated"`
LastUpdated string `json:"lastUpdated"`
UpdatedBy string `json:"updatedBy"`
ActivitiesHref string `json:"activities_href"`
ScheduleentriesHref string `json:"scheduleentries_href"`
@ -263,7 +262,7 @@ type Ticket struct {
//It's not always a string. I need to somehow *puts on sunglasses*... reflect on this as this is a dynamic type.
Value string `json:"value"`
} `json:"customFields"`
RequiredDate time.Time `json:"requiredDate,omitempty"`
RequiredDate string `json:"requiredDate,omitempty"`
BudgetHours float64 `json:"budgetHours,omitempty"`
AddressLine2 string `json:"addressLine2,omitempty"`
Contact struct {
@ -277,6 +276,39 @@ type Ticket struct {
ContactPhoneExtension string `json:"contactPhoneExtension,omitempty"`
}
type TicketNote struct {
ID int `json:"id"`
TicketID int `json:"ticketId"`
Text string `json:"text"`
DetailDescriptionFlag bool `json:"detailDescriptionFlag"`
InternalAnalysisFlag bool `json:"internalAnalysisFlag"`
ResolutionFlag bool `json:"resolutionFlag"`
Contact struct {
ID int `json:"id"`
Name string `json:"name"`
Info struct {
ContactHref string `json:"contact_href"`
} `json:"_info"`
} `json:"contact,omitempty"`
DateCreated string `json:"dateCreated"`
CreatedBy string `json:"createdBy"`
InternalFlag bool `json:"internalFlag"`
ExternalFlag bool `json:"externalFlag"`
Info struct {
LastUpdated string `json:"lastUpdated"`
UpdatedBy string `json:"updatedBy"`
} `json:"_info"`
Member struct {
ID int `json:"id"`
Identifier string `json:"identifier"`
Name string `json:"name"`
Info struct {
MemberHref string `json:"member_href"`
ImageHref string `json:"image_href"`
} `json:"_info"`
} `json:"member,omitempty"`
}
//Board is a struct to hold the unmarshaled JSON data when making a call to the Service API
type Board struct {
ID int `json:"id"`
@ -397,7 +429,7 @@ type Board struct {
ClosedLoopAllFlag bool `json:"closedLoopAllFlag"`
AllSort string `json:"allSort"`
Info struct {
LastUpdated time.Time `json:"lastUpdated"`
LastUpdated string `json:"lastUpdated"`
UpdatedBy string `json:"updatedBy"`
} `json:"_info"`
ShowDependenciesFlag bool `json:"showDependenciesFlag,omitempty"`
@ -413,11 +445,11 @@ type Source struct {
Name string `json:"name"`
DefaultFlag bool `json:"defaultFlag"`
Info struct {
LastUpdated time.Time `json:"lastUpdated"`
LastUpdated string `json:"lastUpdated"`
UpdatedBy string `json:"updatedBy"`
} `json:"_info"`
EnteredBy string `json:"enteredBy"`
DateEntered time.Time `json:"dateEntered"`
DateEntered string `json:"dateEntered"`
}
//TimeEntryReference is a struct to hold the unmarshaled JSON data when making a call to the Service API
@ -645,3 +677,19 @@ func (cw *Site) GetSources() (*[]Source, error) {
return source, nil
}
func (cw *Site) GetTicketNotes(ticketID int) (*[]TicketNote, error) {
req := cw.NewRequest(fmt.Sprintf("/service/tickets/%d/notes", ticketID), "GET", nil)
err := req.Do()
if err != nil {
return nil, fmt.Errorf("request failed for %s: %s", req.RestAction, err)
}
ticketNotes := &[]TicketNote{}
err = json.Unmarshal(req.Body, ticketNotes)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err)
}
return ticketNotes, nil
}