fedeisas / laravel-dolar-blue by fedeisas

Laravel package to fetch latest USD conversion rate on Argentina's black market
17
7
2
Package Data
Maintainer Username: fedeisas
Maintainer Contact: fedeisas@hotmail.com (Fede Isas)
Package Create Date: 2014-05-03
Package Last Update: 2014-10-18
Language: PHP
License: MIT
Last Refreshed: 2024-04-19 15:06:45
Package Statistics
Total Downloads: 17
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 7
Total Watchers: 2
Total Forks: 1
Total Open Issues: 1

Laravel Dolar Blue

Travis Badge Coverage Status Latest Stable Version Latest Unstable Version Total Downloads License

Why?

Because Argentina has a black market for currency exchange. And this makes it easy to retrieve the current USD conversion rate from different sources. And also because I needed something small to talk about Package Development and testing on this meetup.

Requirements

  • Laravel 4
  • PHP >= 5.4

Installation

Begin by installing this package through Composer. Edit your project's composer.json file to require `fedeisas/laravel-dolar-blue.

{
  "require": {
        "laravel/framework": "4.0.*",
        "fedeisas/laravel-dolar-blue": "dev-master"
    },
    "minimum-stability" : "dev"
}

Next, update Composer from the Terminal:

$ composer update

Once this operation completes, the final step is to add the service provider. Open app/config/app.php, and add a new item to the providers array.

'providers' => array(
    ...
    'Fedeisas\LaravelDolarBlue\LaravelDolarBlueServiceProvider',
)

Optionally you can also add the Facade to the aliases array on app/config/app.php:

'aliases' => array(
    ...
    'DolarBlue' => 'Fedeisas\LaravelDolarBlue\Facade\LaravelDolarBlue',
)

Usage

Currenly it only supports 3 providers (more to come):

  • LaNacion
  • DolarBlue
  • BlueLytics
$service = App::make('Fedeisas\LaravelDolarBlue\LaravelDolarBlue');
$result = $service->get('DolarBlue'); // or $service->DolarBlue();
// returns
// array(
//   'buy' => '10.15',
//   'sell' => '10.55',
//   'timestamp' => 1399080004
// )

Or you can use the facade:

$result = DolarBlue::get('LaNacion');

// and using some __call magic
$result = DolarBlue::LaNacion();
$result = DolarBlue::DolarBlue();
$result = DolarBlue::BlueLytics();

Contributing

$ composer install --dev
$ ./vendor/bin/phpunit

In addition to a full test suite, there is Travis integration.

Found a bug?

Please, let me know! Send a pull request or a patch. Questions? Ask! I will respond to all filed issues.

Inspiration

I needed an idea for a small library, and I borrowed it from a friend who has done something similar for NodeJS. You should check it out: https://github.com/matiu/dolar-blue

License

This package is open-sourced software licensed under the MIT license