Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fields to Ticket to support safe-update #106

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion zendesk/ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package zendesk

import (
"fmt"
"github.com/google/go-querystring/query"
"strconv"
"strings"
"time"

"github.com/google/go-querystring/query"
)

// Ticket represents a Zendesk Ticket.
Expand Down Expand Up @@ -47,6 +48,11 @@ type Ticket struct {
TicketFormID *int64 `json:"ticket_form_id,omitempty"`
FollowupSourceID *int64 `json:"via_followup_source_id,omitempty"`

// safe update fields
// https://developer.zendesk.com/documentation/ticketing/managing-tickets/creating-and-updating-tickets/#protecting-against-ticket-update-collisions
UpdatedStamp *time.Time `json:"updated_stamp,omitempty"`
SafeUpdate *bool `json:"safe_update,omitempty"`

AdditionalTags []string `json:"additional_tags,omitempty"`
RemoveTags []string `json:"remove_tags,omitempty"`
}
Expand Down
3 changes: 3 additions & 0 deletions zendesk/ticket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ func TestTicketCRUD(t *testing.T) {
require.True(t, len(allTickets.Tickets) > 0)
require.Equal(t, *created.ID, *allTickets.Tickets[0].ID)

safeUpdate := true
input := Ticket{
Status: String("solved"),
AdditionalCollaborators: []interface{}{"[email protected]"},
UpdatedStamp: created.UpdatedAt,
SafeUpdate: &safeUpdate,
}

updated, err := client.UpdateTicket(*created.ID, &input)
Expand Down