Search in sources :

Example 1 with MapRout

use of com.fanap.podchat.mainmodel.MapRout in project pod-chat-android-sdk by FanapSoft.

the class ChatCore method mapRouting.

public String mapRouting(RequestMapRouting request) {
    String origin = request.getOrigin();
    String destination = request.getDestination();
    String uniqueId;
    RetrofitHelperMap retrofitHelperMap = new RetrofitHelperMap("https://api.neshan.org/");
    MapApi mapApi = retrofitHelperMap.getService(MapApi.class);
    uniqueId = generateUniqueId();
    Observable<Response<MapRout>> responseObservable = mapApi.mapRouting("8b77db18704aa646ee5aaea13e7370f4f88b9e8c", origin, destination, true);
    String finalUniqueId = uniqueId;
    responseObservable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(mapRoutResponse -> {
        if (mapRoutResponse.isSuccessful()) {
            MapRout mapRout = mapRoutResponse.body();
            OutPutMapRout outPutMapRout = new OutPutMapRout();
            outPutMapRout.setResult(mapRout);
            String jsonMapRout = gson.toJson(outPutMapRout);
            listenerManager.callOnMapRouting(jsonMapRout);
            showLog("RECEIVE_MAP_ROUTING", jsonMapRout);
        } else {
            captureError(mapRoutResponse.message(), mapRoutResponse.code(), finalUniqueId);
        }
    }, (Throwable throwable) -> captureError(throwable.getMessage(), ChatConstant.ERROR_CODE_UNKNOWN_EXCEPTION, finalUniqueId, throwable));
    return uniqueId;
}
Also used : RetrofitHelperMap(com.fanap.podchat.networking.retrofithelper.RetrofitHelperMap) ChatResponse(com.fanap.podchat.model.ChatResponse) Response(retrofit2.Response) MapApi(com.fanap.podchat.networking.api.MapApi) OutPutMapRout(com.fanap.podchat.model.OutPutMapRout) MapRout(com.fanap.podchat.mainmodel.MapRout) OutPutMapRout(com.fanap.podchat.model.OutPutMapRout)

Example 2 with MapRout

use of com.fanap.podchat.mainmodel.MapRout in project pod-chat-android-sdk by FanapSoft.

the class ChatCore method mapRouting.

public String mapRouting(String origin, String destination) {
    String uniqueId = generateUniqueId();
    if (chatReady) {
        RetrofitHelperMap retrofitHelperMap = new RetrofitHelperMap("https://api.neshan.org/");
        MapApi mapApi = retrofitHelperMap.getService(MapApi.class);
        Observable<Response<MapRout>> responseObservable = mapApi.mapRouting("8b77db18704aa646ee5aaea13e7370f4f88b9e8c", origin, destination, true);
        responseObservable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(mapRoutResponse -> {
            if (mapRoutResponse.isSuccessful()) {
                MapRout mapRout = mapRoutResponse.body();
                OutPutMapRout outPutMapRout = new OutPutMapRout();
                outPutMapRout.setResult(mapRout);
                String jsonMapRout = gson.toJson(outPutMapRout);
                listenerManager.callOnMapRouting(jsonMapRout);
                showLog("RECEIVE_MAP_ROUTING", jsonMapRout);
            }
        }, (Throwable throwable) -> captureError(ChatConstant.ERROR_CHAT_READY, ChatConstant.ERROR_CODE_CHAT_READY, uniqueId, throwable));
    } else {
        captureError(ChatConstant.ERROR_CHAT_READY, ChatConstant.ERROR_CODE_CHAT_READY, uniqueId);
    }
    return uniqueId;
}
Also used : RetrofitHelperMap(com.fanap.podchat.networking.retrofithelper.RetrofitHelperMap) ChatResponse(com.fanap.podchat.model.ChatResponse) Response(retrofit2.Response) MapApi(com.fanap.podchat.networking.api.MapApi) OutPutMapRout(com.fanap.podchat.model.OutPutMapRout) MapRout(com.fanap.podchat.mainmodel.MapRout) OutPutMapRout(com.fanap.podchat.model.OutPutMapRout)

Aggregations

MapRout (com.fanap.podchat.mainmodel.MapRout)2 ChatResponse (com.fanap.podchat.model.ChatResponse)2 OutPutMapRout (com.fanap.podchat.model.OutPutMapRout)2 MapApi (com.fanap.podchat.networking.api.MapApi)2 RetrofitHelperMap (com.fanap.podchat.networking.retrofithelper.RetrofitHelperMap)2 Response (retrofit2.Response)2