-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from wedevBr/develop
Prepare new release
- Loading branch information
Showing
16 changed files
with
317 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @adeildo-jr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace WeDevBr\Celcoin\Clients; | ||
|
||
use Illuminate\Http\Client\RequestException; | ||
use Illuminate\Support\Facades\Validator; | ||
use WeDevBr\Celcoin\Common\CelcoinBaseApi; | ||
use WeDevBr\Celcoin\Rules\KYC\CreateKycRule; | ||
use WeDevBr\Celcoin\Types\KYC\CreateKyc; | ||
|
||
class CelcoinKyc extends CelcoinBaseApi | ||
{ | ||
public const CREATE_KYC_ENDPOINT = '/v1/fileupload'; | ||
|
||
/** | ||
* @throws RequestException | ||
*/ | ||
public function createKyc(CreateKyc $data): array | ||
{ | ||
$body = Validator::validate($data->toArray(), CreateKycRule::rules()); | ||
|
||
return $this->post( | ||
self::CREATE_KYC_ENDPOINT, | ||
$body | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace WeDevBr\Celcoin\Enums; | ||
|
||
enum KycDocumentEnum: string | ||
{ | ||
case RG = 'RG'; | ||
case CNH = 'CNH'; | ||
case RNE = 'RNE'; | ||
case CARTAO_CNPJ = 'CARTAO_CNPJ'; | ||
case CONTRATO_SOCIAL = 'CONTRATO_SOCIAL'; | ||
case BALANCO = 'BALANCO'; | ||
case FATURAMENTO = 'FATURAMENTO'; | ||
case KYC_EXTERNO = 'KYC_EXTERNO'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace WeDevBr\Celcoin\Rules\KYC; | ||
|
||
use Illuminate\Validation\Rule; | ||
use WeDevBr\Celcoin\Enums\KycDocumentEnum; | ||
|
||
class CreateKycRule | ||
{ | ||
public static function rules(): array | ||
{ | ||
return [ | ||
'documentnumber' => ['required', 'digits:11,14'], | ||
'filetype' => ['required', Rule::enum(KycDocumentEnum::class)], | ||
'front' => ['required', 'file'], | ||
'verse' => ['sometimes', 'file'], | ||
'cnpj' => ['sometimes', 'same:documentnumber', 'digits:11,14'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace WeDevBr\Celcoin\Types\KYC; | ||
|
||
use WeDevBr\Celcoin\Enums\KycDocumentEnum; | ||
use WeDevBr\Celcoin\Types\Data; | ||
|
||
class CreateKyc extends Data | ||
{ | ||
public string $documentnumber; | ||
|
||
public ?string $cnpj; | ||
|
||
public KycDocumentEnum $filetype; | ||
|
||
public KycDocument $front; | ||
|
||
public ?KycDocument $verse = null; | ||
|
||
public function __construct(array $data = []) | ||
{ | ||
if (empty($data['cnpj']) && strlen($data['documentnumber']) === 14) { | ||
$data['cnpj'] = $data['documentnumber']; | ||
} | ||
parent::__construct($data); | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
$array = parent::toArray(); | ||
|
||
if (!empty($array['front'])) { | ||
$array['front'] = $this->front->file; | ||
} | ||
|
||
if ($array['verse']) { | ||
$array['verse'] = $this->verse->file; | ||
} | ||
|
||
return $array; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace WeDevBr\Celcoin\Types\KYC; | ||
|
||
use Illuminate\Http\File; | ||
use WeDevBr\Celcoin\Types\Data; | ||
|
||
class KycDocument extends Data | ||
{ | ||
public string $fileName; | ||
public string $contents; | ||
public File $file; | ||
|
||
public function __construct(File $file) | ||
{ | ||
$data['contents'] = $file->getContent(); | ||
$data['fileName'] = $file->getFilename(); | ||
$data['file'] = $file; | ||
parent::__construct($data); | ||
} | ||
|
||
public function getContents(): string | ||
{ | ||
return $this->contents; | ||
} | ||
|
||
public function getFileName(): string | ||
{ | ||
return $this->fileName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,4 @@ final static public function loginResponse(): PromiseInterface | |
Response::HTTP_OK, | ||
); | ||
} | ||
} | ||
} |
Oops, something went wrong.