From 3e341954e854f1d44cb2b8c59ee6c10eed7c89a3 Mon Sep 17 00:00:00 2001 From: Nicolas Lopes Date: Wed, 18 Sep 2024 13:01:04 -0300 Subject: [PATCH] refactor: ensure the same pattern is being followed --- organization_domain.go | 6 +++--- organizationdomain/api.go | 4 ++-- organizationdomain/client.go | 6 ++++-- organizationdomain/client_test.go | 8 +++++--- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/organization_domain.go b/organization_domain.go index 2cd6f6e..e2e0c23 100644 --- a/organization_domain.go +++ b/organization_domain.go @@ -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"` } @@ -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"` } diff --git a/organizationdomain/api.go b/organizationdomain/api.go index b0ab04e..2674f7e 100644 --- a/organizationdomain/api.go +++ b/organizationdomain/api.go @@ -14,8 +14,8 @@ func Create(ctx context.Context, organizationID string, params *CreateParams) (* } // Update updates an organization domain. -func Update(ctx context.Context, organizationID, domainID string, params *UpdateParams) (*clerk.OrganizationDomain, error) { - return getClient().Update(ctx, organizationID, domainID, params) +func Update(ctx context.Context, params *UpdateParams) (*clerk.OrganizationDomain, error) { + return getClient().Update(ctx, params) } // Delete removes a domain from an organization. diff --git a/organizationdomain/client.go b/organizationdomain/client.go index 514f9cc..5fdc5ba 100644 --- a/organizationdomain/client.go +++ b/organizationdomain/client.go @@ -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 } diff --git a/organizationdomain/client_test.go b/organizationdomain/client_test.go index 45c65da..b5ba96b 100644 --- a/organizationdomain/client_test.go +++ b/organizationdomain/client_test.go @@ -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) @@ -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)