use of com.fanap.podchat.networking.api.SSOApi in project pod-chat-android-sdk by FanapSoft.
the class ChatCore method deviceIdRequest.
private void deviceIdRequest(String ssoHost, String serverAddress, String appId, String severName) {
showLog("GET_DEVICE_ID", "");
currentDeviceExist = false;
RetrofitHelperSsoHost retrofitHelperSsoHost = new RetrofitHelperSsoHost(ssoHost);
SSOApi SSOApi = retrofitHelperSsoHost.getService(SSOApi.class);
rx.Observable<Response<DeviceResult>> listObservable = SSOApi.getDeviceId("Bearer" + " " + getToken());
listObservable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(deviceResults -> {
if (deviceResults.isSuccessful()) {
ArrayList<Device> devices = null;
if (deviceResults.body() != null) {
devices = deviceResults.body().getDevices();
}
for (Device device : devices) {
if (device.isCurrent()) {
currentDeviceExist = true;
showLog("DEVICE_ID :" + device.getUid(), "");
async.connect(serverAddress, appId, severName, token, ssoHost, device.getUid());
break;
}
}
if (!currentDeviceExist) {
captureError(ChatConstant.ERROR_CURRENT_DEVICE, ChatConstant.ERROR_CODE_CURRENT_DEVICE, null);
}
} else {
if (deviceResults.code() == 401) {
captureError("unauthorized", deviceResults.code(), null);
} else {
captureError(deviceResults.message(), deviceResults.code(), null);
}
}
}, (Throwable throwable) -> {
if (log)
Log.e(TAG, "Error on get devices" + throwable.getMessage());
});
}
Aggregations