com.onfido.api.client.OnfidoAPI Maven / Gradle / Ivy
/*
* Copyright (C) Monad Tek Ltd - UK - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited
* Proprietary and confidential
* Written by Ricardo Silva , 2015
*/
package com.onfido.api.client;
import com.onfido.api.client.data.DeviceInfo;
import com.onfido.api.client.data.DocType;
import com.onfido.api.client.data.DocumentMediaIntegrity;
import com.onfido.api.client.data.DocumentMediaUploadResponse;
import com.onfido.api.client.data.DocumentUpload;
import com.onfido.api.client.data.ErrorData;
import com.onfido.api.client.data.InternalDocSide;
import com.onfido.api.client.data.LivePhotoUpload;
import com.onfido.api.client.data.LiveVideoChallenges;
import com.onfido.api.client.data.LiveVideoLanguage;
import com.onfido.api.client.data.LiveVideoUpload;
import com.onfido.api.client.data.MRZDocument;
import com.onfido.api.client.data.NfcProperties;
import com.onfido.api.client.data.PayloadIntegrity;
import com.onfido.api.client.data.PoaDocumentType;
import com.onfido.api.client.data.PoaDocumentUpload;
import com.onfido.api.client.data.SdkConfiguration;
import com.onfido.api.client.data.SdkUploadMetaData;
import com.onfido.api.client.data.SupportedDocuments;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Single;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Call;
import retrofit2.Response;
public interface OnfidoAPI {
// API V3 specific
void upload(
String fileName,
DocType documentType,
String fileType,
byte[] data,
Listener listener,
Map validations,
@Nullable InternalDocSide side,
@Nullable String issuingCountry,
SdkUploadMetaData sdkUploadMetaData
);
Single uploadSingle(
String fileName,
DocType documentType,
String fileType,
String mediaType,
byte[] data,
SdkUploadMetaData sdkUploadMetaData
);
Single poaUpload(
@Nullable String fileName,
@Nullable PoaDocumentType poaDocumentType,
@Nullable String fileType,
@Nullable byte[] data,
@Nullable String issuingCountry,
SdkUploadMetaData sdkUploadMetaData
);
Single uploadDocumentVideo(
String documentId,
String videoPath,
SdkUploadMetaData sdkUploadMetaData,
DocumentMediaIntegrity documentMediaIntegrity,
InternalDocSide docSide,
DocType docType,
@Nullable String issuingCountry
);
//Doc V4
Single uploadDocumentMedia(
String fileName,
String fileType,
String mediaType,
@Nullable String docSide,
@Nullable String docType,
Map validations,
byte[] data,
SdkUploadMetaData sdkUploadMetaData
);
void uploadLivePhoto(
String fileName,
String fileType,
byte[] data,
boolean advancedValidation,
Listener listener,
SdkUploadMetaData sdkUploadMetaData,
PayloadIntegrity payloadIntegrity
);
Single uploadLiveVideo(
String fileName,
String fileType,
byte[] data,
String challengeId,
List challengeList,
Long challengeSwitchTimestamp,
List languages,
SdkUploadMetaData sdkUploadMetaData,
PayloadIntegrity payloadIntegrity
);
Single getLiveVideoChallenges();
Single getSDKConfig(DeviceInfo deviceInfo);
Single getNfcProperties(List documentIds, MRZDocument mrzDocument);
Single getSupportedDocuments();
interface Listener {
void onSuccess(T t);
void onFailure(Throwable throwable);
void onError(int errorCode, String message, ErrorData parsedError);
}
class Callback implements retrofit2.Callback {
static final String TAG = OnfidoAPI.class.getSimpleName() + "." + Callback.class.getSimpleName();
private final Listener listener;
private final ErrorParser errorParser;
public Callback(Listener listener, ErrorParser errorParser) {
this.listener = listener;
this.errorParser = errorParser;
}
@Override
public void onFailure(Call call, Throwable t) {
listener.onFailure(t);
HttpLoggingInterceptor.Logger.DEFAULT.log(TAG + "/onFailure:" + t);
}
@Override
public void onResponse(Call call, Response response) {
boolean isError = !response.isSuccessful();
if (isError) {
ErrorData errorData = errorParser.parseErrorFrom(response);
listener.onError(response.code(), response.message(), errorData);
} else {
listener.onSuccess(response.body());
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy