Repository: mailgun/mailgun-go
Pull request #378 (2025-01-03 18:54:54)

DE-1383 Move the API version out of the base URL 2


Patch:
diff --git a/README.md b/README.md
index aa7cbcd..50c42d7 100644
--- a/README.md
+++ b/README.md
@@ -37,7 +37,7 @@ var privateAPIKey = "your-private-key"
 func main() {
 	// Create an instance of the Mailgun Client
 	mg := mailgun.NewMailgun(privateAPIKey)
-	
+
 	// When you have an EU domain, you must specify the endpoint:
 	// err := mg.SetAPIBase(mailgun.APIBaseEU)
 
diff --git a/analytics.go b/analytics.go
index 25d5271..41e0053 100644
--- a/analytics.go
+++ b/analytics.go
@@ -29,9 +29,6 @@ type MetricsPagination struct {
 //		LabeledValues: []mailgun.MetricsLabeledValue{{Label: "example.com", Value: "example.com"}},
 //	}}
 //
-// NOTE: Only for v1 API. To use the /v1 version define MG_URL in the environment variable
-// as `https://api.mailgun.net/v1` or set `mg.SetAPIBase("https://api.mailgun.net/v1")`
-//
 // https://documentation.mailgun.com/docs/mailgun/api-reference/openapi-final/tag/Metrics/
 func (mg *MailgunImpl) ListMetrics(opts MetricsOptions) (*MetricsIterator, error) {
 	if opts.Pagination.Limit == 0 {
diff --git a/mock_validation.go b/mock_validation.go
index c42fce3..1a034d5 100644
--- a/mock_validation.go
+++ b/mock_validation.go
@@ -9,10 +9,6 @@ import (
 )
 
 func (ms *mockServer) addValidationRoutes(r chi.Router) {
-	r.Get("/v3/address/validate", ms.validateEmail)
-	r.Get("/v3/address/parse", ms.parseEmail)
-	r.Get("/v3/address/private/validate", ms.validateEmail)
-	r.Get("/v3/address/private/parse", ms.parseEmail)
 	r.Get("/v4/address/validate", ms.validateEmailV4)
 }
 
@@ -41,44 +37,3 @@ func (ms *mockServer) validateEmailV4(w http.ResponseWriter, r *http.Request) {
 	}
 	toJSON(w, results)
 }
-
-func (ms *mockServer) validateEmail(w http.ResponseWriter, r *http.Request) {
-	if r.FormValue("address") == "" {
-		w.WriteHeader(http.StatusBadRequest)
-		toJSON(w, okResp{Message: "'address' parameter is required"})
-		return
-	}
-
-	var results EmailVerification
-	parts, err := mail.ParseAddress(r.FormValue("address"))
-	if err == nil {
-		results.IsValid = true
-		results.Parts.Domain = strings.Split(parts.Address, "@")[1]
-		results.Parts.LocalPart = strings.Split(parts.Address, "@")[0]
-		results.Parts.DisplayName = parts.Name
-	}
-	results.Reason = "no-reason"
-	results.Risk = "unknown"
-	toJSON(w, results)
-}
-
-func (ms *mockServer) parseEmail(w http.ResponseWriter, r *http.Request) {
-	if r.FormValue("addresses") == "" {
-		w.WriteHeader(http.StatusBadRequest)
-		toJSON(w, okResp{Message: "'addresses' parameter is required"})
-		return
-	}
-
-	addresses := strings.Split(r.FormValue("addresses"), ",")
-
-	var results addressParseResult
-	for _, address := range addresses {
-		_, err := mail.ParseAddress(address)
-		if err != nil {
-			results.Unparseable = append(results.Unparseable, address)
-		} else {
-			results.Parsed = append(results.Parsed, address)
-		}
-	}
-	toJSON(w, results)
-}


Test patch:
diff --git a/email_validation_test.go b/email_validation_test.go
index 2049bd1..f6bd54d 100644
--- a/email_validation_test.go
+++ b/email_validation_test.go
@@ -12,7 +12,6 @@ import (
 
 func TestEmailValidationV4(t *testing.T) {
 	v := mailgun.NewEmailValidator(testKey)
-	// API Base is set to `http://server/v4`
 	v.SetAPIBase(server.URL())
 
 	ctx := context.Background()