package kz.com.aman.kassa.bank;

import android.widget.Toast;

import java.util.List;

import ru.m4bank.mpos.library.external.authorization.GetMerchantUsersCallbackHandler;
import ru.m4bank.mpos.service.data.dynamic.objects.MerchantUser;
import ru.m4bank.mpos.service.result.Result;

public class GetMerchantUsersCallbackHandlerImpl implements GetMerchantUsersCallbackHandler<Result> {
    private final M4BankActivity activity;

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

    @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 onListOfUsersRequested(List<MerchantUser> userList) {
        activity.runOnUiThread(() -> Toast.makeText(activity, "loaded list of merchant users", Toast.LENGTH_SHORT).show());
    }

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