Skip to content

Commit

Permalink
feat: allow occurred_at to be omitted on RegisterFeedback
Browse files Browse the repository at this point in the history
This field is optional.
  • Loading branch information
figueredo committed Jul 15, 2024
1 parent 7f85766 commit 660aef9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
4 changes: 0 additions & 4 deletions incognia.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ var (
ErrMissingInstallationIDOrSessionToken = errors.New("missing installation id or session token")
ErrMissingAccountID = errors.New("missing account id")
ErrMissingSignupID = errors.New("missing signup id")
ErrMissingTimestamp = errors.New("missing timestamp")
ErrInvalidFeedbackType = errors.New("invalid feedback type")
ErrMissingClientIDOrClientSecret = errors.New("client id and client secret are required")
ErrConfigIsNil = errors.New("incognia client config is required")
Expand Down Expand Up @@ -248,9 +247,6 @@ func (c *Client) registerFeedback(feedbackEvent FeedbackType, occurredAt *time.T
if !isValidFeedbackType(feedbackEvent) {
return ErrInvalidFeedbackType
}
if occurredAt == nil {
return ErrMissingTimestamp
}

requestBody := postFeedbackRequestBody{
Event: feedbackEvent,
Expand Down
13 changes: 2 additions & 11 deletions incognia_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ var (
ExternalID: "some-external-id",
}
postFeedbackRequestBodyRequiredFieldsFixture = &postFeedbackRequestBody{
Event: SignupAccepted,
OccurredAt: &now,
Event: SignupAccepted,
}
feedbackIdentifiersFixture = &FeedbackIdentifiers{
InstallationID: "some-installation-id",
Expand Down Expand Up @@ -637,7 +636,7 @@ func (suite *IncogniaTestSuite) TestSuccessRegisterFeedbackNilOptional() {
feedbackServer := suite.mockFeedbackEndpoint(token, postFeedbackRequestBodyRequiredFieldsFixture)
defer feedbackServer.Close()

err := suite.client.RegisterFeedback(postFeedbackRequestBodyRequiredFieldsFixture.Event, postFeedbackRequestBodyRequiredFieldsFixture.OccurredAt, nil)
err := suite.client.RegisterFeedback(postFeedbackRequestBodyRequiredFieldsFixture.Event, nil, nil)
suite.NoError(err)
}

Expand Down Expand Up @@ -671,14 +670,6 @@ func (suite *IncogniaTestSuite) TestErrorRegisterFeedbackInvalidFeedbackType() {
suite.EqualError(err, ErrInvalidFeedbackType.Error())
}

func (suite *IncogniaTestSuite) TestErrorRegisterFeedbackNilTimestamp() {
feedbackServer := suite.mockFeedbackEndpoint(token, postFeedbackRequestBodyFixture)
defer feedbackServer.Close()

err := suite.client.RegisterFeedback(postFeedbackRequestBodyFixture.Event, nil, feedbackIdentifiersFixture)
suite.EqualError(err, ErrMissingTimestamp.Error())
}

func (suite *IncogniaTestSuite) TestErrorsRegisterFeedback() {
errors := []int{http.StatusBadRequest, http.StatusInternalServerError}
for _, status := range errors {
Expand Down

0 comments on commit 660aef9

Please sign in to comment.