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" "encoding/json"
"fmt" "fmt"
"strconv" "strconv"
"time"
) )
//ServiceTeam is a struct to hold the unmarshaled JSON data when making a call to the service API //ServiceTeam is a struct to hold the unmarshaled JSON data when making a call to the service API
@ -36,10 +35,10 @@ type ServiceTeam struct {
} `json:"department"` } `json:"department"`
DeleteNotifyFlag bool `json:"deleteNotifyFlag"` DeleteNotifyFlag bool `json:"deleteNotifyFlag"`
Info struct { Info struct {
LastUpdated time.Time `json:"lastUpdated"` LastUpdated string `json:"lastUpdated"`
UpdatedBy string `json:"updatedBy"` UpdatedBy string `json:"updatedBy"`
DateEntered time.Time `json:"dateEntered"` DateEntered string `json:"dateEntered"`
EnteredBy string `json:"enteredBy"` EnteredBy string `json:"enteredBy"`
} `json:"_info"` } `json:"_info"`
} }
@ -62,8 +61,8 @@ type BoardTeam struct {
LocationID int `json:"locationId"` LocationID int `json:"locationId"`
BusinessUnitID int `json:"businessUnitId"` BusinessUnitID int `json:"businessUnitId"`
Info struct { Info struct {
LastUpdated time.Time `json:"lastUpdated"` LastUpdated string `json:"lastUpdated"`
UpdatedBy string `json:"updatedBy"` UpdatedBy string `json:"updatedBy"`
} `json:"_info"` } `json:"_info"`
} }
@ -102,10 +101,10 @@ type BoardStatus struct {
} `json:"_info"` } `json:"_info"`
} `json:"emailTemplate,omitempty"` } `json:"emailTemplate,omitempty"`
Info struct { Info struct {
LastUpdated time.Time `json:"lastUpdated"` LastUpdated string `json:"lastUpdated"`
UpdatedBy string `json:"updatedBy"` UpdatedBy string `json:"updatedBy"`
DateEntered time.Time `json:"dateEntered"` DateEntered string `json:"dateEntered"`
EnteredBy string `json:"enteredBy"` EnteredBy string `json:"enteredBy"`
} `json:"_info"` } `json:"_info"`
} }
@ -189,42 +188,42 @@ type Ticket struct {
AgreementHref string `json:"agreement_href"` AgreementHref string `json:"agreement_href"`
} `json:"_info"` } `json:"_info"`
} `json:"agreement,omitempty"` } `json:"agreement,omitempty"`
Severity string `json:"severity"` Severity string `json:"severity"`
Impact string `json:"impact"` Impact string `json:"impact"`
AllowAllClientsPortalView bool `json:"allowAllClientsPortalView"` AllowAllClientsPortalView bool `json:"allowAllClientsPortalView"`
CustomerUpdatedFlag bool `json:"customerUpdatedFlag"` CustomerUpdatedFlag bool `json:"customerUpdatedFlag"`
AutomaticEmailContactFlag bool `json:"automaticEmailContactFlag"` AutomaticEmailContactFlag bool `json:"automaticEmailContactFlag"`
AutomaticEmailResourceFlag bool `json:"automaticEmailResourceFlag"` AutomaticEmailResourceFlag bool `json:"automaticEmailResourceFlag"`
AutomaticEmailCcFlag bool `json:"automaticEmailCcFlag"` AutomaticEmailCcFlag bool `json:"automaticEmailCcFlag"`
ClosedDate time.Time `json:"closedDate"` ClosedDate string `json:"closedDate"`
ClosedBy string `json:"closedBy"` ClosedBy string `json:"closedBy"`
ClosedFlag bool `json:"closedFlag"` ClosedFlag bool `json:"closedFlag"`
DateEntered time.Time `json:"dateEntered"` DateEntered string `json:"dateEntered"`
EnteredBy string `json:"enteredBy"` EnteredBy string `json:"enteredBy"`
ActualHours float64 `json:"actualHours,omitempty"` ActualHours float64 `json:"actualHours,omitempty"`
Approved bool `json:"approved"` Approved bool `json:"approved"`
EstimatedExpenseCost float64 `json:"estimatedExpenseCost"` EstimatedExpenseCost float64 `json:"estimatedExpenseCost"`
EstimatedExpenseRevenue float64 `json:"estimatedExpenseRevenue"` EstimatedExpenseRevenue float64 `json:"estimatedExpenseRevenue"`
EstimatedProductCost float64 `json:"estimatedProductCost"` EstimatedProductCost float64 `json:"estimatedProductCost"`
EstimatedProductRevenue float64 `json:"estimatedProductRevenue"` EstimatedProductRevenue float64 `json:"estimatedProductRevenue"`
EstimatedTimeCost float64 `json:"estimatedTimeCost"` EstimatedTimeCost float64 `json:"estimatedTimeCost"`
EstimatedTimeRevenue float64 `json:"estimatedTimeRevenue"` EstimatedTimeRevenue float64 `json:"estimatedTimeRevenue"`
BillingMethod string `json:"billingMethod"` BillingMethod string `json:"billingMethod"`
SubBillingMethod string `json:"subBillingMethod"` SubBillingMethod string `json:"subBillingMethod"`
DateResolved time.Time `json:"dateResolved"` DateResolved string `json:"dateResolved"`
DateResplan time.Time `json:"dateResplan"` DateResplan string `json:"dateResplan"`
DateResponded time.Time `json:"dateResponded"` DateResponded string `json:"dateResponded"`
ResolveMinutes int `json:"resolveMinutes"` ResolveMinutes int `json:"resolveMinutes"`
ResPlanMinutes int `json:"resPlanMinutes"` ResPlanMinutes int `json:"resPlanMinutes"`
RespondMinutes int `json:"respondMinutes"` RespondMinutes int `json:"respondMinutes"`
IsInSLA bool `json:"isInSla"` IsInSLA bool `json:"isInSla"`
HasChildTicket bool `json:"hasChildTicket"` HasChildTicket bool `json:"hasChildTicket"`
BillTime string `json:"billTime"` BillTime string `json:"billTime"`
BillExpenses string `json:"billExpenses"` BillExpenses string `json:"billExpenses"`
BillProducts string `json:"billProducts"` BillProducts string `json:"billProducts"`
LocationID int `json:"locationId"` LocationID int `json:"locationId"`
BusinessUnitID int `json:"businessUnitId"` BusinessUnitID int `json:"businessUnitId"`
MobileGUID string `json:"mobileGuid"` MobileGUID string `json:"mobileGuid"`
SLA struct { SLA struct {
ID int `json:"id"` ID int `json:"id"`
Name string `json:"name"` Name string `json:"name"`
@ -242,17 +241,17 @@ type Ticket struct {
} `json:"_info"` } `json:"_info"`
} `json:"currency"` } `json:"currency"`
Info struct { Info struct {
LastUpdated time.Time `json:"lastUpdated"` LastUpdated string `json:"lastUpdated"`
UpdatedBy string `json:"updatedBy"` UpdatedBy string `json:"updatedBy"`
ActivitiesHref string `json:"activities_href"` ActivitiesHref string `json:"activities_href"`
ScheduleentriesHref string `json:"scheduleentries_href"` ScheduleentriesHref string `json:"scheduleentries_href"`
DocumentsHref string `json:"documents_href"` DocumentsHref string `json:"documents_href"`
ConfigurationsHref string `json:"configurations_href"` ConfigurationsHref string `json:"configurations_href"`
TasksHref string `json:"tasks_href"` TasksHref string `json:"tasks_href"`
NotesHref string `json:"notes_href"` NotesHref string `json:"notes_href"`
ProductsHref string `json:"products_href"` ProductsHref string `json:"products_href"`
TimeentriesHref string `json:"timeentries_href"` TimeentriesHref string `json:"timeentries_href"`
ExpenseEntriesHref string `json:"expenseEntries_href"` ExpenseEntriesHref string `json:"expenseEntries_href"`
} `json:"_info"` } `json:"_info"`
CustomFields []struct { CustomFields []struct {
ID int `json:"id"` ID int `json:"id"`
@ -263,9 +262,9 @@ 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. //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"` Value string `json:"value"`
} `json:"customFields"` } `json:"customFields"`
RequiredDate time.Time `json:"requiredDate,omitempty"` RequiredDate string `json:"requiredDate,omitempty"`
BudgetHours float64 `json:"budgetHours,omitempty"` BudgetHours float64 `json:"budgetHours,omitempty"`
AddressLine2 string `json:"addressLine2,omitempty"` AddressLine2 string `json:"addressLine2,omitempty"`
Contact struct { Contact struct {
ID int `json:"id"` ID int `json:"id"`
Name string `json:"name"` Name string `json:"name"`
@ -277,6 +276,39 @@ type Ticket struct {
ContactPhoneExtension string `json:"contactPhoneExtension,omitempty"` 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 //Board is a struct to hold the unmarshaled JSON data when making a call to the Service API
type Board struct { type Board struct {
ID int `json:"id"` ID int `json:"id"`
@ -397,8 +429,8 @@ type Board struct {
ClosedLoopAllFlag bool `json:"closedLoopAllFlag"` ClosedLoopAllFlag bool `json:"closedLoopAllFlag"`
AllSort string `json:"allSort"` AllSort string `json:"allSort"`
Info struct { Info struct {
LastUpdated time.Time `json:"lastUpdated"` LastUpdated string `json:"lastUpdated"`
UpdatedBy string `json:"updatedBy"` UpdatedBy string `json:"updatedBy"`
} `json:"_info"` } `json:"_info"`
ShowDependenciesFlag bool `json:"showDependenciesFlag,omitempty"` ShowDependenciesFlag bool `json:"showDependenciesFlag,omitempty"`
ShowEstimatesFlag bool `json:"showEstimatesFlag,omitempty"` ShowEstimatesFlag bool `json:"showEstimatesFlag,omitempty"`
@ -413,11 +445,11 @@ type Source struct {
Name string `json:"name"` Name string `json:"name"`
DefaultFlag bool `json:"defaultFlag"` DefaultFlag bool `json:"defaultFlag"`
Info struct { Info struct {
LastUpdated time.Time `json:"lastUpdated"` LastUpdated string `json:"lastUpdated"`
UpdatedBy string `json:"updatedBy"` UpdatedBy string `json:"updatedBy"`
} `json:"_info"` } `json:"_info"`
EnteredBy string `json:"enteredBy"` 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 //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 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
}