diff --git a/core/handlers/ticket_opened_test.go b/core/handlers/ticket_opened_test.go index cb0c06dec..5f7941857 100644 --- a/core/handlers/ticket_opened_test.go +++ b/core/handlers/ticket_opened_test.go @@ -32,10 +32,10 @@ func TestTicketOpened(t *testing.T) { "message": "Queued. Thank you." }`), }, - "https://nyaruka.zendesk.com/api/v2/users/search?external_id=b699a406-7e44-49be-9f01-1a82893e8a10": { + "https://nyaruka.zendesk.com/api/v2/users/search.json?external_id=b699a406-7e44-49be-9f01-1a82893e8a10": { httpx.NewMockResponse(200, nil, `{"users": []}`), }, - "https://nyaruka.zendesk.com/api/v2/users": { + "https://nyaruka.zendesk.com/api/v2/users.json": { httpx.NewMockResponse(201, nil, `{ "user": { "id": 9873843, diff --git a/services/tickets/zendesk/client.go b/services/tickets/zendesk/client.go index 0c5d3aaac..31e9d274f 100644 --- a/services/tickets/zendesk/client.go +++ b/services/tickets/zendesk/client.go @@ -335,7 +335,7 @@ func (c *RESTClient) CreateUser(user *User) (*User, *httpx.Trace, error) { User *User `json:"user"` }{} - trace, err := c.post("users", payload, response) + trace, err := c.post("users.json", payload, response) if err != nil { return nil, trace, err } @@ -349,7 +349,7 @@ type SearchUserResponse struct { // SearchUser returns the user with the given external ID or nil if it doesn't exist func (c *RESTClient) SearchUser(externalID string) (*User, *httpx.Trace, error) { - endpoint := fmt.Sprintf("users/search?external_id=%s", externalID) + endpoint := fmt.Sprintf("users/search.json?external_id=%s", externalID) var response SearchUserResponse trace, err := c.get(endpoint, nil, &response) if err != nil { diff --git a/services/tickets/zendesk/client_test.go b/services/tickets/zendesk/client_test.go index 2dd46e82a..2391faa99 100644 --- a/services/tickets/zendesk/client_test.go +++ b/services/tickets/zendesk/client_test.go @@ -271,7 +271,7 @@ func TestPush(t *testing.T) { func TestCreateUser(t *testing.T) { defer httpx.SetRequestor(httpx.DefaultRequestor) httpx.SetRequestor(httpx.NewMockRequestor(map[string][]httpx.MockResponse{ - "https://mocked_subdomain.zendesk.com/api/v2/users": { + "https://mocked_subdomain.zendesk.com/api/v2/users.json": { httpx.MockConnectionError, httpx.NewMockResponse(400, nil, `{"description": "Something went wrong", "error": "Unknown"}`), httpx.NewMockResponse(201, nil, `{ @@ -313,7 +313,7 @@ func TestSearchUser(t *testing.T) { userUUID := "9a327960-b2ce-4659-bef7-87cbb837a154" httpx.SetRequestor(httpx.NewMockRequestor(map[string][]httpx.MockResponse{ - fmt.Sprintf("https://mocked_subdomain.zendesk.com/api/v2/users/search?external_id=%s", userUUID): { + fmt.Sprintf("https://mocked_subdomain.zendesk.com/api/v2/users/search.json?external_id=%s", userUUID): { httpx.MockConnectionError, httpx.NewMockResponse(400, nil, `{"description": "Something went wrong", "error": "Unknown"}`), httpx.NewMockResponse(200, nil, `{"users": []}`), diff --git a/services/tickets/zendesk/service_test.go b/services/tickets/zendesk/service_test.go index b4ebb2b72..9b775e8cf 100644 --- a/services/tickets/zendesk/service_test.go +++ b/services/tickets/zendesk/service_test.go @@ -41,7 +41,7 @@ func TestOpenAndForward(t *testing.T) { uuids.SetGenerator(uuids.NewSeededGenerator(12345)) dates.SetNowSource(dates.NewSequentialNowSource(time.Date(2019, 10, 7, 15, 21, 30, 0, time.UTC))) httpx.SetRequestor(httpx.NewMockRequestor(map[string][]httpx.MockResponse{ - "https://nyaruka.zendesk.com/api/v2/users/search?external_id=5d76d86b-3bb9-4d5a-b822-c9d86f5d8e4f": { + "https://nyaruka.zendesk.com/api/v2/users/search.json?external_id=5d76d86b-3bb9-4d5a-b822-c9d86f5d8e4f": { httpx.NewMockResponse(200, nil, `{"users": [{"id": 35241, "name": "Dummy User"}], "count": 1, "next_page": "https://nyaruka.zendesk.com/api/v2/users.json?page=2"}`), httpx.NewMockResponse(200, nil, `{"users": [{"id": 35241, "name": "Dummy User"}], "count": 1, "next_page": "https://nyaruka.zendesk.com/api/v2/users.json?page=2"}`), httpx.NewMockResponse(200, nil, `{"users": [{"id": 35241, "name": "Dummy User"}], "count": 1, "next_page": "https://nyaruka.zendesk.com/api/v2/users.json?page=2"}`),