<?php

namespace App\Http\Integrations\Imake\Requests\MoorlePay;

use Saloon\Enums\Method;
use Saloon\Http\Request;
use Saloon\Contracts\Body\HasBody;
use Saloon\Traits\Body\HasJsonBody;

class VerifyOTP extends Request implements HasBody
{
    use HasJsonBody;
    /**
     * The HTTP method of the request
     */
    protected Method $method = Method::POST;

    public function __construct(
        protected readonly string $amount,
        protected readonly string $payer,
        protected readonly string $otpcode,
        protected readonly string $channel,
        protected readonly string $externalref
    ) {}

    public function defaultBody(): array
    {
        return [
            'type' => 1,
            'channel' => $this->channel,
            'amount' => $this->amount,
            'currency' => 'GHS',
            'payer' => $this->payer,
            'otpcode' => $this->otpcode ?? '',
            'reference' => "iMake",
            'accountnumber' => env('MOORLE_ACCOUNT_NUMBER'),
            'externalref' => $this->externalref
        ];
    }

    /**
     * The endpoint for the request
     */
    public function resolveEndpoint(): string
    {
        return '/transact/payment';
    }
}