Add AssignTickeToCompany

This commit is contained in:
Steven Polley 2018-10-15 18:20:55 -06:00
parent 959df43d67
commit 660c35487f

View File

@ -719,6 +719,35 @@ func (cw *Site) AssignTicketToMember(ticketID, memberID int) (*ScheduleEntry, er
return scheduleEntry, nil return scheduleEntry, nil
} }
//AssignTicketToCompany
func (cw *Site) AssignTicketToCompany(ticketID, companyID int) (*Ticket, error) {
patches := &[]PatchString{}
patch := &PatchString{
Op: "replace",
Path: "company/id",
Value: strconv.Itoa(companyID)}
*patches = append(*patches, *patch)
patchBody, err := json.Marshal(patches)
if err != nil {
return nil, fmt.Errorf("could not marhsal patch json to byte slice: %s", err)
}
req := cw.NewRequest(fmt.Sprintf("/service/tickets/%d", ticketID), "PATCH", patchBody)
err = req.Do()
if err != nil {
return nil, fmt.Errorf("request failed for %s: %s", req.RestAction, err)
}
ticket := &Ticket{}
err = json.Unmarshal(req.Body, ticket)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal body into struct: %s", err)
}
return ticket, nil
}
//AssignTicketToMember will create a new schedule entry for the member and specify the ticket as the object //AssignTicketToMember will create a new schedule entry for the member and specify the ticket as the object
func (cw *Site) TicketMerge(mainTicketID int, mergedTicketIDs []int, mergedTicketStatusID int) error { func (cw *Site) TicketMerge(mainTicketID int, mergedTicketIDs []int, mergedTicketStatusID int) error {
ticketMerge := &TicketMerge{} ticketMerge := &TicketMerge{}