Skip to content

Commit 5d0551c

Browse files
✨ feat: Added a new endpoint to change expire date of carnet
1 parent 72e089b commit 5d0551c

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
/**
4+
* Detailed endpoint documentation
5+
* https://dev.efipay.com.br/docs/api-cobrancas/carne#alterar-data-de-vencimento-de-parcela-do-carnê
6+
*/
7+
8+
$autoload = realpath(__DIR__ . "/../../../vendor/autoload.php");
9+
if (!file_exists($autoload)) {
10+
die("Autoload file not found or on path <code>$autoload</code>.");
11+
}
12+
require_once $autoload;
13+
14+
use Efi\Exception\EfiException;
15+
use Efi\EfiPay;
16+
17+
$options = __DIR__ . "/../../credentials/options.php";
18+
if (!file_exists($options)) {
19+
die("Options file not found or on path <code>$options</code>.");
20+
}
21+
require $options;
22+
23+
$params = [
24+
"id" => 0
25+
];
26+
27+
$body = [
28+
"parcels" => [
29+
[
30+
"parcel" => 2,
31+
"expire_at" => "2025-02-28"
32+
],
33+
[
34+
"parcel" => 3,
35+
"expire_at" => "2025-03-31"
36+
],
37+
[
38+
"parcel" => 4,
39+
"expire_at" => "2025-04-30"
40+
]
41+
]
42+
];
43+
44+
try {
45+
$api = new EfiPay($options);
46+
$response = $api->updateCarnetParcels($params, $body);
47+
48+
print_r("<pre>" . json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) . "</pre>");
49+
} catch (EfiException $e) {
50+
print_r($e->code . "<br>");
51+
print_r($e->error . "<br>");
52+
print_r($e->errorDescription) . "<br>";
53+
} catch (Exception $e) {
54+
print_r($e->getMessage());
55+
}

src/Efi/EfiPay.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* @method array createCarnet(array $params = [], array $body)
2121
* @method array detailCarnet(array $params)
2222
* @method array updateCarnetParcel(array $params, array $body)
23+
* @method array updateCarnetParcels(array $params, array $body)
2324
* @method array updateCarnetMetadata(array $params, array $body)
2425
* @method array getNotification(array $params)
2526
* @method array listPlans(array $params)

src/Efi/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@
6262
"route": "/v1/carnet/:id/parcel/:parcel",
6363
"method": "put"
6464
},
65+
"updateCarnetParcels": {
66+
"route": "/v1/carnet/:id/parcels",
67+
"method": "put"
68+
},
6569
"updateCarnetMetadata": {
6670
"route": "/v1/carnet/:id/metadata",
6771
"method": "put"

0 commit comments

Comments
 (0)