Skip to content

Commit

Permalink
tickets/zendesk: fix client users endpoints to end with .json
Browse files Browse the repository at this point in the history
  • Loading branch information
rasoro committed Aug 4, 2023
1 parent 830c092 commit 757e11d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions core/handlers/ticket_opened_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions services/tickets/zendesk/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions services/tickets/zendesk/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, `{
Expand Down Expand Up @@ -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": []}`),
Expand Down
2 changes: 1 addition & 1 deletion services/tickets/zendesk/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}`),
Expand Down

0 comments on commit 757e11d

Please sign in to comment.