package kz.com.aman.kassa.bank;

import android.widget.Toast;

import ru.m4bank.mpos.library.external.configuration.GetLicenseCallbackHandler;
import ru.m4bank.mpos.service.result.Result;

public class GetLicenseCallbackHandlerImpl implements GetLicenseCallbackHandler<Result> {
    private final M4BankActivity activity;

    public GetLicenseCallbackHandlerImpl(M4BankActivity activity) {
        this.activity = activity;
    }

    @Override
    public void onLicenseReceived(String license) {
        activity.runOnUiThread(() -> Toast.makeText(activity, license, 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());
    }
}
