Search in sources :

Example 1 with CardDetailDataModel

use of net.iGap.fragments.emoji.apiModels.CardDetailDataModel in project iGap-Android by KianIranian-STDG.

the class StickerRepository method getActiveGiftCard.

public Single<CardDetailDataModel> getActiveGiftCard(String stickerId, String nationalCode, String mobileNumber) {
    return getActiveGiftCardApiService(mobileNumber, nationalCode, stickerId).observeOn(AndroidSchedulers.mainThread()).map(rsaDataModel -> {
        CardDetailDataModel cardDetailDataModel = null;
        try {
            byte[] binary = Base64.decode(rsaDataModel.getData(), Base64.DEFAULT);
            byte[] message = HelperNumerical.getMessage(binary);
            byte[] iv = HelperNumerical.getIv(binary, G.ivSize);
            byte[] encryptedBytes = AESCrypt.decrypt(G.symmetricKey, iv, message);
            String str = new String(encryptedBytes);
            cardDetailDataModel = new Gson().fromJson(str, CardDetailDataModel.class);
        } catch (Exception e) {
            FileLog.e(e);
        }
        return cardDetailDataModel;
    });
}
Also used : CardDetailDataModel(net.iGap.fragments.emoji.apiModels.CardDetailDataModel) Gson(com.google.gson.Gson)

Example 2 with CardDetailDataModel

use of net.iGap.fragments.emoji.apiModels.CardDetailDataModel in project iGap-Android by KianIranian-STDG.

the class StickerRepository method getGiftCardInfo.

public Single<CardDetailDataModel> getGiftCardInfo(String mobileNumber, String nationalCode, String stickerId) {
    return getCardInfoApiService(mobileNumber, nationalCode, stickerId).map(rsaDataModel -> {
        CardDetailDataModel cardDetailDataMode = null;
        try {
            byte[] binary = Base64.decode(rsaDataModel.getData(), Base64.DEFAULT);
            byte[] message = HelperNumerical.getMessage(binary);
            byte[] iv = HelperNumerical.getIv(binary, G.ivSize);
            byte[] encryptedBytes = AESCrypt.decrypt(G.symmetricKey, iv, message);
            String str = new String(encryptedBytes);
            cardDetailDataMode = new Gson().fromJson(str, CardDetailDataModel.class);
        } catch (Exception e) {
            FileLog.e(e);
        }
        return cardDetailDataMode;
    });
}
Also used : CardDetailDataModel(net.iGap.fragments.emoji.apiModels.CardDetailDataModel) Gson(com.google.gson.Gson)

Aggregations

Gson (com.google.gson.Gson)2 CardDetailDataModel (net.iGap.fragments.emoji.apiModels.CardDetailDataModel)2