Skip to content

Commit

Permalink
refactor: ensure the same pattern is being followed
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasLopes7 committed Sep 18, 2024
1 parent 955d1b8 commit 3e34195
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
6 changes: 3 additions & 3 deletions organization_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package clerk
type OrganizationDomainVerification struct {
Status string `json:"status"`
Strategy string `json:"strategy"`
Attempts *int `json:"attempts"`
Attempts int64 `json:"attempts"`
ExpireAt *int64 `json:"expire_at"`
}

Expand All @@ -16,8 +16,8 @@ type OrganizationDomain struct {
EnrollmentMode string `json:"enrollment_mode"`
AffiliationEmailAddress *string `json:"affiliation_email_address"`
Verification *OrganizationDomainVerification `json:"verification"`
TotalPendingInvitations int `json:"total_pending_invitations"`
TotalPendingSuggestions int `json:"total_pending_suggestions"`
TotalPendingInvitations int64 `json:"total_pending_invitations"`
TotalPendingSuggestions int64 `json:"total_pending_suggestions"`
CreatedAt int64 `json:"created_at"`
UpdatedAt int64 `json:"updated_at"`
}
Expand Down
4 changes: 2 additions & 2 deletions organizationdomain/api.go

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

6 changes: 4 additions & 2 deletions organizationdomain/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ func (c *Client) Create(ctx context.Context, organizationID string, params *Crea

type UpdateParams struct {
clerk.APIParams
OrganizationID string `json:"-"`
DomainID string `json:"-"`
EnrollmentMode *string `json:"enrollment_mode,omitempty"`
Verified *bool `json:"verified,omitempty"`
}

// Update updates an organization domain.
func (c *Client) Update(ctx context.Context, organizationID, domainID string, params *UpdateParams) (*clerk.OrganizationDomain, error) {
path, err := clerk.JoinPath(path, organizationID, "/domains", domainID)
func (c *Client) Update(ctx context.Context, params *UpdateParams) (*clerk.OrganizationDomain, error) {
path, err := clerk.JoinPath(path, params.OrganizationID, "/domains", params.DomainID)
if err != nil {
return nil, err
}
Expand Down
8 changes: 5 additions & 3 deletions organizationdomain/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ func TestOrganizationDomainClientUpdate(t *testing.T) {
},
}
client := NewClient(config)
domain, err := client.Update(context.Background(), organizationID, id, &UpdateParams{
Verified: clerk.Bool(verified),
domain, err := client.Update(context.Background(), &UpdateParams{
OrganizationID: organizationID,
DomainID: id,
Verified: clerk.Bool(verified),
})
require.NoError(t, err)
require.Equal(t, id, domain.ID)
Expand All @@ -109,7 +111,7 @@ func TestOrganizationDomainClientUpdate_Error(t *testing.T) {
},
}
client := NewClient(config)
_, err := client.Update(context.Background(), "org_123", "orgdm_123", &UpdateParams{})
_, err := client.Update(context.Background(), &UpdateParams{})
require.Error(t, err)
apiErr, ok := err.(*clerk.APIErrorResponse)
require.True(t, ok)
Expand Down

0 comments on commit 3e34195

Please sign in to comment.