Skip to content
Open
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
27 changes: 27 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,33 @@ major versions of the client library.
It covers changes in core resources, other endpoints, and the OpenAPI generator,
ensuring a smooth transition between versions.

## Upgrading from 6.x to 7.x

### API Method Invocation

- All API methods now return request builder objects requiring `.execute()` call
- Optional parameters are set via fluent setter methods instead of method parameters
- This change prevents breaking changes when new optional parameters are added

Example migration:
```java
// Before (6.x)
Applicant applicant = onfido.findApplicant(applicantId);
List<WorkflowRun> runs = onfido.listWorkflowRuns(applicantId, status, page, perPage);

// After (7.x)
Applicant applicant = onfido.findApplicant(applicantId).execute();
List<WorkflowRun> runs = onfido.listWorkflowRuns()
.applicantId(applicantId)
.status(status)
.page(page)
.perPage(perPage)
.execute();
```

Note: Some list methods return wrapper objects (e.g., `ChecksList`) with
accessor methods like `getChecks()` to retrieve the actual list.

## Upgrading from 5.x to 6.x

### Core Resources
Expand Down
6 changes: 4 additions & 2 deletions src/test/java/com/onfido/OnfidoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public void throwsExceptionForMissingApiToken() {
ApiException.class,
() ->
new DefaultApi(apiClient)
.findApplicant(UUID.fromString("839d4812-7c49-4008-8d83-bbd7610f0fec")),
.findApplicant(UUID.fromString("839d4812-7c49-4008-8d83-bbd7610f0fec"))
.execute(),
"Expected to throw, but it didn't");

assertTrue(thrown.getMessage().contains("authorization_error"));
Expand All @@ -40,7 +41,8 @@ public void throwsExceptionForNullApiToken() {
ApiException.class,
() ->
new DefaultApi(apiClient.setApiToken(null))
.findApplicant(UUID.fromString("839d4812-7c49-4008-8d83-bbd7610f0fec")),
.findApplicant(UUID.fromString("839d4812-7c49-4008-8d83-bbd7610f0fec"))
.execute(),
"Expected to throw, but it didn't");

assertTrue(thrown.getMessage().contains("authorization_error"));
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/onfido/integration/AddressTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class AddressTest extends TestBase {

@Test
public void pickTest() throws Exception {
List<Address> addresses = onfido.findAddresses("S2 2DF").getAddresses();
List<Address> addresses = onfido.findAddresses("S2 2DF").execute().getAddresses();

Assertions.assertNotNull(addresses);
Assertions.assertEquals("S2 2DF", addresses.get(0).getPostcode());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ public void documentsTest() throws Exception {
new WorkflowRunBuilder()
.workflowId(workflowId)
.applicantId(applicantId)
.customData(customData));
.customData(customData)).execute();
UUID workflowRunId = workflowRun.getId();

TaskItem task = onfido.listTasks(workflowRunId).get(1);
TaskItem task = onfido.listTasks(workflowRunId).execute().get(1);

LinkedTreeMap output =
(LinkedTreeMap)
Expand All @@ -47,9 +47,9 @@ public void documentsTest() throws Exception {
UUID receiptDocumentFileId = UUID.fromString((String) receiptDocument.get("id"));

byte[] signedDocumentBytes =
onfido.downloadAesDocument(workflowRunId, signedDocumentFileId).getByteArray();
onfido.downloadAesDocument(workflowRunId, signedDocumentFileId).execute().getByteArray();
byte[] receiptDocumentBytes =
onfido.downloadAesDocument(workflowRunId, receiptDocumentFileId).getByteArray();
onfido.downloadAesDocument(workflowRunId, receiptDocumentFileId).execute().getByteArray();

Assertions.assertEquals("%PDF", new String(signedDocumentBytes, 0, 4));
Assertions.assertTrue(signedDocumentBytes.length > 0);
Expand Down
18 changes: 9 additions & 9 deletions src/test/java/com/onfido/integration/ApplicantTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void setup() throws Exception {

@AfterEach
public void cleanUp() throws Exception {
onfido.deleteApplicant(applicant.getId());
onfido.deleteApplicant(applicant.getId()).execute();
}

@Test
Expand All @@ -41,7 +41,7 @@ public void createApplicantTest() throws Exception {
@Test
public void findApplicantTest() throws Exception {
Applicant applicant = createApplicant();
Applicant lookupApplicant = onfido.findApplicant(applicant.getId());
Applicant lookupApplicant = onfido.findApplicant(applicant.getId()).execute();

Assertions.assertEquals("First", lookupApplicant.getFirstName());
Assertions.assertEquals("Last", lookupApplicant.getLastName());
Expand All @@ -52,7 +52,7 @@ public void findApplicantTest() throws Exception {
@Test
public void updateApplicantTest() throws Exception {
Applicant updatedApplicant =
onfido.updateApplicant(applicant.getId(), new ApplicantUpdater().firstName("Updated"));
onfido.updateApplicant(applicant.getId(), new ApplicantUpdater().firstName("Updated")).execute();

Assertions.assertEquals("Updated", updatedApplicant.getFirstName());
Assertions.assertEquals("Last", updatedApplicant.getLastName());
Expand All @@ -72,9 +72,9 @@ public void findApplicantConsentsTest() throws Exception {
.name(ApplicantConsentName.PHONE_NUMBER_VERIFICATION)
.granted(true));

onfido.updateApplicant(applicant.getId(), new ApplicantUpdater().consents(consents));
onfido.updateApplicant(applicant.getId(), new ApplicantUpdater().consents(consents)).execute();

List<ApplicantConsent> actualConsents = onfido.findApplicantConsents(applicant.getId());
List<ApplicantConsent> actualConsents = onfido.findApplicantConsents(applicant.getId()).execute();

Map<ApplicantConsentName, Boolean> expectedConsents =
consents.stream()
Expand All @@ -93,15 +93,15 @@ public void findApplicantConsentsTest() throws Exception {
public void deleteApplicantTest() throws Exception {
Applicant applicant = createApplicant();

onfido.deleteApplicant(applicant.getId());
onfido.deleteApplicant(applicant.getId()).execute();
}

@Test
public void restoreApplicantTest() throws Exception {
Applicant applicant = createApplicant();

onfido.deleteApplicant(applicant.getId());
onfido.restoreApplicant(applicant.getId());
onfido.deleteApplicant(applicant.getId()).execute();
onfido.restoreApplicant(applicant.getId()).execute();
}

@Test
Expand All @@ -110,7 +110,7 @@ public void listApplicants() throws Exception {
createApplicant("Applicant2");

List<Applicant> applicants =
onfido.listApplicants(1, 20, false).getApplicants().stream()
onfido.listApplicants().page(1).perPage(20).includeDeleted(false).execute().getApplicants().stream()
.sorted(Comparator.comparing(Applicant::getFirstName))
.collect(Collectors.toList());

Expand Down
6 changes: 3 additions & 3 deletions src/test/java/com/onfido/integration/CheckTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void findCheckTest() throws Exception {
document,
new CheckBuilder().reportNames(Arrays.asList(ReportName.DOCUMENT)));

Check lookupCheck = onfido.findCheck(check.getId());
Check lookupCheck = onfido.findCheck(check.getId()).execute();

Assertions.assertEquals(check.getApplicantId(), lookupCheck.getApplicantId());

Expand All @@ -103,7 +103,7 @@ public void listChecks() throws Exception {
createCheck(
applicant, document, new CheckBuilder().reportNames(Arrays.asList(ReportName.DOCUMENT)));

List<Check> checks = onfido.listChecks(applicant.getId()).getChecks();
List<Check> checks = onfido.listChecks(applicant.getId()).execute().getChecks();

Assertions.assertEquals(applicant.getId(), checks.get(0).getApplicantId());
Assertions.assertEquals(1, checks.size());
Expand All @@ -130,7 +130,7 @@ public void downloadCheckTest() throws Exception {
document,
new CheckBuilder().reportNames(Arrays.asList(ReportName.DOCUMENT)));

FileTransfer download = onfido.downloadCheck(check.getId());
FileTransfer download = onfido.downloadCheck(check.getId()).execute();
byte[] byteArray = download.getByteArray();

Assertions.assertEquals("application/pdf", download.getContentType());
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/com/onfido/integration/DocumentTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void uploadDocumentTest() {

@Test
public void downloadDocumentTest() throws Exception {
FileTransfer download = onfido.downloadDocument(document.getId());
FileTransfer download = onfido.downloadDocument(document.getId()).execute();

Assertions.assertEquals("image/png", download.getContentType());
Assertions.assertNotNull(download.getFilename());
Expand All @@ -42,7 +42,7 @@ public void downloadDocumentTest() throws Exception {
@Test
public void downloadErrorTest() {
try {
onfido.downloadDocument(nonExistingId);
onfido.downloadDocument(nonExistingId).execute();
Assertions.fail();
} catch (ApiException ex) {
Assertions.assertEquals(404, ex.getCode());
Expand All @@ -51,7 +51,7 @@ public void downloadErrorTest() {

@Test
public void findDocumentTest() throws Exception {
Document lookupDocument = onfido.findDocument(document.getId());
Document lookupDocument = onfido.findDocument(document.getId()).execute();

Assertions.assertEquals("sample_driving_licence.png", lookupDocument.getFileName());
Assertions.assertNotNull(lookupDocument.toJson());
Expand All @@ -62,7 +62,7 @@ public void listDocumentsTest() throws Exception {
uploadDocument(applicant, "another_sample_driving_licence.jpeg", DocumentTypes.UNKNOWN);

List<Document> documents =
onfido.listDocuments(applicant.getId()).getDocuments().stream()
onfido.listDocuments(applicant.getId()).execute().getDocuments().stream()
.sorted(Comparator.comparing(Document::getFileName))
.collect(Collectors.toList());

Expand All @@ -81,7 +81,7 @@ public void listDocumentsTest() throws Exception {
@Test
public void nullParamRequestTest() {
try {
onfido.uploadDocument(null, null, null, "file.png", null, null, null, null);
onfido.uploadDocument(null, null, null).execute();
Assertions.fail();
} catch (ApiException ex) {
Assertions.assertEquals(0, ex.getCode());
Expand All @@ -92,7 +92,7 @@ public void nullParamRequestTest() {
public void downloadNfcFaceTest() throws Exception {
Document nfcFace = uploadDocument(applicant, "nfc_data.json", DocumentTypes.PASSPORT);

FileTransfer download = onfido.downloadNfcFace(nfcFace.getId());
FileTransfer download = onfido.downloadNfcFace(nfcFace.getId()).execute();

Assertions.assertEquals("image/png", download.getContentType());
Assertions.assertNotNull(download.getFilename());
Expand All @@ -102,7 +102,7 @@ public void downloadNfcFaceTest() throws Exception {
@Test
public void downloadNfcFaceNotFoundTest() {
try {
onfido.downloadNfcFace(nonExistingId);
onfido.downloadNfcFace(nonExistingId).execute();
Assertions.fail();
} catch (ApiException ex) {
Assertions.assertEquals(404, ex.getCode());
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/onfido/integration/ExtractionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void performExtractionTest() throws Exception {

Document document =
uploadDocument(applicant, "sample_driving_licence.png", DocumentTypes.DRIVING_LICENCE);
Extraction extraction = onfido.extract(new ExtractRequest().documentId(document.getId()));
Extraction extraction = onfido.extract(new ExtractRequest().documentId(document.getId())).execute();

Assertions.assertEquals(document.getId(), extraction.getDocumentId());

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/onfido/integration/IdPhotoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void uploadIdPhotoTest() throws Exception {

@Test
public void downloadIdPhotoTest() throws Exception {
FileTransfer download = onfido.downloadIdPhoto(idPhoto.getId());
FileTransfer download = onfido.downloadIdPhoto(idPhoto.getId()).execute();

Assertions.assertEquals("image/png", download.getContentType());
Assertions.assertTrue(download.getFilename() != null);
Expand All @@ -41,7 +41,7 @@ public void downloadIdPhotoTest() throws Exception {
@Test
public void downloadErrorTest() throws Exception {
try {
onfido.downloadIdPhoto(nonExistingId);
onfido.downloadIdPhoto(nonExistingId).execute();
Assertions.fail();
} catch (ApiException ex) {
Assertions.assertEquals(404, ex.getCode());
Expand All @@ -50,7 +50,7 @@ public void downloadErrorTest() throws Exception {

@Test
public void findIdPhotoTest() throws Exception {
IdPhoto lookupIdPhoto = onfido.findIdPhoto(idPhoto.getId());
IdPhoto lookupIdPhoto = onfido.findIdPhoto(idPhoto.getId()).execute();

Assertions.assertEquals(idPhoto.getId() + ".png", lookupIdPhoto.getFileName());

Expand All @@ -62,7 +62,7 @@ public void listIdPhotosTest() throws Exception {
uploadIdPhoto(applicant, "another_sample_photo.png");

List<IdPhoto> idPhotos =
onfido.listIdPhotos(applicant.getId()).getIdPhotos().stream()
onfido.listIdPhotos(applicant.getId()).execute().getIdPhotos().stream()
.sorted(Comparator.comparing(IdPhoto::getFileName))
.collect(Collectors.toList());

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/onfido/integration/LivePhotoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void uploadLivePhotoTest() throws Exception {

@Test
public void downloadLivePhotoTest() throws Exception {
FileTransfer download = onfido.downloadLivePhoto(livePhoto.getId());
FileTransfer download = onfido.downloadLivePhoto(livePhoto.getId()).execute();

Assertions.assertEquals("image/png", download.getContentType());
Assertions.assertEquals("sample_photo.png", download.getFilename());
Expand All @@ -41,7 +41,7 @@ public void downloadLivePhotoTest() throws Exception {
@Test
public void downloadErrorTest() throws Exception {
try {
onfido.downloadLivePhoto(nonExistingId);
onfido.downloadLivePhoto(nonExistingId).execute();
Assertions.fail();
} catch (ApiException ex) {
Assertions.assertEquals(404, ex.getCode());
Expand All @@ -50,7 +50,7 @@ public void downloadErrorTest() throws Exception {

@Test
public void findLivePhotoTest() throws Exception {
LivePhoto lookupLivePhoto = onfido.findLivePhoto(livePhoto.getId());
LivePhoto lookupLivePhoto = onfido.findLivePhoto(livePhoto.getId()).execute();

Assertions.assertEquals("sample_photo.png", lookupLivePhoto.getFileName());

Expand All @@ -62,7 +62,7 @@ public void listLivePhotosTest() throws Exception {
uploadLivePhoto(applicant, "another_sample_photo.png");

List<LivePhoto> livePhotos =
onfido.listLivePhotos(applicant.getId()).getLivePhotos().stream()
onfido.listLivePhotos(applicant.getId()).execute().getLivePhotos().stream()
.sorted(Comparator.comparing(LivePhoto::getFileName))
.collect(Collectors.toList());

Expand Down
10 changes: 5 additions & 5 deletions src/test/java/com/onfido/integration/LiveVideoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class LiveVideoTest extends TestBase {

@Test
public void downloadLiveVideoTest() throws Exception {
FileTransfer download = onfido.downloadLiveVideo(sampleLiveVideoId1);
FileTransfer download = onfido.downloadLiveVideo(sampleLiveVideoId1).execute();

Assertions.assertEquals("video/quicktime", download.getContentType());
Assertions.assertEquals("video.mov", download.getFilename());
Expand All @@ -25,7 +25,7 @@ public void downloadLiveVideoTest() throws Exception {
@Test
public void downloadLiveVideoFrameTest() throws Exception {
try {
FileTransfer download = onfido.downloadLiveVideoFrame(sampleLiveVideoId1);
FileTransfer download = onfido.downloadLiveVideoFrame(sampleLiveVideoId1).execute();

Assertions.assertEquals("image/jpeg", download.getContentType());
Assertions.assertTrue(download.getFilename() != null);
Expand All @@ -40,7 +40,7 @@ public void downloadLiveVideoFrameTest() throws Exception {
@Test
public void downloadErrorTest() throws Exception {
try {
onfido.downloadLiveVideo(nonExistingId);
onfido.downloadLiveVideo(nonExistingId).execute();
Assertions.fail();
} catch (ApiException ex) {
Assertions.assertEquals(404, ex.getCode());
Expand All @@ -49,7 +49,7 @@ public void downloadErrorTest() throws Exception {

@Test
public void findLiveVideoTest() throws Exception {
LiveVideo liveVideo = onfido.findLiveVideo(sampleLiveVideoId1);
LiveVideo liveVideo = onfido.findLiveVideo(sampleLiveVideoId1).execute();

Assertions.assertEquals("video.mov", liveVideo.getFileName());

Expand All @@ -58,7 +58,7 @@ public void findLiveVideoTest() throws Exception {

@Test
public void listLiveVideosTest() throws Exception {
List<LiveVideo> liveVideos = onfido.listLiveVideos(sampleApplicantId).getLiveVideos();
List<LiveVideo> liveVideos = onfido.listLiveVideos(sampleApplicantId).execute().getLiveVideos();

Assertions.assertEquals("video.mov", liveVideos.get(0).getFileName());
Assertions.assertEquals("video.mov", liveVideos.get(1).getFileName());
Expand Down
Loading
Loading