Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove timestamp restriction on registerFeedback #82

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/incogniaApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ export class IncogniaApi {
bodyParams: RegisterFeedbackBodyProps,
queryParams?: RegisterFeedbackParamsProps
): Promise<void> {
const { event, timestamp } = bodyParams || {}
if (!event || !timestamp) {
throw new IncogniaError('No event or timestamp provided')
const { event } = bodyParams || {}
if (!event) {
throw new IncogniaError('No event provided')
}

const params = queryParams && convertObjectToSnakeCase(queryParams)
Expand Down
42 changes: 38 additions & 4 deletions test/incogniaApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,40 @@ describe('API', () => {

await incogniaApi.registerFeedback(
{
installationId: 'installation_id',
accountId: 'account_id',
event: FeedbackEvent.AccountTakeover
},
{
dryRun: true
}
)

const expectedData = {
event: FeedbackEvent.AccountTakeover,
}

const expectedParams = {
dry_run: true
}

expect(incogniaApi.resourceRequest).toBeCalledWith({
url: apiEndpoints.FEEDBACKS,
method: 'post',
params: expectedParams,
data: expectedData
})
})

it('registers feedback when all params are filled', async () => {
incogniaApi.resourceRequest = vi.fn()

await incogniaApi.registerFeedback(
{
event: FeedbackEvent.AccountTakeover,
accountId: 'account_id',
installationId: 'installation_id',
loginId: 'login_id',
paymentId: 'payment_id',
signupId: 'signup_id',
timestamp: 123
},
{
Expand All @@ -239,9 +270,12 @@ describe('API', () => {
)

const expectedData = {
installation_id: 'installation_id',
account_id: 'account_id',
event: FeedbackEvent.AccountTakeover,
account_id: 'account_id',
installation_id: 'installation_id',
login_id: 'login_id',
payment_id: 'payment_id',
signup_id: 'signup_id',
timestamp: 123
}

Expand Down
Loading