From 6ac80cddafb2d0fe9a84dbdf4d004f7956ac0576 Mon Sep 17 00:00:00 2001 From: Sokratis Vidros Date: Fri, 1 Sep 2023 17:31:45 +0300 Subject: [PATCH] feat: Add block_disposable_emails param --- clerk/instances.go | 16 +++++++++------- clerk/instances_test.go | 13 ++++++++----- tests/integration/instances_test.go | 1 + 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/clerk/instances.go b/clerk/instances.go index 6611d7e6..6322f41c 100644 --- a/clerk/instances.go +++ b/clerk/instances.go @@ -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) { diff --git a/clerk/instances_test.go b/clerk/instances_test.go index 0d3f4bec..5e1560a2 100644 --- a/clerk/instances_test.go +++ b/clerk/instances_test.go @@ -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() @@ -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) diff --git a/tests/integration/instances_test.go b/tests/integration/instances_test.go index bf15aeb7..cbf066c4 100644 --- a/tests/integration/instances_test.go +++ b/tests/integration/instances_test.go @@ -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) {