Skip to content

Commit

Permalink
feat: add/use RFC3339 fields in requests
Browse files Browse the repository at this point in the history
Timestamp fields that store time as milliseconds since epoch are
being replaced by fields that store it as a RFC 3339 string.

This commit:
- Removes POST /feedbacks `timestamp` field, replacing it with
`occurred_at`. Removal is possible because this field is not in
the public API.
- Add `collected_at` to POST /signups' `additional_locations`. This
field should be used instead of the existing `timestamp`.
  • Loading branch information
figueredo committed Jul 17, 2024
1 parent 2a42d43 commit 8401bc0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/incognia/api/IncogniaAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -408,14 +408,14 @@ public void registerFeedback(

public void registerFeedback(
FeedbackEvent feedbackEvent,
Instant timestamp,
Instant occurredAt,
FeedbackIdentifiers identifiers,
boolean dryRun)
throws IncogniaException {
PostFeedbackRequestBody requestBody =
PostFeedbackRequestBody.builder()
.event(feedbackEvent)
.timestamp(timestamp.toEpochMilli())
.occurredAt(occurredAt)
.installationId(identifiers.getInstallationId())
.sessionToken(identifiers.getSessionToken())
.accountId(identifiers.getAccountId())
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/incognia/common/AdditionalLocation.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
import lombok.Builder;
import lombok.Value;

import java.time.Instant;

@Value
@Builder
public class AdditionalLocation {
Double lat;
Double lng;
@Deprecated
Long timestamp;
Instant collectedAt;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import lombok.Builder;
import lombok.Value;

import java.time.Instant;

@Value
@Builder
public class PostFeedbackRequestBody {
FeedbackEvent event;
Long timestamp;
Instant occurredAt;
String accountId;
String externalId;
String installationId;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/incognia/api/IncogniaAPITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ void testRegisterFeedback_whenDataIsValid(boolean dryRun) {
.signupId(signupId)
.accountId(accountId)
.event(FeedbackEvent.ACCOUNT_TAKEOVER)
.timestamp(timestamp.toEpochMilli())
.occurredAt(timestamp)
.build());
mockServer.setDispatcher(dispatcher);
client.registerFeedback(
Expand Down

0 comments on commit 8401bc0

Please sign in to comment.