diff --git a/composer.json b/composer.json index faedc16..525aeb1 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/src/Clients/CelcoinBAAS.php b/src/Clients/CelcoinBAAS.php index 4f69066..540d5fd 100644 --- a/src/Clients/CelcoinBAAS.php +++ b/src/Clients/CelcoinBAAS.php @@ -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()); @@ -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')) + ); + } } diff --git a/tests/Integration/BAAS/IncomeReportTest.php b/tests/Integration/BAAS/IncomeReportTest.php new file mode 100644 index 0000000..e577831 --- /dev/null +++ b/tests/Integration/BAAS/IncomeReportTest.php @@ -0,0 +1,65 @@ + 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" + ] + ]; + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php index e44e042..83dfd47 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -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; @@ -23,7 +22,6 @@ public function setUp(): void protected function getPackageProviders($app) { return [ - LaraDumpsServiceProvider::class, CelcoinServiceProvider::class, ]; } @@ -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(); } }