Skip to content

Commit

Permalink
Merge pull request #49 from wedevBr/develop
Browse files Browse the repository at this point in the history
Deploy
  • Loading branch information
adeildo-jr authored Mar 1, 2024
2 parents a8b1ff9 + d544413 commit 1af8953
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 6 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"require-dev": {
"orchestra/testbench": "^7.24.1",
"phpunit/phpunit": "^9.6.9",
"laradumps/laradumps": "^2.0",
"phpstan/phpstan": "^1.10"
},
"extra": {
Expand Down
13 changes: 13 additions & 0 deletions src/Clients/CelcoinBAAS.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class CelcoinBAAS extends CelcoinBaseApi
const GET_WALLET_MOVEMENT = '/baas-walletreports/v1/wallet/movement';
const CREATE_RELEASE = '/baas-wallet-transactions-webservice/v1/wallet/entry/%s';

const INCOME_REPORT = '/baas-accountmanager/v1/account/income-report?Account=%s&CalendarYear=%s';

public function createAccountNaturalPerson(AccountNaturalPerson $data)
{
$body = Validator::validate($data->toArray(), BAASAccountNaturalPerson::rules());
Expand Down Expand Up @@ -181,4 +183,15 @@ public function createRelease(string $account, AccountRelease $data)
$body
);
}

/**
* @throws RequestException
*/
public function getIncomeReport(string $account, Carbon $referenceYear): mixed
{
return $this
->get(
sprintf(self::INCOME_REPORT, $account, $referenceYear->format('Y'))
);
}
}
65 changes: 65 additions & 0 deletions tests/Integration/BAAS/IncomeReportTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace WeDevBr\Celcoin\Tests\Integration\BAAS;

use Carbon\Carbon;
use Illuminate\Support\Facades\Http;
use WeDevBr\Celcoin\Clients\CelcoinBAAS;
use WeDevBr\Celcoin\Tests\GlobalStubs;
use WeDevBr\Celcoin\Tests\TestCase;

class IncomeReportTest extends TestCase
{
public function testSuccess()
{
Http::fake(
[
config('celcoin.login_url') => GlobalStubs::loginResponse(),
sprintf(
'%s%s',
config('api_url'),
sprintf(CelcoinBAAS::INCOME_REPORT, '300541976902', '2024'),
) => self::stubSuccess(),
],
);

$baas = new CelcoinBAAS();
$response = $baas->getIncomeReport('300541976902', Carbon::parse('2024'));

$this->assertEquals('SUCCESS', $response['status']);
}

public static function stubSuccess(): array
{
return [
"version" => "1.0.0",
"status" => "SUCCESS",
"body" => [
"payerSource" => [
"name" => "Celcoin Teste S/A",
"documentNumber" => "123456"
],
"owner" => [
"documentNumber" => "01234567890",
"name" => "Nome Completo",
"type" => "NATURAL_PERSON",
"createDate" => "15-07-1986"
],
"account" => [
"branch" => "1234",
"account" => "123456"
],
"balances" => [
[
"calendarYear" => "2025",
"amount" => 10.5,
"currency" => "BRL",
"type" => "SALDO"
]
],
"incomeFile" => "string",
"fileType" => "string"
]
];
}
}
5 changes: 0 additions & 5 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Dotenv\Dotenv;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use LaraDumps\LaraDumps\LaraDumpsServiceProvider;
use Orchestra\Testbench\Concerns\CreatesApplication;
use WeDevBr\Celcoin\CelcoinServiceProvider;

Expand All @@ -23,7 +22,6 @@ public function setUp(): void
protected function getPackageProviders($app)
{
return [
LaraDumpsServiceProvider::class,
CelcoinServiceProvider::class,
];
}
Expand All @@ -33,14 +31,11 @@ protected function getEnvironmentSetUp($app)
$root = __DIR__ . '/../';
$dotenv = Dotenv::createImmutable($root);
$dotenv->safeLoad();
$app['config']->set('laradumps', require(__DIR__ . '../../config/laradumps.php'));
$app['config']->set('cache.default', env('CACHE_DRIVER', 'file'));
$app['config']->set('celcoin.client_id', env('CELCOIN_CLIENT_ID', null));
$app['config']->set('celcoin.client_secret', env('CELCOIN_CLIENT_SECRET', null));
$app['config']->set('celcoin.mtls_cert_path', env('CELCOIN_MTLS_CERT_PATH', null));
$app['config']->set('celcoin.mtls_key_path', env('CELCOIN_MTLS_KEY_PATH', null));
$app['config']->set('celcoin.mtls_passphrase', env('CELCOIN_MTLS_PASSPHRASE', null));

ds()->httpOn();
}
}

0 comments on commit 1af8953

Please sign in to comment.