<?php

declare(strict_types=1);

use LidonationDevs\ADAPAYFWC\Enums\CurrencyEnum;
use LidonationDevs\ADAPAYFWC\Services\AdaUsdQuoteService;

function ADAPAYFWC_convertion_rate_ada_to_usd(float|null $amount = null): float|int|null
{
    try {
        $rateInstance = new AdaUsdQuoteService(CurrencyEnum::ADA, CurrencyEnum::USD);

        return isset($amount) ? $rateInstance->rate * $amount : $rateInstance->rate;
    } catch (\Throwable $th) {
        return null;
    }
}


function ADAPAYFWC_convertion_rate_usd_to_ada(int|float $amount = 1): float|int|null
{
    try {
        $rateInstance = new AdaUsdQuoteService(CurrencyEnum::USD, CurrencyEnum::ADA);

        return isset($amount) ? $rateInstance->rate * $amount : $rateInstance->rate;
    } catch (\Throwable $th) {
        return null;
    }
}
