承接 mrzard/open-exchange-rates-service 相关项目开发

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

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

mrzard/open-exchange-rates-service

Composer 安装命令:

composer require mrzard/open-exchange-rates-service

包简介

OpenExchangeRates API exposure

README 文档

README

SensioLabsInsight Scrutinizer Code Quality Build Status

This service will help you use OpenExchangeRates in your project

Installation

Use composer to require and install the service

$ php composer.phar require mrzard/open-exchange-rates-service ~1.0.0

Configuration

When creating an instance of the service, you will have to provide the basic data needed for accessing the OpenExchangeRates API and a HTTP client compatible with HttpClientInterface like GuzzleHttp\Client

    use Mrzard\OpenExchangeRates\Service\OpenExchangeRatesService;
    use GuzzleHttp\Client;
    ...

    $apiOptions = array(
        'https' => false,
        'base_currency' => 'USD'
    );

    new OpenExchangeRatesService(
        $openExchangeRatesApiId, // your id from openExchangeRatesApi
        $apiOptions,
        new Client()
    );
    ...

If you're using a free version, you won't need to change the https or base_currency as they only work for Enterprise/Unlimited accounts

Note on HTTP client

compatible in current context means that the client MUST have methods with next signatures:

public HttpRequestInterface request(string method, string url = null, array $options = []);

public HttpResponseInterface send(HttpRequestInterface request);

Also wrapper doesn't require returned values to implement that interface, but MUST be also compatible

Usage

Free features

Get latest exchange rates

    /**
     * Get the latest exchange rates
     *
     * @param array  $symbols Currency codes to get the rates for. Default all
     * @param string $base    Base currency, default NULL (gets it from config)
     *
     * @return array
     */
    public function getLatest($symbols = array, $base = null)
    {
    }

Only use the $symbols and $base parameters if you have an Enterprise or Unlimited plan.

Output:

    array (size=5)

          'disclaimer' => string 'Exchange rates...'

          'license' => string 'Data sourced from...'

          'timestamp' => int 1395396061

          'base' => string 'USD' (length=3)

          'rates' =>

                array (size=166)

                  'AED' => float 3.672721

                  'AFN' => float 56.747225

                  'ALL' => float 101.7573

                  'AMD' => float 417.366998

                  ...
            )
    )

Get available currencies

    /**
     * Gets a list of all available currencies
     *
     * @return array with keys = ISO codes, content = Currency Name
     */
    public function getCurrencies()
    {
    }

Output:

    array (size=5)

          'AED' => 'United Arab Emirates Dirham'

          'AFN' => 'Afghan Afghani'

          'ALL' => 'Albanian Lek'

          'AMD' => 'Armenian Dram'

          'ANG' => 'Netherlands Antillean Guilder'

          ...

    )

Get historical data for a date

    /**
     * Get historical data
     *
     * @param \DateTime $date
     * @param array  $symbols array of currency codes to get the rates for.
     *                        Default empty (all currencies)
     * @param string $base    Base currency, default NULL (gets it from config)
     *
     */
    public function getHistorical(\DateTime $date)
    {
    }

Only use the $symbols and $base parameters if you have a Developer, Enterprise or Unlimited plan.

Output:

    array (size=5)

        'disclaimer' => string 'Exchange rates...'

        'license' => string 'Data sourced from...'

        'timestamp' => int 1388617200

        'base' => string 'USD' (length=3)

        'rates' =>

            array (size=166)

                'AED' => float 3.672524

                'AFN' => float 56.0846

                'ALL' => float 102.06575

                'AMD' => float 408.448002

                'ANG' => float 1.78902

                'AOA' => float 97.598401

                'ARS' => float 6.51658

                'AUD' => float 1.124795

                'AWG' => float 1.789775

                'AZN' => float 0.7841

                'BAM' => float 1.421715

                'BBD' => int 2
          ...
        )
    )

Developer / Unlimited features

Get the latest exchange rates, limiting the return array

    $openExchangeRatesService->getLatest(array('EUR', 'USD', 'COP'));

Output:

    array (size=5)

          'disclaimer' => string 'Exchange rates ...'

          'license' => string 'Data sourced...'

          'timestamp' => int 1395396061

          'base' => string 'USD' (length=3)

          'rates' =>

                array (size=3)

                  'EUR' => ...,

                  'USD' => ...,

                  'COP' => ...

                )

    )

You can also change the base currency used to get the latest exchange rates with the second parameter

Directly convert a quantity between currencies

    $openExchangeRatesService->convert(10, 'USD', 'EUR');

mrzard/open-exchange-rates-service 适用场景与选型建议

mrzard/open-exchange-rates-service 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 74.76k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2014 年 08 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 mrzard/open-exchange-rates-service 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-08-04