Skip to content

Commit

Permalink
feat: support list and get connection(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
bepsvpt committed Feb 29, 2024
1 parent 35bf876 commit 3f76239
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Objects/Connection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Storipress\Revert\Objects;

class Connection extends RevertObject
{
public string $tp_id;

public string $tp_access_token;

public ?string $tp_refresh_token = null;

public string $tp_customer_id;

public string $t_id;

public mixed $app_config = null;
}
39 changes: 39 additions & 0 deletions src/Requests/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,47 @@

namespace Storipress\Revert\Requests;

use stdClass;
use Storipress\Revert\Objects\Connection as ConnectionObject;

class Connection extends Request
{
/**
* Get details of all the connection for a specific account at Revert.
*
* @return array<int, ConnectionObject>
*
* @link https://docs.revert.dev/api-reference/api-reference/connection/get-all-connections
*/
public function list(): array
{
$data = $this->request(
'get',
'/connection/all',
isArray: true,
);

return array_map(
fn (stdClass $item) => ConnectionObject::from($item),
$data,
);
}

/**
* Get details of a connection for a specific tenant.
*
* @link https://docs.revert.dev/api-reference/api-reference/connection/get-connection
*/
public function get(): ConnectionObject
{
$data = $this->request(
'get',
'/connection',
);

return ConnectionObject::from($data);
}

/**
* Delete a connection for a specific tenant.
*
Expand Down

0 comments on commit 3f76239

Please sign in to comment.