diff --git a/.gitignore b/.gitignore index 2b748f4..c10d63b 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,6 @@ Thumbs.db # Environment .env .envrc + +# Test scripts +scripts/ diff --git a/README.md b/README.md index 8c6fbc4..29b0fd0 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/src/Services/Console.php b/src/Services/Console.php index 6f07557..b6cb219 100644 --- a/src/Services/Console.php +++ b/src/Services/Console.php @@ -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) */ @@ -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); } diff --git a/tests/Services/ConsoleTest.php b/tests/Services/ConsoleTest.php index c37d359..44d85b8 100644 --- a/tests/Services/ConsoleTest.php +++ b/tests/Services/ConsoleTest.php @@ -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', @@ -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); @@ -244,7 +244,7 @@ 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; }), @@ -252,27 +252,27 @@ public function testListPassTemplatePairsWithParams(): void $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 diff --git a/tests/Services/LandingPagesTest.php b/tests/Services/LandingPagesTest.php index 941c53c..e64c17b 100644 --- a/tests/Services/LandingPagesTest.php +++ b/tests/Services/LandingPagesTest.php @@ -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',