diff --git a/zendesk/mock/client.go b/zendesk/mock/client.go index 196c5e4e..4c1b99e2 100644 --- a/zendesk/mock/client.go +++ b/zendesk/mock/client.go @@ -155,6 +155,21 @@ func (mr *ClientMockRecorder) CreateMacro(arg0, arg1 interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateMacro", reflect.TypeOf((*Client)(nil).CreateMacro), arg0, arg1) } +// CreateOrUpdateUser mocks base method. +func (m *Client) CreateOrUpdateUser(arg0 context.Context, arg1 zendesk.User) (zendesk.User, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "CreateOrUpdateUser", arg0, arg1) + ret0, _ := ret[0].(zendesk.User) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// CreateOrUpdateUser indicates an expected call of CreateOrUpdateUser. +func (mr *ClientMockRecorder) CreateOrUpdateUser(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateOrUpdateUser", reflect.TypeOf((*Client)(nil).CreateOrUpdateUser), arg0, arg1) +} + // CreateOrganization mocks base method. func (m *Client) CreateOrganization(arg0 context.Context, arg1 zendesk.Organization) (zendesk.Organization, error) { m.ctrl.T.Helper() @@ -284,15 +299,6 @@ func (m *Client) CreateUser(arg0 context.Context, arg1 zendesk.User) (zendesk.Us return ret0, ret1 } -// CreateOrUpdateUser mocks base method. -func (m *Client) CreateOrUpdateUser(arg0 context.Context, arg1 zendesk.User) (zendesk.User, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "CreateOrUpdateUser", arg0, arg1) - ret0, _ := ret[0].(zendesk.User) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - // CreateUser indicates an expected call of CreateUser. func (mr *ClientMockRecorder) CreateUser(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() diff --git a/zendesk/search_test.go b/zendesk/search_test.go index 29422ba9..9683456f 100644 --- a/zendesk/search_test.go +++ b/zendesk/search_test.go @@ -105,7 +105,7 @@ func TestSearchUser(t *testing.T) { t.Fatalf("Cannot assert %v as a user", list[0]) } - if result.ID != 1234 { + if *result.ID != 1234 { t.Fatalf("Group did not have the expected id %v", result) } } diff --git a/zendesk/user.go b/zendesk/user.go index e76e22c3..22ba4ab1 100644 --- a/zendesk/user.go +++ b/zendesk/user.go @@ -13,41 +13,41 @@ type UserFields map[string]interface{} // User is zendesk user JSON payload format // https://developer.zendesk.com/rest_api/docs/support/users type User struct { - ID int64 `json:"id,omitempty"` + ID *int64 `json:"id,omitempty"` URL string `json:"url,omitempty"` Email string `json:"email,omitempty"` Name string `json:"name"` - Active bool `json:"active,omitempty"` + Active *bool `json:"active,omitempty"` Alias string `json:"alias,omitempty"` - ChatOnly bool `json:"chat_only,omitempty"` - CustomRoleID int64 `json:"custom_role_id,omitempty"` - DefaultGroupID int64 `json:"default_group_id,omitempty"` + ChatOnly *bool `json:"chat_only,omitempty"` + CustomRoleID *int64 `json:"custom_role_id,omitempty"` + DefaultGroupID *int64 `json:"default_group_id,omitempty"` Details string `json:"details,omitempty"` ExternalID string `json:"external_id,omitempty"` IanaTimezone string `json:"iana_time_zone,omitempty"` Locale string `json:"locale,omitempty"` - LocaleID int64 `json:"locale_id,omitempty"` - Moderator bool `json:"moderator,omitempty"` + LocaleID *int64 `json:"locale_id,omitempty"` + Moderator *bool `json:"moderator,omitempty"` Notes string `json:"notes,omitempty"` - OnlyPrivateComments bool `json:"only_private_comments,omitempty"` - OrganizationID int64 `json:"organization_id,omitempty"` + OnlyPrivateComments *bool `json:"only_private_comments,omitempty"` + OrganizationID *int64 `json:"organization_id,omitempty"` Phone string `json:"phone,omitempty"` Photo Attachment `json:"photo,omitempty"` - RestrictedAgent bool `json:"restricted_agent,omitempty"` + RestrictedAgent *bool `json:"restricted_agent,omitempty"` Role string `json:"role,omitempty"` - RoleType int64 `json:"role_type,omitempty"` - Shared bool `json:"shared,omitempty"` - SharedAgent bool `json:"shared_agent,omitempty"` - SharedPhoneNumber bool `json:"shared_phone_number,omitempty"` + RoleType *int64 `json:"role_type,omitempty"` + Shared *bool `json:"shared,omitempty"` + SharedAgent *bool `json:"shared_agent,omitempty"` + SharedPhoneNumber *bool `json:"shared_phone_number,omitempty"` Signature string `json:"signature,omitempty"` - Suspended bool `json:"suspended,omitempty"` + Suspended *bool `json:"suspended,omitempty"` Tags []string `json:"tags,omitempty"` TicketRestriction string `json:"ticket_restriction,omitempty"` Timezone string `json:"time_zone,omitempty"` - TwoFactorAuthEnabled bool `json:"two_factor_auth_enabled,omitempty"` + TwoFactorAuthEnabled *bool `json:"two_factor_auth_enabled,omitempty"` UserFields UserFields `json:"user_fields"` - Verified bool `json:"verified,omitempty"` - ReportCSV bool `json:"report_csv,omitempty"` + Verified *bool `json:"verified,omitempty"` + ReportCSV *bool `json:"report_csv,omitempty"` LastLoginAt time.Time `json:"last_login_at,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` UpdatedAt time.Time `json:"updated_at,omitempty"` diff --git a/zendesk/user_test.go b/zendesk/user_test.go index eb51c4a4..f7b16f3a 100644 --- a/zendesk/user_test.go +++ b/zendesk/user_test.go @@ -56,7 +56,7 @@ func TestGetUser(t *testing.T) { } expectedID := int64(369531345753) - if user.ID != expectedID { + if *user.ID != expectedID { t.Fatalf("Returned user does not have the expected ID %d. User id is %d", expectedID, user.ID) } } @@ -110,7 +110,7 @@ func TestCreateUser(t *testing.T) { if err != nil { t.Fatalf("Failed to get valid response: %s", err) } - if user.ID == 0 { + if *user.ID == 0 { t.Fatal("Failed to create user") } } @@ -127,7 +127,7 @@ func TestCreateOrUpdateUserCreated(t *testing.T) { if err != nil { t.Fatalf("Failed to get valid response: %s", err) } - if user.ID == 0 { + if *user.ID == 0 { t.Fatal("Failed to create or update user") } } @@ -144,7 +144,7 @@ func TestCreateOrUpdateUserUpdated(t *testing.T) { if err != nil { t.Fatalf("Failed to get valid response: %s", err) } - if user.ID == 0 { + if *user.ID == 0 { t.Fatal("Failed to create or update user") } } @@ -172,7 +172,7 @@ func TestUpdateUser(t *testing.T) { } expectedID := int64(369531345753) - if user.ID != expectedID { + if *user.ID != expectedID { t.Fatalf("Returned user does not have the expected ID %d. User id is %d", expectedID, user.ID) } }