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: Add block_disposable_emails param #163

Merged
merged 2 commits into from
Sep 26, 2023
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
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
Loading