SDK contains IOzForensicsAPI interface describing APO net calls that can be used to create a Retrofit instance.
This interface uses a gson-converter and operates classes from the com.ozforensics.liveness.sdk.api.model pack.
Apart from this, the interface specifies a static method for creating a default Retrofit instance (without logging, interceptors and with 15-second timeouts). This instance will look for the server at the specified address:
val apiService = OzForensicsAPI.create(BASE_URL)SDK includes the OzForensicsService class that uses a Retrofit instance from OzForensicsAPI.create(). This class wraps in net calls from the Retrofit interface and checks the presence of a token. When an auth request is performed, the token is stored automatically for internal goals. Also, the required metadata is added where necessary when performing the net requests (creating a folder, uploading media data to be analyzed). The method calls of this class are asynchronous (the StatusListener<> interface is used). You can obtain an instance of this class as follows:
If the TOKEN parameter value is set to null, authorization is required before performing any API call (except auth):
After a successful request, onSuccessCallback is performed so that the access token can be transferred with AuthResponse.
OzForensicsAPI apiService = OzForensicsAPI.Factory.create(BASE_URL);val service = OzForensicsService(BASE_URL, ACCESS_TOKEN)OzForensicsService service = OzForensicsService(BASE_URL, ACCESS_TOKEN);service.auth(EMAIL, PASSWORD, listener)service.auth(EMAIL, PASSWORD, listener);Data to be uploaded and analyzed is stored in object sdkMediaResult, obtained after capturing and recording video. Upload it to the server and initiate required analyses via Oz API.
A simple scenario of interaction with Oz API can be implemented with theuploadMediaAndAnalyze method as described below.
val statusListener = object: StatusListener<List<OzAnalysisResult>> {
override fun onStatusChanged(status: String?) { /*your code for showing status message*/ }
override fun onSuccess(result:List <OzAnalysisResult>) {
StatusListener<List<OzAnalysisResult>> statusListener = new StatusListener<List<OzAnalysisResult>>() {
@Override public void onStatusChanged(@Nullable String s) { /*your code for showing status message*/ }
@Override
To run the on-device analyses instead of server-based, use the following methods:
OzLivenessSDK.runOnDeviceLivenessAnalysis(mediaList)
OzLivenessSDK.runOnDeviceBiometryAnalysis(mediaList)OzLivenessSDK.INSTANCE.runOnDeviceLivenessAnalysis(mediaList);
OzLivenessSDK.INSTANCE.runOnDeviceBiometryAnalysis(mediaList);