diff --git a/src/Clients/CelcoinBAASPIX.php b/src/Clients/CelcoinBAASPIX.php index 508bfdf..ad3e610 100644 --- a/src/Clients/CelcoinBAASPIX.php +++ b/src/Clients/CelcoinBAASPIX.php @@ -2,6 +2,7 @@ namespace WeDevBr\Celcoin\Clients; +use Illuminate\Http\Client\RequestException; use Illuminate\Support\Facades\Validator; use WeDevBr\Celcoin\Common\CelcoinBaseApi; use WeDevBr\Celcoin\Rules\BAAS\PixCashOut as BAASPixCashOut; @@ -29,9 +30,12 @@ class CelcoinBAASPIX extends CelcoinBaseApi const REFUND_PIX_ENDPOINT = '/baas-wallet-transactions-webservice/v1/pix/reverse'; const STATUS_REFUND_PIX_ENDPOINT = '/baas-wallet-transactions-webservice/v1/pix/reverse/status'; + /** + * @throws RequestException + */ public function cashOut(PixCashOut $data) { - $body = Validator::validate($data->toArray(), BAASPixCashOut::rules()); + $body = Validator::validate($data->toArray(), BAASPixCashOut::rules($data->initiationType->value)); return $this->post( self::CASH_OUT_ENDPOINT, $body diff --git a/src/Rules/BAAS/PixCashOut.php b/src/Rules/BAAS/PixCashOut.php index 070558b..49fdb72 100644 --- a/src/Rules/BAAS/PixCashOut.php +++ b/src/Rules/BAAS/PixCashOut.php @@ -14,12 +14,13 @@ class PixCashOut /** * @see https://developers.celcoin.com.br/docs/realizar-um-pix-cash-out-por-chaves-pix * @see https://developers.celcoin.com.br/docs/realizar-um-pix-cash-out + * @param string $initiationTypeEnum * @return array */ - public static function rules(): array + public static function rules(string $initiationTypeEnum): array { - return match (request()->initiationType) { + return match ($initiationTypeEnum) { InitiationTypeEnum::PAYMENT_MANUAL->value => self::manual(), InitiationTypeEnum::PAYMENT_DICT->value => self::dict(), InitiationTypeEnum::PAYMENT_STATIC_BRCODE->value => self::static(), @@ -76,7 +77,7 @@ private static function dict(): array [ 'transactionIdentification' => ['prohibited'], 'endToEndId' => ['required'], - 'creditParty.*' => ['required', 'array'], + 'creditParty' => ['required', 'array'], 'creditParty.key' => ['required'], ] ); diff --git a/tests/Integration/BAAS/PixCashOut/BAASPIXCashOutTest.php b/tests/Integration/BAAS/PixCashOut/BAASPIXCashOutTest.php index 677c59f..29b5683 100644 --- a/tests/Integration/BAAS/PixCashOut/BAASPIXCashOutTest.php +++ b/tests/Integration/BAAS/PixCashOut/BAASPIXCashOutTest.php @@ -31,7 +31,6 @@ final public function testSuccess(): void new PixCashOut([ "amount" => 5.55, "clientCode" => "1234ab", - "transactionIdentification" => fake()->uuid(), "endToEndId" => "E1393589320230724213001637810511", "initiationType" => "DICT", "paymentType" => "IMMEDIATE",