Skip to content

Commit

Permalink
fix: remove restriction on feedback type
Browse files Browse the repository at this point in the history
  • Loading branch information
figueredo committed Jul 20, 2024
1 parent fd78175 commit 70c1fcd
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 51 deletions.
35 changes: 0 additions & 35 deletions incognia.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,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,
Expand Down Expand Up @@ -460,34 +456,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
}
}
16 changes: 0 additions & 16 deletions incognia_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,14 +680,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 {
Expand Down Expand Up @@ -737,14 +729,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 {
Expand Down

0 comments on commit 70c1fcd

Please sign in to comment.