-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement opening ticket with note as two events
- Loading branch information
1 parent
04805d8
commit ad19d5d
Showing
14 changed files
with
132 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,10 +119,15 @@ | |
"assignee": { | ||
"email": "[email protected]", | ||
"name": "Bob" | ||
}, | ||
"note": "Last message: Hi everybody" | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "ticket_note_added", | ||
"created_on": "2018-10-18T14:20:30.000123456Z", | ||
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c", | ||
"note": "Last message: Hi everybody" | ||
}, | ||
{ | ||
"type": "contact_groups_changed", | ||
"created_on": "2018-10-18T14:20:30.000123456Z", | ||
|
@@ -183,8 +188,7 @@ | |
"assignee": { | ||
"email": "[email protected]", | ||
"name": "Bob" | ||
}, | ||
"note": "Last message: Hi everybody" | ||
} | ||
} | ||
}, | ||
"templates": [ | ||
|
@@ -229,10 +233,15 @@ | |
"topic": { | ||
"uuid": "0d9a2c56-6fc2-4f27-93c5-a6322e26b740", | ||
"name": "General" | ||
}, | ||
"note": "Last message: Hi everybody" | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "ticket_note_added", | ||
"created_on": "2018-10-18T14:20:30.000123456Z", | ||
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c", | ||
"note": "Last message: Hi everybody" | ||
}, | ||
{ | ||
"type": "contact_groups_changed", | ||
"created_on": "2018-10-18T14:20:30.000123456Z", | ||
|
@@ -289,8 +298,7 @@ | |
"topic": { | ||
"uuid": "0d9a2c56-6fc2-4f27-93c5-a6322e26b740", | ||
"name": "General" | ||
}, | ||
"note": "Last message: Hi everybody" | ||
} | ||
} | ||
}, | ||
"templates": [ | ||
|
@@ -333,10 +341,15 @@ | |
"assignee": { | ||
"email": "[email protected]", | ||
"name": "Jim" | ||
}, | ||
"note": "Last message: Hi everybody" | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "ticket_note_added", | ||
"created_on": "2018-10-18T14:20:30.000123456Z", | ||
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c", | ||
"note": "Last message: Hi everybody" | ||
}, | ||
{ | ||
"type": "contact_groups_changed", | ||
"created_on": "2018-10-18T14:20:30.000123456Z", | ||
|
@@ -397,8 +410,7 @@ | |
"assignee": { | ||
"email": "[email protected]", | ||
"name": "Jim" | ||
}, | ||
"note": "Last message: Hi everybody" | ||
} | ||
} | ||
}, | ||
"templates": [ | ||
|
@@ -450,10 +462,15 @@ | |
"topic": { | ||
"uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", | ||
"name": "Weather" | ||
}, | ||
"note": "Last message: Hi everybody" | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "ticket_note_added", | ||
"created_on": "2018-10-18T14:20:30.000123456Z", | ||
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c", | ||
"note": "Last message: Hi everybody" | ||
}, | ||
{ | ||
"type": "contact_groups_changed", | ||
"created_on": "2018-10-18T14:20:30.000123456Z", | ||
|
@@ -510,8 +527,7 @@ | |
"topic": { | ||
"uuid": "472a7a73-96cb-4736-b567-056d987cc5b4", | ||
"name": "Weather" | ||
}, | ||
"note": "Last message: Hi everybody" | ||
} | ||
} | ||
}, | ||
"templates": [ | ||
|
@@ -558,10 +574,15 @@ | |
"topic": { | ||
"uuid": "0d9a2c56-6fc2-4f27-93c5-a6322e26b740", | ||
"name": "General" | ||
}, | ||
"note": "Where are my cookies? " | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "ticket_note_added", | ||
"created_on": "2018-10-18T14:20:30.000123456Z", | ||
"step_uuid": "59d74b86-3e2f-4a93-aece-b05d2fdcde0c", | ||
"note": "Where are my cookies? " | ||
}, | ||
{ | ||
"type": "contact_groups_changed", | ||
"created_on": "2018-10-18T14:20:30.000123456Z", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ func TestEventMarshaling(t *testing.T) { | |
weather := session.Assets().Topics().Get("472a7a73-96cb-4736-b567-056d987cc5b4") | ||
user := session.Assets().Users().Get("[email protected]") | ||
facebook := session.Assets().Channels().Get("4bb288a0-7fca-4da1-abe8-59a593aff648") | ||
ticket := flows.NewTicket("7481888c-07dd-47dc-bf22-ef7448696ffe", weather, user, "this is weird") | ||
ticket := flows.NewTicket("7481888c-07dd-47dc-bf22-ef7448696ffe", weather, user) | ||
|
||
eventTests := []struct { | ||
event flows.Event | ||
|
@@ -610,6 +610,14 @@ func TestEventMarshaling(t *testing.T) { | |
} | ||
}`, | ||
}, | ||
{ | ||
events.NewTicketNoteAdded("this is weird"), | ||
`{ | ||
"type": "ticket_note_added", | ||
"created_on": "2018-10-18T14:20:30.000123456Z", | ||
"note": "this is weird" | ||
}`, | ||
}, | ||
{ | ||
events.NewTicketOpened(ticket), | ||
`{ | ||
|
@@ -624,8 +632,7 @@ func TestEventMarshaling(t *testing.T) { | |
"assignee": { | ||
"email": "[email protected]", | ||
"name": "Bob" | ||
}, | ||
"note": "this is weird" | ||
} | ||
} | ||
}`, | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package events | ||
|
||
import ( | ||
"github.com/nyaruka/goflow/flows" | ||
) | ||
|
||
func init() { | ||
registerType(TypeTicketNoteAdded, func() flows.Event { return &TicketNoteAddedEvent{} }) | ||
} | ||
|
||
// TypeTicketNoteAdded is the type for our ticket note added events | ||
const TypeTicketNoteAdded string = "ticket_note_added" | ||
|
||
// TicketNoteAddedEvent events are created when a note is added to the currently open ticket. | ||
// | ||
// { | ||
// "type": "ticket_note_added", | ||
// "created_on": "2006-01-02T15:04:05Z", | ||
// "note": "this is weird" | ||
// } | ||
// | ||
// @event ticket_note_added | ||
type TicketNoteAddedEvent struct { | ||
BaseEvent | ||
|
||
Note string `json:"note"` | ||
} | ||
|
||
// NewTicketNoteAdded returns a new ticket note added event | ||
func NewTicketNoteAdded(note string) *TicketNoteAddedEvent { | ||
return &TicketNoteAddedEvent{ | ||
BaseEvent: NewBaseEvent(TypeTicketNoteAdded), | ||
Note: note, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ type Ticket struct { | |
UUID flows.TicketUUID `json:"uuid" validate:"required,uuid4"` | ||
Topic *assets.TopicReference `json:"topic" validate:"omitempty"` | ||
Assignee *assets.UserReference `json:"assignee,omitempty" validate:"omitempty"` | ||
Note string `json:"note,omitempty"` | ||
} | ||
|
||
// TicketOpenedEvent events are created when a new ticket is opened. | ||
|
@@ -30,8 +29,7 @@ type Ticket struct { | |
// "uuid": "add17edf-0b6e-4311-bcd7-a64b2a459157", | ||
// "name": "Weather" | ||
// }, | ||
// "assignee": {"email": "[email protected]", "name": "Bob"}, | ||
// "note": "this is weird" | ||
// "assignee": {"email": "[email protected]", "name": "Bob"} | ||
// } | ||
// } | ||
// | ||
|
@@ -50,7 +48,6 @@ func NewTicketOpened(ticket *flows.Ticket) *TicketOpenedEvent { | |
UUID: ticket.UUID(), | ||
Topic: ticket.Topic().Reference(), | ||
Assignee: ticket.Assignee().Reference(), | ||
Note: ticket.Note(), | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,8 +35,7 @@ | |
"assignee": { | ||
"email": "[email protected]", | ||
"name": "Bob" | ||
}, | ||
"note": "this is a note" | ||
} | ||
} | ||
}, | ||
"events": [ | ||
|
@@ -52,9 +51,13 @@ | |
"assignee": { | ||
"email": "[email protected]", | ||
"name": "Bob" | ||
}, | ||
"note": "this is a note" | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "ticket_note_added", | ||
"created_on": "2018-10-18T14:20:30.000123456Z", | ||
"note": "this is a note" | ||
} | ||
] | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.