Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ Thumbs.db
# Environment
.env
.envrc

# Test scripts
scripts/
53 changes: 29 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,27 +367,32 @@ MIT License

## Feature Matrix

| Feature | Supported |
|---|:---:|
| POST /v1/key-cards (issue) | Y |
| GET /v1/key-cards/{id} | Y |
| PATCH /v1/key-cards/{id} | Y |
| GET /v1/key-cards (list) | Y |
| POST .../suspend | Y |
| POST .../resume | Y |
| POST .../unlink | Y |
| POST .../delete | Y |
| POST /v1/console/card-templates | Y |
| PUT /v1/console/card-templates/{id} | Y |
| GET /v1/console/card-templates/{id} | Y |
| GET .../logs | Y |
| GET /v1/console/pass-template-pairs | Y |
| GET /v1/console/ledger-items | Y |
| POST /v1/console/ios-preflight | Y |
| GET /v1/console/landing-pages | Y |
| POST /v1/console/landing-pages | Y |
| PATCH /v1/console/landing-pages/{id} | Y |
| GET /v1/console/credential-profiles | Y |
| POST /v1/console/credential-profiles | Y |
| Webhooks (list/create/delete) | Y |
| HID orgs (create/activate/list) | Y |
| Endpoint | Method | Supported |
|---|---|:---:|
| POST /v1/key-cards | `accessCards->provision()` | Y |
| GET /v1/key-cards/{id} | `accessCards->get()` | Y |
| PATCH /v1/key-cards/{id} | `accessCards->update()` | Y |
| GET /v1/key-cards | `accessCards->list()` | Y |
| POST /v1/key-cards/{id}/suspend | `accessCards->suspend()` | Y |
| POST /v1/key-cards/{id}/resume | `accessCards->resume()` | Y |
| POST /v1/key-cards/{id}/unlink | `accessCards->unlink()` | Y |
| POST /v1/key-cards/{id}/delete | `accessCards->delete()` | Y |
| POST /v1/console/card-templates | `console->createTemplate()` | Y |
| PUT /v1/console/card-templates/{id} | `console->updateTemplate()` | Y |
| GET /v1/console/card-templates/{id} | `console->readTemplate()` | Y |
| GET /v1/console/card-templates/{id}/logs | `console->eventLog()` | Y |
| GET /v1/console/card-template-pairs | `console->listPassTemplatePairs()` | Y |
| POST /v1/console/card-template-pairs | `console->createPassTemplatePair()` | Y |
| POST /v1/console/card-templates/{id}/ios_preflight | `console->iosPreflight()` | Y |
| GET /v1/console/ledger-items | `console->ledgerItems()` | Y |
| GET /v1/console/landing-pages | `console->listLandingPages()` | Y |
| POST /v1/console/landing-pages | `console->createLandingPage()` | Y |
| PUT /v1/console/landing-pages/{id} | `console->updateLandingPage()` | Y |
| GET /v1/console/credential-profiles | `console->credentialProfiles->list()` | Y |
| POST /v1/console/credential-profiles | `console->credentialProfiles->create()` | Y |
| GET /v1/console/webhooks | `console->listWebhooks()` | Y |
| POST /v1/console/webhooks | `console->createWebhook()` | Y |
| DELETE /v1/console/webhooks/{id} | `console->deleteWebhook()` | Y |
| POST /v1/console/hid/orgs | `console->hid->orgs->create()` | Y |
| POST /v1/console/hid/orgs/activate | `console->hid->orgs->activate()` | Y |
| GET /v1/console/hid/orgs | `console->hid->orgs->list()` | Y |
19 changes: 14 additions & 5 deletions src/Services/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,27 @@ public function eventLog(array $data): array
*/
public function listPassTemplatePairs(array $params = []): array
{
$response = $this->client->get('/v1/console/pass-template-pairs', $params);
$response = $this->client->get('/v1/console/card-template-pairs', $params);

if (isset($response['pass_template_pairs'])) {
$response['pass_template_pairs'] = array_map(
if (isset($response['card_template_pairs'])) {
$response['card_template_pairs'] = array_map(
fn($pair) => new PassTemplatePair($this->client, $pair),
$response['pass_template_pairs']
$response['card_template_pairs']
);
}

return $response;
}

/**
* Create a pass template pair
*/
public function createPassTemplatePair(array $data): PassTemplatePair
{
$response = $this->client->post('/v1/console/card-template-pairs', $data);
return new PassTemplatePair($this->client, $response);
}

/**
* List ledger items (alias matching doc examples)
*/
Expand Down Expand Up @@ -184,7 +193,7 @@ public function createLandingPage(array $data): LandingPage
*/
public function updateLandingPage(string $landingPageId, array $data): LandingPage
{
$response = $this->client->patch("/v1/console/landing-pages/{$landingPageId}", $data);
$response = $this->client->put("/v1/console/landing-pages/{$landingPageId}", $data);
return new LandingPage($this->client, $response);
}

Expand Down
24 changes: 12 additions & 12 deletions tests/Services/ConsoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ public function testIosPreflight(): void

public function testListPassTemplatePairs(): void
{
$this->expectRequest('GET', '/v1/console/pass-template-pairs', 200, [
'pass_template_pairs' => [
$this->expectRequest('GET', '/v1/console/card-template-pairs', 200, [
'card_template_pairs' => [
[
'id' => 'pair_123',
'name' => 'Employee Badge Pair',
Expand All @@ -218,11 +218,11 @@ public function testListPassTemplatePairs(): void

$result = $this->client->console->listPassTemplatePairs();

$this->assertArrayHasKey('pass_template_pairs', $result);
$this->assertArrayHasKey('card_template_pairs', $result);
$this->assertArrayHasKey('pagination', $result);
$this->assertCount(1, $result['pass_template_pairs']);
$this->assertCount(1, $result['card_template_pairs']);

$pair = $result['pass_template_pairs'][0];
$pair = $result['card_template_pairs'][0];
$this->assertInstanceOf(PassTemplatePair::class, $pair);
$this->assertEquals('pair_123', $pair->id);
$this->assertEquals('Employee Badge Pair', $pair->name);
Expand All @@ -244,35 +244,35 @@ public function testListPassTemplatePairsWithParams(): void
->with(
$this->equalTo('GET'),
$this->callback(function (string $url) {
return strpos($url, '/v1/console/pass-template-pairs') !== false
return strpos($url, '/v1/console/card-template-pairs') !== false
&& strpos($url, 'page=2') !== false
&& strpos($url, 'per_page=10') !== false;
}),
$this->anything(),
$this->anything()
)
->willReturn(new \AccessGrid\Http\HttpResponse(200, json_encode([
'pass_template_pairs' => [],
'card_template_pairs' => [],
'pagination' => ['current_page' => 2, 'per_page' => 10, 'total_pages' => 3, 'total_count' => 25],
])));

$result = $this->client->console->listPassTemplatePairs(['page' => 2, 'per_page' => 10]);

$this->assertArrayHasKey('pass_template_pairs', $result);
$this->assertCount(0, $result['pass_template_pairs']);
$this->assertArrayHasKey('card_template_pairs', $result);
$this->assertCount(0, $result['card_template_pairs']);
$this->assertEquals(2, $result['pagination']['current_page']);
}

public function testListPassTemplatePairsEmpty(): void
{
$this->expectRequest('GET', '/v1/console/pass-template-pairs', 200, [
'pass_template_pairs' => [],
$this->expectRequest('GET', '/v1/console/card-template-pairs', 200, [
'card_template_pairs' => [],
'pagination' => ['current_page' => 1, 'per_page' => 25, 'total_pages' => 0, 'total_count' => 0],
]);

$result = $this->client->console->listPassTemplatePairs();

$this->assertCount(0, $result['pass_template_pairs']);
$this->assertCount(0, $result['card_template_pairs']);
}

public function testListLedgerItems(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Services/LandingPagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testCreateLandingPage(): void

public function testUpdateLandingPage(): void
{
$this->expectRequest('PATCH', '/v1/console/landing-pages/lp_123', 200, [
$this->expectRequest('PUT', '/v1/console/landing-pages/lp_123', 200, [
'id' => 'lp_123',
'name' => 'Updated Miami Office',
'kind' => 'universal',
Expand Down
Loading