From 68901ac33144952d1cd9494a60f79796d0a686e1 Mon Sep 17 00:00:00 2001 From: Thiago Cardoso Date: Thu, 18 Jul 2024 16:47:43 -0300 Subject: [PATCH] fix: remove restriction on feedback type --- incognia.go | 35 ----------------------------------- incognia_test.go | 16 ---------------- 2 files changed, 51 deletions(-) diff --git a/incognia.go b/incognia.go index 8840108..731e689 100644 --- a/incognia.go +++ b/incognia.go @@ -256,10 +256,6 @@ func (c *Client) RegisterFeedbackWithExpiration(feedbackEvent FeedbackType, occu } func (c *Client) registerFeedback(feedbackEvent FeedbackType, occurredAt *time.Time, expiresAt *time.Time, feedbackIdentifiers *FeedbackIdentifiers) (err error) { - if !isValidFeedbackType(feedbackEvent) { - return ErrInvalidFeedbackType - } - requestBody := postFeedbackRequestBody{ Event: feedbackEvent, OccurredAt: occurredAt, @@ -458,34 +454,3 @@ func (c *Client) authorizeRequest(request *http.Request) error { return nil } - -func isValidFeedbackType(feedbackType FeedbackType) bool { - switch feedbackType { - case - PaymentAccepted, - PaymentDeclined, - PaymentDeclinedByRiskAnalysis, - PaymentDeclinedByAcquirer, - PaymentDeclinedByBusiness, - PaymentDeclinedByManualReview, - PaymentAcceptedByThirdParty, - LoginAccepted, - LoginDeclined, - SignupAccepted, - SignupDeclined, - ChallengePassed, - ChallengeFailed, - PasswordChangedSuccessfully, - PasswordChangeFailed, - Verified, - NotVerified, - Chargeback, - PromotionAbuse, - AccountTakeover, - MposFraud, - ChargebackNotification: - return true - default: - return false - } -} diff --git a/incognia_test.go b/incognia_test.go index 8f58d1d..27c9599 100644 --- a/incognia_test.go +++ b/incognia_test.go @@ -677,14 +677,6 @@ func (suite *IncogniaTestSuite) TestForbiddenRegisterFeedback() { suite.EqualError(err, "403 Forbidden") } -func (suite *IncogniaTestSuite) TestErrorRegisterFeedbackInvalidFeedbackType() { - feedbackServer := suite.mockFeedbackEndpoint(token, postFeedbackRequestBodyFixture) - defer feedbackServer.Close() - - err := suite.client.RegisterFeedback("invalid-type", postFeedbackRequestBodyFixture.OccurredAt, feedbackIdentifiersFixture) - suite.EqualError(err, ErrInvalidFeedbackType.Error()) -} - func (suite *IncogniaTestSuite) TestErrorsRegisterFeedback() { errors := []int{http.StatusBadRequest, http.StatusInternalServerError} for _, status := range errors { @@ -734,14 +726,6 @@ func (suite *IncogniaTestSuite) TestForbiddenRegisterFeedbackWithExpiration() { suite.EqualError(err, "403 Forbidden") } -func (suite *IncogniaTestSuite) TestErrorRegisterFeedbackWithExpirationInvalidFeedbackType() { - feedbackServer := suite.mockFeedbackEndpoint(token, postFeedbackRequestWithExpirationBodyFixture) - defer feedbackServer.Close() - - err := suite.client.RegisterFeedbackWithExpiration("invalid-type", postFeedbackRequestWithExpirationBodyFixture.OccurredAt, postFeedbackRequestWithExpirationBodyFixture.ExpiresAt, feedbackIdentifiersFixture) - suite.EqualError(err, ErrInvalidFeedbackType.Error()) -} - func (suite *IncogniaTestSuite) TestErrorsRegisterFeedbackWithExpiration() { errors := []int{http.StatusBadRequest, http.StatusInternalServerError} for _, status := range errors {