From 988f751a86fcb4d61e6f62083b109c885eb2a6e2 Mon Sep 17 00:00:00 2001 From: Prosper Otemuyiwa Date: Tue, 5 Sep 2023 06:46:03 +0100 Subject: [PATCH] =?UTF-8?q?Revert=20"[NV-GO-1]=20API=20=F0=9F=9A=80:=20Val?= =?UTF-8?q?idate=20MX=20Record=20Setup=20for=20Inbound=20Parse=20Functiona?= =?UTF-8?q?lity"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 - lib/inbound_parser.go | 30 ----------------------- lib/inbound_parser_test.go | 49 -------------------------------------- lib/model.go | 7 ------ lib/novu.go | 1 - 5 files changed, 88 deletions(-) delete mode 100644 lib/inbound_parser.go delete mode 100644 lib/inbound_parser_test.go diff --git a/README.md b/README.md index c97bdb0..59dba39 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,6 @@ Class | Method *IntegrationsApi* | [**Delete**](https://docs.novu.co/platform/integrations) | **Delete** /integrations/:integrationId | Delete an integration *IntegrationsApi* | [**Get**](https://docs.novu.co/platform/integrations) | **Get** /integrations | Get all integrations *IntegrationsApi* | [**GetActive**](https://docs.novu.co/platform/intergations) | **Get** /integrations/active | Get all active integrations -*InboundParserApi* | [**Get**](https://docs.novu.co/platform/inbound-parse-webhook/) | **Get** /inbound-parse/mx/status | Validate the mx record setup for the inbound parse functionality ## Authorization (api-key) diff --git a/lib/inbound_parser.go b/lib/inbound_parser.go deleted file mode 100644 index 922c42a..0000000 --- a/lib/inbound_parser.go +++ /dev/null @@ -1,30 +0,0 @@ -package lib - -import ( - "context" - "net/http" -) - -type IInboundParser interface { - Get(ctx context.Context) (*InboundParserResponse, error) -} - -type InboundParserService service - -func (i *InboundParserService) Get(ctx context.Context) (*InboundParserResponse, error) { - var resp InboundParserResponse - - URL := i.client.config.BackendURL.JoinPath("inbound-parse", "mx", "status") - - req, err := http.NewRequestWithContext(ctx, http.MethodGet, URL.String(), http.NoBody) - if err != nil { - return nil, err - } - - _, err = i.client.sendRequest(req, &resp) - if err != nil { - return nil, err - } - - return &resp, nil -} diff --git a/lib/inbound_parser_test.go b/lib/inbound_parser_test.go deleted file mode 100644 index c7e67b8..0000000 --- a/lib/inbound_parser_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package lib_test - -import ( - "context" - "encoding/json" - "net/http" - "net/http/httptest" - "strings" - "testing" - - "github.com/novuhq/go-novu/lib" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestInboundParserService_Get_Success(t *testing.T) { - var expectedResponse lib.MxRecordConfiguredStatus - - inboundParserService := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - - // Write the expected response as JSON - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - err := json.NewEncoder(w).Encode(expectedResponse) - assert.NoError(t, err) - - t.Run("Header must contain ApiKey", func(t *testing.T) { - authKey := r.Header.Get("Authorization") - assert.True(t, strings.Contains(authKey, novuApiKey)) - assert.True(t, strings.HasPrefix(authKey, "ApiKey")) - }) - - t.Run("URL and request method is as expected", func(t *testing.T) { - expectedURL := "/inbound-parse/mx/status" - assert.Equal(t, http.MethodPost, r.Method) - assert.Equal(t, expectedURL, r.RequestURI) - }) - - })) - - defer inboundParserService.Close() - - ctx := context.Background() - i := lib.NewAPIClient(novuApiKey, &lib.Config{BackendURL: lib.MustParseURL(inboundParserService.URL)}) - - _, err := i.InboundParser.Get(ctx) - - require.Nil(t, err) -} diff --git a/lib/model.go b/lib/model.go index 1b95aa0..dd8f6ea 100644 --- a/lib/model.go +++ b/lib/model.go @@ -325,10 +325,3 @@ type BroadcastEventToAll struct { TransactionId string `json:"transactionId,omitempty"` Actor interface{} `json:"actor,omitempty"` } - -type MxRecordConfiguredStatus struct { - MxRecordConfigured bool `json:"mxRecordConfigured"` -} -type InboundParserResponse struct { - Data MxRecordConfiguredStatus `json:"data"` -} diff --git a/lib/novu.go b/lib/novu.go index 81f01c0..ba0fc6c 100644 --- a/lib/novu.go +++ b/lib/novu.go @@ -32,7 +32,6 @@ type APIClient struct { EventApi *EventService TopicsApi *TopicService IntegrationsApi *IntegrationService - InboundParser *InboundParserService } type service struct {