icekristal/xecdapi-for-laravel

v0.0.6 2024-09-05 17:31 UTC

This package is auto-updated.

Last update: 2024-11-05 17:45:51 UTC


README

Documentation: https://xecdapi.xe.com/docs/v1

install:

composer require icekristal/xecdapi-for-laravel

add config services.php:

    'xecdapi' => [
        'auth' => [
            'username' => env('XECD_USERNAME'),
            'password' => env('XECD_PASSWORD'),
        ],
        'base_url' => env('XECD_URL', 'https://xecdapi.xe.com'),
    ],

config:

php artisan vendor:publish --provider="Icekristal\XecdapiForLaravel\XecdapiServiceProvider" --tag="config"

use:

use Icekristal\XecdapiForLaravel\Facades;

Xecdapi::getAccountInfo();

$needParams = [
    'from' => 'USD', //example
    'to' => 'EUR', //example
    'amount' => 1, //example
];

Xecdapi::setQueryParams($needParams)->getCurrencies();
Xecdapi::setQueryParams($needParams)->convertFrom();
Xecdapi::setQueryParams($needParams)->convertTo();
Xecdapi::setQueryParams($needParams)->centralBankExchangeRate();

//custom convert one to one
Xecdapi::fastConvertFiat(string $from, string $to, float|int $amount = 1); //return float; if -1 then error