apihub-cdc/rc-peru-client-simulacion-php

此包最新版本(v1.0.0)没有提供许可证信息。

v1.0.0 2020-06-05 17:21 UTC

This package is auto-updated.

Last update: 2024-09-07 03:33:56 UTC


README

报告自然人及法人信用,考虑公共和私人来源。

要求

PHP 7.1 或更高版本

额外依赖

  • 必须具备以下PHP依赖项
    • ext-curl
    • ext-mbstring
  • 如果不在Linux上,请使用以下命令
#ejemplo con php en versión 7.3 para otra versión colocar php{version}-curl
apt-get install php7.3-curl
apt-get install php7.3-mbstring

安装

执行: composer install

入门指南

步骤 1. 将产品添加到应用程序

登录后按照以下步骤操作

  1. 点击“我的应用程序”部分。
  2. 选择应用程序。
  3. 转到“编辑 '@tuApp'”选项卡。

  4. 打开窗口后,选择产品。
  5. 点击“保存 App”按钮

步骤 2. 捕获请求数据

以下需要修改的数据位于 test/Api/ApiTest.php

重要:需要具有setUp(),用于初始化url。修改对象 $config 中的请求URL ('the_url'),如下代码片段所示

public function setUp()
{
    $handler = \GuzzleHttp\HandlerStack::create();
    $config = new \rc\simulacion\pe\Client\Configuration();
    $config->setHost('the_url');

    $client = new \GuzzleHttp\Client(['handler' => $handler]);
    $this->apiInstance = new \rc\simulacion\pe\Client\Api\ReporteCreditoPeruSimulacionApi($client, $config);
    $this->x_api_key = "your_api_key";
} 

/**
* Este es el método que se será ejecutado en la prueba ubicado en path/to/repository/test/Api/ApiTest.php
*/
public function testGetRC()
{

    $request = new \rc\simulacion\pe\Client\Model\Peticion();

    $request->setFolio("10000200");
    $request->setNumeroDocumento("67544489");
    $request->setTipoDocumento("1");

    try {
        $result = $this->apiInstance->getRC($this->x_api_key, $request);
        
        if($this->apiInstance->getStatusCode() == 200){
            print_r($result);
        }
    } catch (ApiException $e) {

        if($e->getCode() !== 204){
            echo ' code. Exception when calling ApiTest->getRC: ', $e->getResponseBody(), PHP_EOL;
        }
    }
    $this->assertTrue($this->apiInstance->getStatusCode() == 200);

}

单元测试

要执行单元测试

./vendor/bin/phpunit