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

feat: Allow providing the domains default role ID when updating instance's organization settings #190

Merged
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
6 changes: 4 additions & 2 deletions clerk/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,21 @@ type OrganizationSettingsResponse struct {
Object string `json:"object"`
Enabled bool `json:"enabled"`
MaxAllowedMemberships int `json:"max_allowed_memberships"`
CreatorRole string `json:"creator_role"`
AdminDeleteEnabled bool `json:"admin_delete_enabled"`
DomainsEnabled bool `json:"domains_enabled"`
DomainsEnrollmentModes []string `json:"domains_enrollment_modes"`
CreatorRole string `json:"creator_role"`
DomainsDefaultRole string `json:"domains_default_role"`
}

type UpdateOrganizationSettingsParams struct {
Enabled *bool `json:"enabled,omitempty"`
MaxAllowedMemberships *int `json:"max_allowed_memberships,omitempty"`
CreatorRoleID *string `json:"creator_role_id,omitempty"`
AdminDeleteEnabled *bool `json:"admin_delete_enabled,omitempty"`
DomainsEnabled *bool `json:"domains_enabled,omitempty"`
DomainsEnrollmentModes []string `json:"domains_enrollment_modes,omitempty"`
CreatorRoleID *string `json:"creator_role_id,omitempty"`
DomainsDefaultRoleID *string `json:"domains_default_role_id"`
}

func (s *InstanceService) UpdateOrganizationSettings(params UpdateOrganizationSettingsParams) (*OrganizationSettingsResponse, error) {
Expand Down
8 changes: 5 additions & 3 deletions clerk/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,15 @@ func TestInstanceService_UpdateOrganizationSettings_happyPath(t *testing.T) {
dummyOrganizationSettingsResponseJSON := `{
"enabled": true,
"max_allowed_memberships": 2,
"creator_role": "org:custom_admin",
"admin_delete_enabled": true,
"domains_enabled": true,
"domains_enrollment_modes": [
"manual_invitation",
"automatic_invitation",
"automatic_suggestion"
],
"creator_role": "org:custom_admin"
"domains_default_role": "org:custom_domains"
}`
var organizationSettingsResponse OrganizationSettingsResponse
_ = json.Unmarshal([]byte(dummyOrganizationSettingsResponseJSON), &organizationSettingsResponse)
Expand All @@ -127,8 +128,9 @@ func TestInstanceService_UpdateOrganizationSettings_happyPath(t *testing.T) {

enabled := true
got, _ := client.Instances().UpdateOrganizationSettings(UpdateOrganizationSettingsParams{
Enabled: &enabled,
CreatorRoleID: stringToPtr("role_2XcSZn6swGCjX59Nk0XbGer22jb"),
Enabled: &enabled,
CreatorRoleID: stringToPtr("role_2XcSZn6swGCjX59Nk0XbGer22jb"),
DomainsDefaultRoleID: stringToPtr("role_2XZCQwxfLbXOz2hoBXKFVRjwmGc"),
})

assert.Equal(t, &organizationSettingsResponse, got)
Expand Down
Loading