Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for 'omitempty' issue #218

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions zendesk/mock/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion zendesk/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
36 changes: 18 additions & 18 deletions zendesk/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
10 changes: 5 additions & 5 deletions zendesk/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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")
}
}
Expand All @@ -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")
}
}
Expand All @@ -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")
}
}
Expand Down Expand Up @@ -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)
}
}
Expand Down