Skip to content

Commit

Permalink
Add new endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipeMata committed Jan 3, 2018
1 parent 989242a commit e1172bf
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 2.1.0

- Added: new endpoint (update plan)
- Added: new endpoint (create subscription history)

# 2.0.0

- Breaking change: Drop PHP 5.4 support
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gerencianet/gerencianet-sdk-php",
"description": "GN API SDK PHP",
"version": "2.0.0",
"version": "2.1.0",
"require": {
"guzzlehttp/guzzle": "^6.0.0",
"php": ">=5.5.0"
Expand Down
28 changes: 28 additions & 0 deletions examples/subscription/createSubscriptionHistory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

require __DIR__.'/../../vendor/autoload.php';

use Gerencianet\Exception\GerencianetException;
use Gerencianet\Gerencianet;

$file = file_get_contents(__DIR__.'/../config.json');
$options = json_decode($file, true);

$params = ['id' => 0];

$body = [
'description' => 'This carnet is about a service'
];

try {
$api = new Gerencianet($options);
$response = $api->createSubscriptionHistory($params, $body);

print_r($response);
} catch (GerencianetException $e) {
print_r($e->code);
print_r($e->error);
print_r($e->errorDescription);
} catch (Exception $e) {
print_r($e->getMessage());
}
26 changes: 26 additions & 0 deletions examples/subscription/updatePlan.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

require __DIR__.'/../../vendor/autoload.php';

use Gerencianet\Exception\GerencianetException;
use Gerencianet\Gerencianet;

$file = file_get_contents(__DIR__.'/../config.json');
$options = json_decode($file, true);

$params = ['id' => 0];

$body = [ 'name' => 'My new plan' ];

try {
$api = new Gerencianet($options);
$subscription = $api->updatePlan($params, $body);

print_r($subscription);
} catch (GerencianetException $e) {
print_r($e->code);
print_r($e->error);
print_r($e->errorDescription);
} catch (Exception $e) {
print_r($e->getMessage());
}
8 changes: 8 additions & 0 deletions src/Gerencianet/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@
"updateChargeLink": {
"route": "/v1/charge/:id/link",
"method": "put"
},
"updatePlan": {
"route": "/v1/plan/:id",
"method": "put"
},
"createSubscriptionHistory": {
"route": "/v1/subscription/:id/history",
"method": "post"
}
}
}

0 comments on commit e1172bf

Please # to comment.