package kz.com.aman.kassa.bank;

import android.widget.Toast;

//import com.landicorp.uns.result;

import java.util.List;

import ru.m4bank.mpos.library.external.transactions.CloseDayCallbackHandler;
import ru.m4bank.mpos.service.data.dynamic.objects.Transaction;
import ru.m4bank.mpos.service.handling.result.CloseDayResult;
import ru.m4bank.mpos.service.result.Result;
import ru.m4bank.mpos.service.transactions.network.closeday.CloseDayResponseInfo;


class CloseDayCallbackHandlerImpl implements CloseDayCallbackHandler<Result> {
    private final M4BankActivity activity;

    CloseDayCallbackHandlerImpl(M4BankActivity activity) {
        this.activity = activity;
    }

    @Override
    public void notAuthorized() {
        activity.runOnUiThread(() -> Toast.makeText(activity, "Not authorized", Toast.LENGTH_SHORT).show());
    }

    @Override
    public void onCompleted(Result result) {
        activity.runOnUiThread(() -> Toast.makeText(activity, result.getResultType() + " " + (result.getDescription() == null ? "" : result.getDescription()), Toast.LENGTH_SHORT)
             .show());
    }

    @Override
    public void onWrongApiCalled() {
        activity.runOnUiThread(() -> Toast.makeText(activity, "Wrong method has been called", Toast.LENGTH_SHORT).show());
    }

    @Override
    public void onRepeat(int attemptNumber) {
        activity.runOnUiThread(() -> Toast.makeText(activity, "Repeat attempt number " + attemptNumber, Toast.LENGTH_SHORT).show());
    }

    @Override
    public void onTransactionsListReceived(List<Transaction> transactionList, List<CloseDayResponseInfo> list1) {
        activity.runOnUiThread(() -> Toast.makeText(activity, "onTransactionsListReceived - " + transactionList, Toast.LENGTH_SHORT).show());
    }

    @Override
    public void onCompleted(CloseDayResult closeDayResult) {
        activity.runOnUiThread(() -> Toast.makeText(activity, closeDayResult.getResultType() + " " + (closeDayResult.getDescription() == null ? "" : closeDayResult.getDescription()), Toast.LENGTH_SHORT)
                .show());
    }
}
