Skip to content

Commit

Permalink
feat: Add block_disposable_emails param
Browse files Browse the repository at this point in the history
  • Loading branch information
SokratisVidros committed Sep 26, 2023
1 parent 7c24fcd commit c5b7ccf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
16 changes: 9 additions & 7 deletions clerk/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,18 @@ func (s *InstanceService) Update(params UpdateInstanceParams) error {
}

type InstanceRestrictionsResponse struct {
Object string `json:"object"`
Allowlist bool `json:"allowlist"`
Blocklist bool `json:"blocklist"`
BlockEmailSubaddresses bool `json:"block_email_subaddresses"`
Object string `json:"object"`
Allowlist bool `json:"allowlist"`
Blocklist bool `json:"blocklist"`
BlockEmailSubaddresses bool `json:"block_email_subaddresses"`
BlockDisposableEmailDomains bool `json:"block_disposable_email_domains"`
}

type UpdateRestrictionsParams struct {
Allowlist *bool `json:"allowlist,omitempty"`
Blocklist *bool `json:"blocklist,omitempty"`
BlockEmailSubaddresses *bool `json:"block_email_subaddresses,omitempty"`
Allowlist *bool `json:"allowlist,omitempty"`
Blocklist *bool `json:"blocklist,omitempty"`
BlockEmailSubaddresses *bool `json:"block_email_subaddresses,omitempty"`
BlockDisposableEmailDomains *bool `json:"block_disposable_email_domains,omitempty"`
}

func (s *InstanceService) UpdateRestrictions(params UpdateRestrictionsParams) (*InstanceRestrictionsResponse, error) {
Expand Down
13 changes: 8 additions & 5 deletions clerk/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ func TestInstanceService_UpdateRestrictions_happyPath(t *testing.T) {
dummyRestrictionsResponseJSON := `{
"allowlist": true,
"blocklist": true,
"block_email_subaddresses": true
"block_email_subaddresses": true,
"block_disposable_email_domains": true
}`
var restrictionsResponse InstanceRestrictionsResponse
_ = json.Unmarshal([]byte(dummyRestrictionsResponseJSON), &restrictionsResponse)
err := json.Unmarshal([]byte(dummyRestrictionsResponseJSON), &restrictionsResponse)
assert.NoError(t, err)

client, mux, _, teardown := setup(token)
defer teardown()
Expand All @@ -75,9 +77,10 @@ func TestInstanceService_UpdateRestrictions_happyPath(t *testing.T) {

enabled := true
got, _ := client.Instances().UpdateRestrictions(UpdateRestrictionsParams{
Allowlist: &enabled,
Blocklist: &enabled,
BlockEmailSubaddresses: &enabled,
Allowlist: &enabled,
Blocklist: &enabled,
BlockEmailSubaddresses: &enabled,
BlockDisposableEmailDomains: &enabled,
})

assert.Equal(t, &restrictionsResponse, got)
Expand Down
1 change: 1 addition & 0 deletions tests/integration/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestInstanceRestrictions(t *testing.T) {
assert.True(t, restrictionsResponse.Allowlist)
assert.True(t, restrictionsResponse.Blocklist)
assert.False(t, restrictionsResponse.BlockEmailSubaddresses)
assert.False(t, restrictionsResponse.BlockDisposableEmailDomains)
}

func TestInstanceOrganizationSettings(t *testing.T) {
Expand Down

0 comments on commit c5b7ccf

Please sign in to comment.