kattatzu/sbif
Composer 安装命令:
composer require kattatzu/sbif
包简介
Consulta de indicadores al API de la SBIF (Chile)
README 文档
README
Libreria que permite consultar el valor de indicadores al API de la superintendencia de bancos e instituciones financieras (SBIF) de Chile. Pueden acceder a los siguientes indicadores:
- Dólar
- Euro
- UF
- UTM
- IPC
Además se puede acceder a información de bancos de Chile.
Obtener API key
Para usar el API de la SBIF debes obtener tu APIKEY en la siguiente página: http://api.sbif.cl/api/contactanos.jsp
Instalación
Para instalar la librería ejecuta el siguiente comando en la consola:
composer require kattatzu/sbif
Uso de forma Standalone
Si tu sistema no trabaja con Laravel puedes usarlo de forma directa:
use Kattatzu/Sbif/Sbif; $sbif = new Sbif('SBIF API KEY'); // o $sbif = new Sbif; $sbif->apiKey('SBIF API KEY'); echo $sbif->getDollar('2017-04-30'); //664.0
Indicadores disponibles
$date = Carbon::today(); $sbif->getDollar($date); $sbif->getEuro($date); $sbif->getUTM($date); $sbif->getUF($date); $sbif->getIPC($date); // NOTA: El IPC solo tiene valor hasta el mes anterior // Si no envias una fecha se toma la fecha actual $sbif->getDollar();
También puedes consultar de forma dinámica
$sbif->getIndicator(Sbif::IND_EURO, $date);
Constantes disponibles
Sbif::IND_UF Sbif::IND_UTM Sbif::IND_DOLLAR Sbif::IND_EURO Sbif::IND_IPC
Puedes acceder al resto de los datos que disponibiliza la SBIF (http://api.sbif.cl/que-es-api.html) enviando directamente el endpoint que corresponda:
var_dump($sbif->get("/resultados/2009/12/instituciones")); object(stdClass){ "DescripcionesCodigosDeInstituciones": [ "0" => { "CodigoInstitucion": "001", "NombreInstitucion": "BANCO DE CHILE" }, "1" => { "CodigoInstitucion": "014", "NombreInstitucion": "SCOTIABANK CHILE" }, ... ] }
Información de Bancos
Puedes consultar la información que disponibiliza la SBIF sobre los bancos de Chile.
$info = $sbif->getInstitutionData('001'); echo $info->name; // BANCO DE CHILE
Puedes obtener la información como un array:
$info = $sbif->getInstitutionData('001')->toArray(); var_dump($info);
[ "code" => "001", "name" => "BANCO DE CHILE", "swift_code" => "BCHI CL RM", "rut" => "97.004.000-5", "address" => "AHUMADA 251", "phone" => "(56-2) 653 11 11", "website" => "www.bancochile.cl", "public_contact" => "Pamela Valdivia", "public_address" => "Huérfanos 980, 8º Piso, Santiago", "public_phone" => "(56-2) 653 06 73", "branches" => 403, "employees" => 11426, "publication_date" => "2017-05-01", "cashiers" => 1412 ]
Para obtener el listado de códigos puedes usar la clase Institution:
use Kattatzu\Sbif\Institution; var_dump((new Institution)->getInstitutions());
[ "001" => "Banco de Chile", "009" => "Banco Internacional", "014" => "Scotiabank Chile", "016" => "Banco de Credito E Inversiones", "028" => "Banco Bice", "031" => "HSBC Bank (chile)", "037" => "Banco Santander-chile", "039" => "Itaú Corpbanca", "049" => "Banco Security", "051" => "Banco Falabella", "053" => "Banco Ripley", "054" => "Rabobank Chile", "055" => "Banco Consorcio", "056" => "Banco Penta", "504" => "Banco BBVA", "059" => "Banco BTG Pactual Chile", "012" => "Banco del Estado de Chile", "017" => "Banco Do Brasil S.A.", "041" => "JP Morgan Chase Bank, N. A.", "043" => "Banco de la Nacion Argentina", "045" => "The Bank of Tokyo-mitsubishi UFJ", "060" => "China Construction Bank" ]
Instalación y Uso en Laravel
Después de hacer la instalación con Composer debes registrar el ServiceProvider y el alias en tu archivo config/app.php:
'providers' => [ ... Kattatzu\Sbif\Providers\SbifServiceProvider::class, ], 'aliases' => [ ... 'Sbif' => Kattatzu\Sbif\Facades\SbifFacade::class, ]
Publica el archivo de configuración ejecutando en Artisan:
php artisan vendor:publish --provider="Kattatzu\Sbif\Providers\SbifServiceProvider"
Ya puedes ingresar tu API Key en el archivo de configuración config/sbif.php o en en archivo .env con la key SBIF_API_KEY.
SBIF_API_KEY=xxxxxxxxxxxxxxxxxxxx
Facades
Ya puedes usar el Facade para acceder de forma rápida a las funciones:
Sbif::getDollar(); Sbif::getUTM('2017-06-30'); Sbif::getUF(Carbon::today());
Helpers
También puedes utilizar los helpers:
sbif_dollar(); sbif_euro('2017-06-30'); sbif_utm(Carbon::yesterday()); sbif_uf(Carbon::now()->subMonth(1)); sbif_ipc(); sbif_institution('001')->name; sbif_institutions();
No dudes en enviarme tus feedbacks o pull-request para mejorar esta librería.
Licencia
MIT License
Copyright (c) 2017 José Eduardo Ríos
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
kattatzu/sbif 适用场景与选型建议
kattatzu/sbif 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.01k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2017 年 07 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「ipc」 「illuminate」 「uf」 「chile」 「UTM」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 kattatzu/sbif 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 kattatzu/sbif 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 kattatzu/sbif 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Janis IPC manager
Convert has() and whereHas() constraints to non-dependent subqueries.
Synchronous Message Passing Framework for PHP
A fluent PHP library for supervised master-child process control using pcntl and pipes
Simple PHP Inter Process Communication (IPC) library
This package provides a flexible way to add Role-based Permissions to Laravel 6.x
统计信息
- 总下载量: 1.01k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-07-14