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
79 changes: 78 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@ $card = $client->accessCards->provision([
'card_template_id' => '0xd3adb00b5',
'employee_id' => '123456789',
'tag_id' => 'DDEADB33FB00B5',
'allow_on_multiple_devices' => true,
'full_name' => 'Employee name',
'email' => 'employee@yourwebsite.com',
'phone_number' => '+19547212241',
'classification' => 'full_time',
'department' => 'Engineering',
'location' => 'San Francisco',
'site_name' => 'HQ Building A',
'workstation' => '4F-207',
'mail_stop' => 'MS-401',
'company_address' => '123 Main St, San Francisco, CA 94105',
'start_date' => (new DateTime('now', new DateTimeZone('UTC')))->format('c'),
'expiration_date' => '2026-04-01T00:00:00.000Z',
'employee_photo' => '[image_in_base64_encoded_format]',
Expand Down Expand Up @@ -83,6 +88,12 @@ $card = $client->accessCards->update([
'employee_id' => '987654321',
'full_name' => 'Updated Employee Name',
'classification' => 'contractor',
'department' => 'Marketing',
'location' => 'New York',
'site_name' => 'NYC Office',
'workstation' => '2F-105',
'mail_stop' => 'MS-200',
'company_address' => '456 Broadway, New York, NY 10013',
'expiration_date' => (new DateTime('now', new DateTimeZone('UTC')))->modify('+3 months')->format('c'),
'employee_photo' => '[image_in_base64_encoded_format]',
'title' => 'Senior Developer'
Expand Down Expand Up @@ -277,6 +288,67 @@ $result = $client->console->hid->orgs->activate([
]);
```

### Landing Pages

```php
// List all landing pages
$landingPages = $client->console->listLandingPages();

foreach ($landingPages as $page) {
echo "ID: {$page->id}, Name: {$page->name}, Kind: {$page->kind}\n";
echo " Password Protected: {$page->password_protected}\n";
if ($page->logo_url) {
echo " Logo URL: {$page->logo_url}\n";
}
}

// Create a landing page
$landingPage = $client->console->createLandingPage([
'name' => 'Miami Office Access Pass',
'kind' => 'universal',
'additional_text' => 'Welcome to the Miami Office',
'bg_color' => '#f1f5f9',
'allow_immediate_download' => true
]);

echo "Landing page created: {$landingPage->id}\n";
echo "Name: {$landingPage->name}, Kind: {$landingPage->kind}\n";

// Update a landing page
$landingPage = $client->console->updateLandingPage('0xlandingpage1d', [
'name' => 'Updated Miami Office Access Pass',
'additional_text' => 'Welcome! Tap below to get your access pass.',
'bg_color' => '#e2e8f0'
]);

echo "Landing page updated: {$landingPage->id}\n";
echo "Name: {$landingPage->name}\n";
```

### Credential Profiles

```php
// List all credential profiles
$profiles = $client->console->credentialProfiles->list();

foreach ($profiles as $profile) {
echo "ID: {$profile->id}, Name: {$profile->name}, AID: {$profile->aid}\n";
}

// Create a credential profile
$profile = $client->console->credentialProfiles->create([
'name' => 'Main Office Profile',
'app_name' => 'KEY-ID-main',
'keys' => [
['value' => 'your_32_char_hex_master_key_here'],
['value' => 'your_32_char_hex__read_key__here']
]
]);

echo "Profile created: {$profile->id}\n";
echo "AID: {$profile->aid}\n";
```

## Error Handling

```php
Expand Down Expand Up @@ -312,5 +384,10 @@ MIT License
| 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 |
22 changes: 22 additions & 0 deletions src/Models/AccessCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ class AccessCard
public ?string $file_data;
public ?string $directInstallUrl;
public ?string $direct_install_url;
public ?string $organizationName;
public ?string $organization_name;
public ?string $department;
public ?string $location;
public ?string $siteName;
public ?string $site_name;
public ?string $workstation;
public ?string $mailStop;
public ?string $mail_stop;
public ?string $companyAddress;
public ?string $company_address;
public $details;
public array $devices;
public array $metadata;
Expand All @@ -46,6 +57,17 @@ public function __construct(AccessGridClient $client, array $data)
$this->file_data = $data['file_data'] ?? null;
$this->directInstallUrl = $data['direct_install_url'] ?? null;
$this->direct_install_url = $data['direct_install_url'] ?? null;
$this->organizationName = $data['organization_name'] ?? null;
$this->organization_name = $data['organization_name'] ?? null;
$this->department = $data['department'] ?? null;
$this->location = $data['location'] ?? null;
$this->siteName = $data['site_name'] ?? null;
$this->site_name = $data['site_name'] ?? null;
$this->workstation = $data['workstation'] ?? null;
$this->mailStop = $data['mail_stop'] ?? null;
$this->mail_stop = $data['mail_stop'] ?? null;
$this->companyAddress = $data['company_address'] ?? null;
$this->company_address = $data['company_address'] ?? null;
$this->details = $data['details'] ?? null;
$this->devices = $data['devices'] ?? [];
$this->metadata = $data['metadata'] ?? [];
Expand Down
37 changes: 37 additions & 0 deletions src/Models/CredentialProfile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace AccessGrid\Models;

use AccessGrid\AccessGridClient;

class CredentialProfile
{
private AccessGridClient $client;
public ?string $id;
public ?string $aid;
public ?string $name;
public ?string $appleId;
public ?string $apple_id;
public ?string $createdAt;
public ?string $created_at;
public ?string $cardStorage;
public ?string $card_storage;
public array $keys;
public array $files;

public function __construct(AccessGridClient $client, array $data)
{
$this->client = $client;
$this->id = $data['id'] ?? null;
$this->aid = $data['aid'] ?? null;
$this->name = $data['name'] ?? null;
$this->appleId = $data['apple_id'] ?? null;
$this->apple_id = $data['apple_id'] ?? null;
$this->createdAt = $data['created_at'] ?? null;
$this->created_at = $data['created_at'] ?? null;
$this->cardStorage = $data['card_storage'] ?? null;
$this->card_storage = $data['card_storage'] ?? null;
$this->keys = $data['keys'] ?? [];
$this->files = $data['files'] ?? [];
}
}
33 changes: 33 additions & 0 deletions src/Models/LandingPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace AccessGrid\Models;

use AccessGrid\AccessGridClient;

class LandingPage
{
private AccessGridClient $client;
public ?string $id;
public ?string $name;
public ?string $kind;
public ?bool $passwordProtected;
public ?bool $password_protected;
public ?string $logoUrl;
public ?string $logo_url;
public ?string $createdAt;
public ?string $created_at;

public function __construct(AccessGridClient $client, array $data)
{
$this->client = $client;
$this->id = $data['id'] ?? null;
$this->name = $data['name'] ?? null;
$this->kind = $data['kind'] ?? null;
$this->passwordProtected = $data['password_protected'] ?? null;
$this->password_protected = $data['password_protected'] ?? null;
$this->logoUrl = $data['logo_url'] ?? null;
$this->logo_url = $data['logo_url'] ?? null;
$this->createdAt = $data['created_at'] ?? null;
$this->created_at = $data['created_at'] ?? null;
}
}
37 changes: 37 additions & 0 deletions src/Services/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,21 @@
use AccessGrid\Models\Template;
use AccessGrid\Models\PassTemplatePair;
use AccessGrid\Models\LedgerItem;
use AccessGrid\Models\LandingPage;
use AccessGrid\Models\CredentialProfile;
use AccessGrid\Models\Webhook;

class Console
{
private AccessGridClient $client;
public HID $hid;
public CredentialProfiles $credentialProfiles;

public function __construct(AccessGridClient $client)
{
$this->client = $client;
$this->hid = new HID($client);
$this->credentialProfiles = new CredentialProfiles($client);
}

/**
Expand Down Expand Up @@ -151,6 +155,39 @@ public function deleteWebhook(string $webhookId): void
$this->client->delete("/v1/console/webhooks/{$webhookId}");
}

/**
* List all landing pages
*
* @return LandingPage[]
*/
public function listLandingPages(): array
{
$response = $this->client->get('/v1/console/landing-pages');

return array_map(
fn($item) => new LandingPage($this->client, $item),
$response
);
}

/**
* Create a landing page
*/
public function createLandingPage(array $data): LandingPage
{
$response = $this->client->post('/v1/console/landing-pages', $data);
return new LandingPage($this->client, $response);
}

/**
* Update a landing page
*/
public function updateLandingPage(string $landingPageId, array $data): LandingPage
{
$response = $this->client->patch("/v1/console/landing-pages/{$landingPageId}", $data);
return new LandingPage($this->client, $response);
}

/**
* Get iOS provisioning identifiers for preflight
*/
Expand Down
40 changes: 40 additions & 0 deletions src/Services/CredentialProfiles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace AccessGrid\Services;

use AccessGrid\AccessGridClient;
use AccessGrid\Models\CredentialProfile;

class CredentialProfiles
{
private AccessGridClient $client;

public function __construct(AccessGridClient $client)
{
$this->client = $client;
}

/**
* List all credential profiles
*
* @return CredentialProfile[]
*/
public function list(): array
{
$response = $this->client->get('/v1/console/credential-profiles');

return array_map(
fn($item) => new CredentialProfile($this->client, $item),
$response
);
}

/**
* Create a credential profile
*/
public function create(array $data): CredentialProfile
{
$response = $this->client->post('/v1/console/credential-profiles', $data);
return new CredentialProfile($this->client, $response);
}
}
52 changes: 52 additions & 0 deletions tests/Models/AccessCardNewFieldsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

namespace AccessGrid\Tests\Models;

use AccessGrid\Tests\TestCase;
use AccessGrid\Models\AccessCard;

class AccessCardNewFieldsTest extends TestCase
{
public function testCardWithNewFields(): void
{
$data = [
'id' => 'card_123',
'state' => 'active',
'full_name' => 'John Doe',
'organization_name' => 'Acme Corp',
'department' => 'Engineering',
'location' => 'San Francisco',
'site_name' => 'HQ Building A',
'workstation' => '4F-207',
'mail_stop' => 'MS-401',
'company_address' => '123 Main St, San Francisco, CA 94105',
];

$card = new AccessCard($this->client, $data);

$this->assertEquals('Acme Corp', $card->organization_name);
$this->assertEquals('Acme Corp', $card->organizationName);
$this->assertEquals('Engineering', $card->department);
$this->assertEquals('San Francisco', $card->location);
$this->assertEquals('HQ Building A', $card->site_name);
$this->assertEquals('HQ Building A', $card->siteName);
$this->assertEquals('4F-207', $card->workstation);
$this->assertEquals('MS-401', $card->mail_stop);
$this->assertEquals('MS-401', $card->mailStop);
$this->assertEquals('123 Main St, San Francisco, CA 94105', $card->company_address);
$this->assertEquals('123 Main St, San Francisco, CA 94105', $card->companyAddress);
}

public function testCardNewFieldsNullWhenAbsent(): void
{
$card = new AccessCard($this->client, ['id' => 'card_456']);

$this->assertNull($card->organization_name);
$this->assertNull($card->department);
$this->assertNull($card->location);
$this->assertNull($card->site_name);
$this->assertNull($card->workstation);
$this->assertNull($card->mail_stop);
$this->assertNull($card->company_address);
}
}
Loading
Loading