<?php

namespace App\Http\Controllers\Api\V1;

use App\Helpers\ApiResponse;
use App\Http\Controllers\Controller;
use App\Http\Requests\Barobill\BankServiceUrlRequest;
use App\Http\Requests\Barobill\BarobillLoginRequest;
use App\Http\Requests\Barobill\BarobillSignupRequest;
use App\Services\Barobill\BarobillSoapService;

class BarobillController extends Controller
{
    public function __construct(
        private BarobillSoapService $barobillSoapService
    ) {}

    public function login(BarobillLoginRequest $request)
    {
        return ApiResponse::handle(
            fn () => $this->barobillSoapService->registerLogin($request->validated()),
            __('message.barobill.login_success')
        );
    }

    public function signup(BarobillSignupRequest $request)
    {
        return ApiResponse::handle(
            fn () => $this->barobillSoapService->registerSignup($request->validated()),
            __('message.barobill.signup_success')
        );
    }

    public function bankServiceUrl(BankServiceUrlRequest $request)
    {
        return ApiResponse::handle(
            fn () => $this->barobillSoapService->getBankServiceRedirectUrl($request->validated()),
            __('message.fetched')
        );
    }

    public function status()
    {
        return ApiResponse::handle(
            fn () => $this->barobillSoapService->getIntegrationStatus(),
            __('message.fetched')
        );
    }

    public function accountLinkUrl()
    {
        return ApiResponse::handle(
            fn () => $this->barobillSoapService->getAccountLinkRedirectUrl(),
            __('message.fetched')
        );
    }

    public function cardLinkUrl()
    {
        return ApiResponse::handle(
            fn () => $this->barobillSoapService->getCardLinkRedirectUrl(),
            __('message.fetched')
        );
    }

    public function certificateUrl()
    {
        return ApiResponse::handle(
            fn () => $this->barobillSoapService->getCertificateRedirectUrl(),
            __('message.fetched')
        );
    }
}
