Skip to content

Commit

Permalink
insert and change endPoints
Browse files Browse the repository at this point in the history
  • Loading branch information
noemimpimentel committed Nov 29, 2023
1 parent 8daf871 commit 9016b58
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 191 deletions.
15 changes: 0 additions & 15 deletions .editorconfig

This file was deleted.

18 changes: 18 additions & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = Finder::create()
->in(__DIR__);

$config = new Config();
$config->setRules([
'@PSR2' => true,
'array_indentation' => true,
'array_syntax' => ['syntax' => 'short']
])
->setLineEnding("\n")
->setFinder($finder);

return $config;
40 changes: 0 additions & 40 deletions .php_cs.dist.php

This file was deleted.

15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@
"Bildvitta\\IssJuridico\\Tests\\": "tests"
}
},
"scripts": {
"analyse": "vendor/bin/phpstan analyse",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest coverage"
},
"config": {
"sort-packages": true,
"allow-plugins": {
Expand All @@ -61,5 +56,13 @@
}
},
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": true,
"scripts": {
"check-style": [
"vendor/bin/php-cs-fixer fix --config .php-cs-fixer.php --diff --verbose --dry-run"
],
"fix-style": [
"vendor/bin/php-cs-fixer fix --config .php-cs-fixer.php"
]
}
}
2 changes: 1 addition & 1 deletion src/Contracts/IssJuridicoFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface IssJuridicoFactory
public const DEFAULT_HEADERS = [
'content-type' => 'application/json',
'accept' => 'application/json',
'User-Agent' => 'ISS v0.0.1-alpha',
'User-Agent' => 'iss-juridico v0.0.1-alpha',
];

public const DEFAULT_OPTIONS = ['allow_redirects' => false];
Expand Down
15 changes: 0 additions & 15 deletions src/Contracts/Resources/ContractContract.php

This file was deleted.

15 changes: 0 additions & 15 deletions src/Contracts/Resources/Programmatic/ContractContract.php

This file was deleted.

21 changes: 4 additions & 17 deletions src/IssJuridico.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

use Bildvitta\IssJuridico\Contracts\IssJuridicoFactory;
use Bildvitta\IssJuridico\Resources\Contracts;
use Bildvitta\IssJuridico\Resources\Programmatic\Programmatic;
use Bildvitta\IssJuridico\Resources\Documents;
use Illuminate\Http\Client\Factory as HttpClient;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Http;

Expand Down Expand Up @@ -35,12 +34,7 @@ public function setToken(string $token, bool $programmatic = false)

if ($programmatic) {
$clientId = Config::get('hub.programatic_access.client_id');
if (Cache::has($clientId)) {
$accessToken = Cache::get($clientId);
} else {
$accessToken = $this->getToken();
Cache::add($clientId, $accessToken, now()->addSeconds(31536000));
}
$accessToken = $this->getToken();
$this->token = $accessToken;
}

Expand Down Expand Up @@ -82,16 +76,9 @@ public function getHeaders()
);
}

public function contracts(): Contracts
public function documents(): Documents
{
return new Contracts($this);
return new Documents($this);
}

/**
* @return Programmatic
*/
public function programmatic(): Programmatic
{
return new Programmatic($this);
}
}
31 changes: 0 additions & 31 deletions src/Resources/Contracts.php

This file was deleted.

94 changes: 94 additions & 0 deletions src/Resources/Documents.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

namespace Bildvitta\IssJuridico\Resources;

use Bildvitta\IssJuridico\IssJuridico;

class Documents
{
private IssJuridico $juridico;


public function __construct(IssJuridico $juridico)
{
$this->juridico = $juridico;
}

public function list($data)
{
return $this->juridico->request->get(
'documents',
$data
)->throw()->object();
}

public function send($data)
{
return $this->juridico->request->post(
'documents/send',
$data
)->throw()->object();
}

public function view($data)
{
return $this->juridico->request->post(
'documents/view',
$data
)->throw()->object();
}

public function historic($data)
{
return $this->juridico->request->get(
sprintf('documents/historic'),
$data
)->throw()->object();
}

public function historicDocument($uuidDocument,$data)
{
return $this->juridico->request->get(
sprintf('documents/%s/historic', $uuidDocument),
$data
)->throw()->object();
}

public function download($uuidDocument)
{
return $this->juridico->request->get(
sprintf('documents/%s/download', $uuidDocument),
)->throw()->object();
}

public function verifySignatures($uuidDocument)
{
return $this->juridico->request->get(
sprintf('documents/%s/verify-signatures', $uuidDocument),
)->throw()->object();
}

public function cancel($uuidDocument,$data)
{
return $this->juridico->request->get(
sprintf('documents/%s/cancel', $uuidDocument),
$data
)->throw()->object();
}

public function resendSigner($uuidDocument, $uuidSigner)
{
return $this->juridico->request->get(
sprintf('documents/%s/resend-signer/%s', $uuidDocument, $uuidSigner)
)->throw()->object();
}

public function changeSigner($uuidDocument, $uuidSigner,$data)
{
return $this->juridico->request->get(
sprintf('documents/%s/change-signer/%s', $uuidDocument, $uuidSigner),
$data
)->throw()->object();
}

}
31 changes: 0 additions & 31 deletions src/Resources/Programmatic/Contracts.php

This file was deleted.

20 changes: 0 additions & 20 deletions src/Resources/Programmatic/Programmatic.php

This file was deleted.

0 comments on commit 9016b58

Please sign in to comment.