Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FPJS_API_SECRET=<FPJS_API_SECRET>
FPJS_VISITOR_ID=<FPJS_VISITOR_ID>
FPJS_REQUEST_ID=<FPJS_REQUEST_ID>
FPJS_VISITOR_ID_TO_DELETE=<FPJS_VISITOR_ID>
FPJS_REQUEST_ID_TO_UPDATE=<FPJS_REQUEST_ID>
# "eu" or "ap", "us" is the default
FPJS_API_REGION=<FPJS_API_REGION>
FPJS_API_REGION=<FPJS_API_REGION>
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
package com.fingerprint.example;

import com.fingerprint.api.FingerprintApi;
import com.fingerprint.model.EventsGetResponse;
import com.fingerprint.model.EventsUpdateRequest;
import com.fingerprint.model.SearchEventsResponse;
import com.fingerprint.model.VisitorsGetResponse;
import com.fingerprint.model.*;
import com.fingerprint.sdk.ApiClient;
import com.fingerprint.sdk.ApiException;
import com.fingerprint.sdk.Configuration;

import java.sql.Timestamp;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.HashMap;

public class FunctionalTests {
public static void main(String... args) {
String FPJS_API_SECRET = System.getenv("FPJS_API_SECRET");
String FPJS_VISITOR_ID = System.getenv("FPJS_VISITOR_ID");
String FPJS_REQUEST_ID = System.getenv("FPJS_REQUEST_ID");
String FPJS_VISITOR_ID = "";
String FPJS_REQUEST_ID = "";
String FPJS_API_REGION = System.getenv("FPJS_API_REGION");
String FPJS_REQUEST_ID_TO_UPDATE = System.getenv("FPJS_REQUEST_ID_TO_UPDATE");
String FPJS_VISITOR_ID_TO_DELETE = System.getenv("FPJS_VISITOR_ID_TO_DELETE");
Expand All @@ -26,6 +25,23 @@ public static void main(String... args) {
ApiClient client = Configuration.getDefaultApiClient(FPJS_API_SECRET, FPJS_API_REGION != null ? FPJS_API_REGION : "us");
FingerprintApi api = new FingerprintApi(client);

long end = Instant.now().toEpochMilli();
long start = Instant.now().minus(90L, ChronoUnit.DAYS).toEpochMilli();

// Search events
try {
final SearchEventsResponse events = api.searchEvents(2, new FingerprintApi.SearchEventsOptionalParams()
.setStart(start)
.setEnd(end)
);
Identification firstEventIdentificationData = events.getEvents().get(0).getProducts().getIdentification().getData();
FPJS_VISITOR_ID = firstEventIdentificationData.getVisitorId();
FPJS_REQUEST_ID = firstEventIdentificationData.getRequestId();
System.out.println(events.getEvents());
} catch (ApiException e) {
System.err.println("Exception when calling FingerprintApi.searchEvents:" + e.getMessage());
System.exit(1);
}

// Get identification event
try {
Expand All @@ -45,15 +61,6 @@ public static void main(String... args) {
System.exit(1);
}

// Search events
try {
final SearchEventsResponse events = api.searchEvents(2, new FingerprintApi.SearchEventsOptionalParams().setBot("bad"));
System.out.println(events.getEvents());
} catch (ApiException e) {
System.err.println("Exception when calling FingerprintApi.searchEvents:" + e.getMessage());
System.exit(1);
}

// Update identification event

if (FPJS_REQUEST_ID_TO_UPDATE != null) {
Expand All @@ -79,6 +86,24 @@ public static void main(String... args) {
}
}

// Check that old events are still match expected format
try {
final SearchEventsResponse oldEvents = api.searchEvents(2, new FingerprintApi.SearchEventsOptionalParams()
.setStart(start)
.setEnd(end)
.setReverse(true)
);
Identification oldEventIdentificationData = oldEvents.getEvents().get(0).getProducts().getIdentification().getData();
String FPJS_OLD_VISITOR_ID = oldEventIdentificationData.getVisitorId();
String FPJS_OLD_REQUEST_ID = oldEventIdentificationData.getRequestId();
api.getEvent(FPJS_OLD_REQUEST_ID);
api.getVisits(FPJS_OLD_VISITOR_ID, null, null, null, null, null);
System.out.println("Old events are good");
} catch (ApiException e) {
System.err.println("Exception when trying to read old data:" + e.getMessage());
System.exit(1);
}

System.out.println("Checks Passed");
System.exit(0);
}
Expand Down
Loading