承接 abgeo/nbg-currency 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

abgeo/nbg-currency

Composer 安装命令:

composer require abgeo/nbg-currency

包简介

Library for getting data from National Bank of Georgia (NBG)'s API.

README 文档

README

PHP Library for getting data from National Bank of Georgia (NBG)'s API.

GitHub license

GitHub release

Packagist Version

Build Status

See documentation generated by phpDocumentor in docs/ folder.

Installation

You can install this library with Composer:

  • composer require abgeo/nbg-currency

Usage

Include composer autoloader in your main file (Ex.: index.php)

  • require_once __DIR__.'/../vendor/autoload.php';

Import Classes:

  • use ABGEO\NBG\Currency;
  • use ABGEO\NBG\Helper\CurrencyCodes;

Now you can create new Currency Class object ex. for USD currency:

  • $USD = new Currency(CurrencyCodes::USD);

The Currency class constructor takes a single argument - the Currency Code. You can pass it manually (ISO 4217) or using ABGEO\NBG\Helper\CurrencyCodes class constants:

AED, AMD, AUD, AZN, BGN, BYR, CAD, CHF, CNY, CZK, DKK, EEK, EGP, EUR, 
GBP, HKD, HUF, ILS, INR, IRR, ISK, JPY, KGS, KWD, KZT, LTL, LVL, MDL, 
NOK, NZD, PLN, RON, RSD, RUB, SEK, SGD, TJS, TMT, TRY, UAH, USD, UZS.

After creating a class object, we can get currency data.
The API gives us:

  • Currency Amount;
  • Currency Description;
  • Currency Change value;
  • Currency Change rate (-1 - decreased; 0 - unchanged; 1 - increased);
  • Currency Date;

Public methods

  • getCurrency() - Get Currency Amount;
  • getDescription() - Get Currency Description;
  • getChange() - Currency Change value;
  • getRate() - Get Currency Change rate;
  • getDate() - Get Currency Date;

Examples

Example for USD

...
echo "Currency: \t{$USD->getCurrency()}\n";
echo "Description: \t{$USD->getDescription()}\n";
echo "Change: \t{$USD->getChange()}\n";
echo "Change Rate: \t{$USD->getRate()}\n";
echo "Date: \t\t{$USD->getDate()->format('m/d/Y')}\n";
...

Full example with USD and EUR

<?php

// Include Composer Autoloader.
require_once __DIR__.'/../vendor/autoload.php';

// Import namespace.
use ABGEO\NBG\Currency;
use ABGEO\NBG\Helper\CurrencyCodes;

// Create new Currency class object for USD and EUR Currencies.
$USD = new Currency(CurrencyCodes::USD);
$EUR = new Currency(CurrencyCodes::EUR);

// Print results.

echo "USD: \n\n";
echo "Currency: \t{$USD->getCurrency()}\n";
echo "Description: \t{$USD->getDescription()}\n";
echo "Change: \t{$USD->getChange()}\n";
echo "Change Rate: \t{$USD->getRate()}\n";
echo "Date: \t\t{$USD->getDate()->format('m/d/Y')}\n";

echo "\n------------------------------------------\n\n";

echo "EUR: \n\n";
echo "Currency: \t{$EUR->getCurrency()}\n";
echo "Description: \t{$EUR->getDescription()}\n";
echo "Change: \t{$EUR->getChange()}\n";
echo "Change Rate: \t{$EUR->getRate()}\n";
echo "Date: \t\t{$EUR->getDate()->format('m/d/Y')}\n";

Export

You can use ABGEO\NBG\Exporter Class for exporting currency data to CSV file or PHP Stream output.
ABGEO\NBG\Exporter class has export() method that takes 3 arguments:

  • currencies - Single Currency Code or array;
  • exportMode [Optional][Default: Exporter::EXPORT_2_FILE]
    • Exporter::EXPORT_2_FILE(1) - To file;
    • Exporter::Exporter::EXPORT_2_FILE(2) - To stream;
  • file [Optional][Default: currency-{current-date}.csv] - Filename to export.

Export examples

Export single currency
...
Exporter::export(CurrencyCodes::USD, Exporter::EXPORT_2_FILE, 'single.csv');
...
Export many currencies
...
Exporter::export(
    [
        CurrencyCodes::USD,
        CurrencyCodes::EUR,
        CurrencyCodes::BGN,
        CurrencyCodes::AMD,
    ],
    Exporter::EXPORT_2_STREAM
);
...

NOTE: Don't print anything before exporting to stream coz we use header() function.

Authors

  • Temuri Takalandze - Initial work - ABGEO

License

This project is licensed under the MIT License - see the LICENSE file for details

abgeo/nbg-currency 适用场景与选型建议

abgeo/nbg-currency 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 442 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 07 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「currency」 「Banking」 「nbg」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 abgeo/nbg-currency 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 abgeo/nbg-currency 我们能提供哪些服务?
定制开发 / 二次开发

基于 abgeo/nbg-currency 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 442
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 8
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-07-17