Skip to content

Commit dd7a984

Browse files
committed
Update code example
1 parent 3c65691 commit dd7a984

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

README.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ Primero es necesario obtener el client_id, client_secret desde el portal de SUNA
2121

2222
```php
2323
<?php
24-
2524
$apiInstance = new Greenter\Sunat\GRE\Api\AuthApi(
2625
new GuzzleHttp\Client()
2726
);
@@ -41,7 +40,28 @@ try {
4140

4241
```
4342

44-
## Models
43+
Enviar comprobante
44+
```php
45+
$config = Greenter\Sunat\GRE\Configuration::getDefaultConfiguration()
46+
->setAccessToken($token);
47+
48+
$cpeApi = new Greenter\Sunat\GRE\Api\CpeApi(
49+
new GuzzleHttp\Client(),
50+
$config->setHost('https://api.sunat.gob.pe/v1')
51+
);
52+
53+
$greZip = file_get_contents('20161515648-09-T001-124.zip');
54+
$doc = (new Greenter\Sunat\GRE\Model\CpeDocument())
55+
->setArchivo((new Greenter\Sunat\GRE\Model\CpeDocumentArchivo())
56+
->setNomArchivo('20161515648-09-T001-124.zip')
57+
->setArcGreZip(base64_encode($greZip))
58+
->setHashZip(hash('sha256', $greZip))
59+
);
60+
$result = $cpeApi->enviarCpe('20161515648-09-T001-124', $doc);
61+
$ticket = $result->getNumTicket();
62+
```
63+
64+
## Doc Models
4565

4666
- [ApiToken](docs/Model/ApiToken.md)
4767
- [CpeDocument](docs/Model/CpeDocument.md)
@@ -51,22 +71,3 @@ try {
5171
- [CpeResponse](docs/Model/CpeResponse.md)
5272
- [StatusResponse](docs/Model/StatusResponse.md)
5373
- [StatusResponseError](docs/Model/StatusResponseError.md)
54-
55-
## Authorization
56-
57-
### sunat_auth
58-
59-
- **Type**: Bearer authentication
60-
61-
## Tests
62-
63-
To run the tests, use:
64-
65-
```bash
66-
composer install
67-
vendor/bin/phpunit
68-
```
69-
70-
## Author
71-
72-
me@giansalex.dev

0 commit comments

Comments
 (0)