diff --git a/fixture/POST/ticket_fields.json b/fixture/POST/ticket_fields.json new file mode 100644 index 00000000..6a805aa6 --- /dev/null +++ b/fixture/POST/ticket_fields.json @@ -0,0 +1,26 @@ +{ + "ticket_field": { + "url": "https://example.zendesk.com/api/v2/ticket_fields/360011737434.json", + "id": 360011737434, + "type": "subject", + "title": "Subject", + "raw_title": "Subject", + "description": "", + "raw_description": "", + "position": 0, + "active": true, + "required": false, + "collapsed_for_agents": false, + "regexp_for_validation": null, + "title_in_portal": "Subject", + "raw_title_in_portal": "Subject", + "visible_in_portal": true, + "editable_in_portal": true, + "required_in_portal": true, + "tag": null, + "created_at": "2018-11-23T16:05:12Z", + "updated_at": "2018-11-24T10:54:05Z", + "removable": false, + "agent_description": null + } +} diff --git a/fixture/POST/triggers.json b/fixture/POST/triggers.json new file mode 100644 index 00000000..d33acf80 --- /dev/null +++ b/fixture/POST/triggers.json @@ -0,0 +1,43 @@ +{ + "trigger": { + "url": "https://example.zendesk.com/api/v2/triggers/360056295714.json", + "id": 360056295714, + "title": "Notify requester of received request", + "active": true, + "updated_at": "2018-11-23T16:05:14Z", + "created_at": "2018-11-23T16:05:12Z", + "actions": [ + { + "field": "notification_user", + "value": [ + "requester_id", + "[Request received]", + "Your request ({{ticket.id}}) has been received and is being reviewed by our support staff.\n\nTo add additional comments, reply to this email." + ] + } + ], + "conditions": { + "all": [ + { + "field": "update_type", + "operator": "is", + "value": "Create" + }, + { + "field": "status", + "operator": "is_not", + "value": "solved" + }, + { + "field": "ticket_is_public", + "operator": "is", + "value": "public" + } + ], + "any": [] + }, + "description": null, + "position": 0, + "raw_title": "Notify requester of received request" + } +} diff --git a/zendesk/group_test.go b/zendesk/group_test.go index 7efd447a..2a7ee71d 100644 --- a/zendesk/group_test.go +++ b/zendesk/group_test.go @@ -19,3 +19,14 @@ func TestGetGroups(t *testing.T) { t.Fatalf("expected length of groups is 1, but got %d", len(groups)) } } + +func TestCreateGroup(t *testing.T) { + mockAPI := newMockAPIWithStatus(http.MethodPost, "groups.json", http.StatusCreated) + client := newTestClient(mockAPI) + defer mockAPI.Close() + + _, err := client.CreateGroup(Group{}) + if err != nil { + t.Fatalf("Failed to send request to create group: %s", err) + } +} diff --git a/zendesk/ticket_field_test.go b/zendesk/ticket_field_test.go index 8437b288..fbf225b3 100644 --- a/zendesk/ticket_field_test.go +++ b/zendesk/ticket_field_test.go @@ -35,3 +35,14 @@ func TestGetTicketField(t *testing.T) { t.Fatalf("Returned ticket field does not have the expected ID %d. Ticket id is %d", expectedID, ticketField.ID) } } + +func TestCreateTicketField(t *testing.T) { + mockAPI := newMockAPIWithStatus(http.MethodPost, "ticket_fields.json", http.StatusCreated) + client := newTestClient(mockAPI) + defer mockAPI.Close() + + _, err := client.CreateTicketField(TicketField{}) + if err != nil { + t.Fatalf("Failed to send request to create ticket field: %s", err) + } +} diff --git a/zendesk/trigger_test.go b/zendesk/trigger_test.go index ac38fad1..d4205af1 100644 --- a/zendesk/trigger_test.go +++ b/zendesk/trigger_test.go @@ -19,3 +19,14 @@ func TestGetTriggers(t *testing.T) { t.Fatalf("expected length of triggers is , but got %d", len(triggers)) } } + +func TestCreateTrigger(t *testing.T) { + mockAPI := newMockAPIWithStatus(http.MethodPost, "triggers.json", http.StatusCreated) + client := newTestClient(mockAPI) + defer mockAPI.Close() + + _, err := client.CreateTrigger(Trigger{}) + if err != nil { + t.Fatalf("Failed to send request to create trigger: %s", err) + } +}