Skip to content

Commit

Permalink
Make Via field to pointer type (#194)
Browse files Browse the repository at this point in the history
* Make Via field to pointer type

* go fmt

* Fix test
  • Loading branch information
nukosuke committed Dec 19, 2020
1 parent fc3399e commit 4bfaec9
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 27 deletions.
2 changes: 1 addition & 1 deletion zendesk/attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestWrite(t *testing.T) {
}

func TestWriteCancelledContext(t *testing.T) {
mockAPI := newMockAPIWithStatus(http.MethodPost, "ticket.json", 201)
mockAPI := newMockAPIWithStatus(http.MethodPost, "ticket.json", 201)
defer mockAPI.Close()

client := newTestClient(mockAPI)
Expand Down
19 changes: 11 additions & 8 deletions zendesk/ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,7 @@ type Ticket struct {
Tags []string `json:"tags,omitempty"`
CustomFields []CustomField `json:"custom_fields,omitempty"`

Via struct {
Channel string `json:"channel"`
Source struct {
From map[string]interface{} `json:"from"`
To map[string]interface{} `json:"to"`
Rel string `json:"rel"`
} `json:"source"`
} `json:"via,omitempty"`
Via *Via `json:"via,omitempty"`

SatisfactionRating struct {
ID int64 `json:"id"`
Expand Down Expand Up @@ -109,6 +102,16 @@ type Ticket struct {
// TODO: TicketAudit (POST only) #126
}

// Via is information about source of Ticket or TicketComment
type Via struct {
Channel string `json:"channel"`
Source struct {
From map[string]interface{} `json:"from"`
To map[string]interface{} `json:"to"`
Rel string `json:"rel"`
} `json:"source"`
}

type TicketListOptions struct {
PageOptions

Expand Down
2 changes: 0 additions & 2 deletions zendesk/ticket_audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,3 @@ func TestGetTicketAudit(t *testing.T) {
t.Fatalf("Returned ticket audit does not have the expected ID %d. Ticket audit id is %d", expectedID, ticketAudit.ID)
}
}


9 changes: 1 addition & 8 deletions zendesk/ticket_comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,7 @@ type TicketComment struct {
Uploads []string `json:"uploads,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`

Via struct {
Channel string `json:"channel"`
Source struct {
From map[string]interface{} `json:"from"`
To map[string]interface{} `json:"to"`
Rel string `json:"rel"`
} `json:"source"`
} `json:"via,omitempty"`
Via *Via `json:"via,omitempty"`
}

// NewPublicTicketComment generates and returns a new TicketComment
Expand Down
9 changes: 1 addition & 8 deletions zendesk/ticket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,7 @@ func TestGetTicket(t *testing.T) {
t.Fatalf("Returned ticket does not have the expected ID %d. Ticket id is %d", expectedID, ticket.ID)
}

expectedVia := struct {
Channel string `json:"channel"`
Source struct {
From map[string]interface{} `json:"from"`
To map[string]interface{} `json:"to"`
Rel string `json:"rel"`
} `json:"source"`
}{
expectedVia := &Via{
Channel: "email",
Source: struct {
From map[string]interface{} `json:"from"`
Expand Down

0 comments on commit 4bfaec9

Please sign in to comment.