Skip to content

Commit 2792b79

Browse files
Add missing sub statuses: gold, role_based_accept_all, alternate, mx_forward, blocked, allowed
- Added SS_GOLD, SS_ROLE_BASED_ACCEPT_ALL, SS_ALTERNATE, SS_MX_FORWARD, SS_BLOCKED, SS_ALLOWED constants - Added test cases for gold and role_based_accept_all sub statuses - Added mock responses for gold@example.com and role_based_accept_all@example.com - Added standalone test functions TestResponseSubStatusGold and TestResponseSubStatusRoleBasedAcceptAll - Added API usage tracking fields for alternate, blocked, allowed, and gold sub statuses - Added test assertions for new API usage fields - Ensures 100% parity with Python SDK sub status support
1 parent 0224b9d commit 2792b79

File tree

5 files changed

+87
-0
lines changed

5 files changed

+87
-0
lines changed

api.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ type ApiUsageResponse struct {
116116
SubStatusAcceptAll int `json:"sub_status_accept_all"`
117117
// Total number times the API has a sub status "mx_forward"
118118
SubStatusMxForward int `json:"sub_status_mx_forward"`
119+
// Total number of times the API has a sub status of "alternate"
120+
SubStatusAlternate int `json:"sub_status_alternate"`
121+
// Total number of times the API has a sub status of "blocked"
122+
SubStatusBlocked int `json:"sub_status_blocked"`
123+
// Total number of times the API has a sub status of "allowed"
124+
SubStatusAllowed int `json:"sub_status_allowed"`
125+
// Total number of times the API has a sub status of "gold"
126+
SubStatusGold int `json:"sub_status_gold"`
119127
// Start date of query.
120128
RawStartDate string `json:"start_date"`
121129
// End date of query.

api_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ func TestApiUsageOk(t *testing.T) {
154154
assert.NotEqual(t, api_usage.SubStatusFailedSmtpConnection, 0)
155155
assert.NotEqual(t, api_usage.SubStatusAcceptAll, 0)
156156
assert.NotEqual(t, api_usage.SubStatusMxForward, 0)
157+
assert.NotEqual(t, api_usage.SubStatusAlternate, 0)
158+
assert.NotEqual(t, api_usage.SubStatusBlocked, 0)
159+
assert.NotEqual(t, api_usage.SubStatusAllowed, 0)
157160

158161
expected_start := time.Date(2023, 1, 1, 0, 0, 0, 0, time.Local)
159162
expected_end := time.Date(2023, 12, 12, 0, 0, 0, 0, time.Local)

mocking_validation_content.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,48 @@ var MOCK_VALIDATE_RESPONSE = map[string]string{
589589
"zipcode": "33401",
590590
"processed_at": "2023-03-23 12:30:32.095"
591591
}`,
592+
"gold@example.com": `{
593+
"address": "gold@example.com",
594+
"status": "valid",
595+
"sub_status": "gold",
596+
"free_email": false,
597+
"did_you_mean": null,
598+
"account": null,
599+
"domain": null,
600+
"domain_age_days": "9692",
601+
"smtp_provider": "example",
602+
"mx_found": "true",
603+
"mx_record": "mx.example.com",
604+
"firstname": "zero",
605+
"lastname": "bounce",
606+
"gender": "male",
607+
"country": "United States",
608+
"region": "Florida",
609+
"city": "West Palm Beach",
610+
"zipcode": "33401",
611+
"processed_at": "2023-03-23 12:30:32.095"
612+
}`,
613+
"role_based_accept_all@example.com": `{
614+
"address": "role_based_accept_all@example.com",
615+
"status": "valid",
616+
"sub_status": "role_based_accept_all",
617+
"free_email": false,
618+
"did_you_mean": null,
619+
"account": null,
620+
"domain": null,
621+
"domain_age_days": "9692",
622+
"smtp_provider": "example",
623+
"mx_found": "true",
624+
"mx_record": "mx.example.com",
625+
"firstname": "zero",
626+
"lastname": "bounce",
627+
"gender": "male",
628+
"country": "United States",
629+
"region": "Florida",
630+
"city": "West Palm Beach",
631+
"zipcode": "33401",
632+
"processed_at": "2023-03-23 12:30:32.095"
633+
}`,
592634
"role_based_catch_all@example.com": `{
593635
"address": "role_based_catch_all@example.com",
594636
"status": "do_not_mail",

utility.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,15 @@ const (
7474
SS_DOES_NOT_ACCEPT_MAIL = "does_not_accept_mail"
7575
SS_ALIAS_ADDRESS = "alias_address"
7676
SS_ROLE_BASED_CATCH_ALL = "role_based_catch_all"
77+
SS_ROLE_BASED_ACCEPT_ALL = "role_based_accept_all"
7778
SS_DISPOSABLE = "disposable"
7879
SS_TOXIC = "toxic"
7980
SS_ACCEPT_ALL = "accept_all"
81+
SS_ALTERNATE = "alternate"
82+
SS_MX_FORWARD = "mx_forward"
83+
SS_BLOCKED = "blocked"
84+
SS_ALLOWED = "allowed"
85+
SS_GOLD = "gold"
8086
)
8187

8288
const (
@@ -274,6 +280,8 @@ var emailsToValidate = []SingleTest{
274280
{Email: "timeout_exceeded@example.com", Status: "unknown", SubStatus: "timeout_exceeded"},
275281
{Email: "unroutable_ip_address@example.com", Status: "invalid", SubStatus: "unroutable_ip_address"},
276282
{Email: "free_email@example.com", Status: "valid", SubStatus: "", FreeEmail: true},
283+
{Email: "gold@example.com", Status: "valid", SubStatus: "gold"},
284+
{Email: "role_based_accept_all@example.com", Status: "valid", SubStatus: "role_based_accept_all"},
277285
{Email: "role_based_catch_all@example.com", Status: "do_not_mail", SubStatus: "role_based_catch_all"},
278286
}
279287

validate_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,32 @@ func TestMockValidationOk(t *testing.T) {
124124
}
125125
}
126126

127+
func TestResponseSubStatusGold(t *testing.T) {
128+
Initialize("mock_key")
129+
httpmock.Activate()
130+
defer httpmock.DeactivateAndReset()
131+
mockValidateRequest()
132+
133+
response, error_ := ValidateWithTimeout("gold@example.com", SANDBOX_IP, "10")
134+
assert.Nil(t, error_)
135+
assert.Equal(t, "gold@example.com", response.Address)
136+
assert.Equal(t, "valid", response.Status)
137+
assert.Equal(t, "gold", response.SubStatus)
138+
}
139+
140+
func TestResponseSubStatusRoleBasedAcceptAll(t *testing.T) {
141+
Initialize("mock_key")
142+
httpmock.Activate()
143+
defer httpmock.DeactivateAndReset()
144+
mockValidateRequest()
145+
146+
response, error_ := ValidateWithTimeout("role_based_accept_all@example.com", SANDBOX_IP, "10")
147+
assert.Nil(t, error_)
148+
assert.Equal(t, "role_based_accept_all@example.com", response.Address)
149+
assert.Equal(t, "valid", response.Status)
150+
assert.Equal(t, "role_based_accept_all", response.SubStatus)
151+
}
152+
127153
func TestMockBulkValidationNoApiKey(t *testing.T) {
128154
Initialize("")
129155
httpmock.Activate()

0 commit comments

Comments
 (0)