sachinkiranti/nrb-forex-api

获取尼泊尔国家银行外汇API

v1.0.0 2022-04-27 12:28 UTC

This package is auto-updated.

Last update: 2024-09-20 07:23:39 UTC


README

sachinkiranti/nrb-forex-api 包提供了访问尼泊尔国家银行固定不同国家货币对尼泊尔卢比(NPR)汇率的一种简单方式。

安装

安装过程简单,设置与其它Laravel包类似。

1. 通过Composer安装

首先通过Composer引入包

composer require sachinkiranti/nrb-forex-api

2. 定义服务提供者和别名

注意: 此包支持 Laravel >=5.5 的新自动发现功能,因此如果您正在使用 Laravel >=5.5 的项目,则安装完成,您可以跳到步骤3。

在您的 config/app.php 文件中手动添加服务提供者

'providers' => [
    // ...
    SachinKiranti\NrbForexApi\NrbForexApiServiceProvider::class,
];

在您的 config/app.php 文件中手动添加外观

'aliases' => [
    // ...
    SachinKiranti\NrbForexApi\Facades\NrbForexApi::class,
];

3. 发布配置文件

要在终端中生成配置文件,请输入以下命令

php artisan vendor:publish --tag=nrb-forex-api

用法

使用 NrbForexApi 包,获取当前汇率非常简单。

我们提供了 SachinKiranti\NrbForexApi\NrbForexISO3 用于ISO3常量列表。

使用外观

  • 获取美元对尼泊尔卢比当前汇率
 NrbForexApi::to(\SachinKiranti\NrbForexApi\NrbForexISO3::US_DOLLAR)->convert(5);
 // Outputs : (Right now, US Dollar per unit === 122.24 NRS)
 611.2

使用辅助函数

  • 获取印度卢比对尼泊尔卢比当前汇率
 nrb_forex_convert(\SachinKiranti\NrbForexApi\NrbForexISO3::INDIAN_RUPEE, 100)
 // Outputs : (Right now, Indian ruppee per 100 unit === 160 NRS)
 160

待办事项

  • 获取 尼泊尔国家银行 提供的所有可用货币的汇率列表
  • 更灵活的API

许可证

MIT许可证(MIT)。有关更多信息,请参阅许可证文件