From 97c517ba1f7486d9a18aec0dd6cad6fcf8d6254b Mon Sep 17 00:00:00 2001 From: Auston Bunsen Date: Mon, 30 Mar 2026 20:42:09 -0400 Subject: [PATCH] Flatten CreateTemplateParams to match API docs Replace nested Design/SupportInfo structs with flat fields (BackgroundColor, SupportURL, etc.) and add AllowOnMultipleDevices and Metadata fields. Add feature matrix to README. --- README.md | 69 +++++++++++++++++++++++++--------------- models/models.go | 27 +++++++++++----- services/console_test.go | 41 +++++++++++------------- 3 files changed, 82 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 60352f8..23cb659 100644 --- a/README.md +++ b/README.md @@ -271,33 +271,26 @@ func main() { return } - design := accessgrid.TemplateDesign{ - BackgroundColor: "#FFFFFF", - LabelColor: "#000000", - LabelSecondaryColor: "#333333", - BackgroundImage: "[image_in_base64_encoded_format]", - LogoImage: "[image_in_base64_encoded_format]", - IconImage: "[image_in_base64_encoded_format]", - } - - supportInfo := accessgrid.SupportInfo{ - SupportURL: "https://help.yourcompany.com", - SupportPhoneNumber: "+1-555-123-4567", - SupportEmail: "support@yourcompany.com", - PrivacyPolicyURL: "https://yourcompany.com/privacy", - TermsAndConditionsURL: "https://yourcompany.com/terms", - } - params := accessgrid.CreateTemplateParams{ - Name: "Employee NFC key", - Platform: "apple", - UseCase: "employee_badge", - Protocol: "desfire", + Name: "Employee Access Pass", + Platform: "apple", + UseCase: "employee_badge", + Protocol: "desfire", AllowOnMultipleDevices: true, - WatchCount: 2, - IPhoneCount: 3, - Design: design, - SupportInfo: supportInfo, + WatchCount: 2, + IPhoneCount: 3, + BackgroundColor: "#FFFFFF", + LabelColor: "#000000", + LabelSecondaryColor: "#333333", + SupportURL: "https://help.yourcompany.com", + SupportPhoneNumber: "+1-555-123-4567", + SupportEmail: "support@yourcompany.com", + PrivacyPolicyURL: "https://yourcompany.com/privacy", + TermsAndConditionsURL: "https://yourcompany.com/terms", + Metadata: map[string]interface{}{ + "version": "2.1", + "approval_status": "approved", + }, } ctx := context.Background() @@ -488,6 +481,32 @@ The SDK automatically handles: Never expose your `secretKey` in source code. Always use environment variables or a secure configuration management system. +## Feature Matrix + +| 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/pass-template-pairs | `Console.ListPassTemplatePairs()` | Y | +| POST /v1/console/card-templates/{id}/ios_preflight | `Console.IosPreflight()` | - | +| GET /v1/console/ledger-items | `Console.ListLedgerItems()` | Y | +| GET /v1/console/webhooks | `Console.Webhooks.List()` | - | +| POST /v1/console/webhooks | `Console.Webhooks.Create()` | - | +| DELETE /v1/console/webhooks/{id} | `Console.Webhooks.Delete()` | - | +| POST /v1/console/hid/orgs | `Console.HID.Orgs.Create()` | - | +| POST /v1/console/hid/orgs/activate | `Console.HID.Orgs.Activate()` | - | +| GET /v1/console/hid/orgs | `Console.HID.Orgs.List()` | - | + ## License MIT License - See LICENSE file for details. \ No newline at end of file diff --git a/models/models.go b/models/models.go index d278a66..f379117 100644 --- a/models/models.go +++ b/models/models.go @@ -136,14 +136,25 @@ type SupportInfo struct { // CreateTemplateParams defines parameters for creating a new template type CreateTemplateParams struct { - Name string `json:"name"` - Platform string `json:"platform"` - UseCase string `json:"use_case"` - Protocol string `json:"protocol"` - WatchCount int `json:"watch_count"` - IPhoneCount int `json:"iphone_count"` - Design TemplateDesign `json:"design"` - SupportInfo SupportInfo `json:"support_info"` + Name string `json:"name"` + Platform string `json:"platform"` + UseCase string `json:"use_case"` + Protocol string `json:"protocol"` + AllowOnMultipleDevices bool `json:"allow_on_multiple_devices,omitempty"` + WatchCount int `json:"watch_count"` + IPhoneCount int `json:"iphone_count"` + BackgroundColor string `json:"background_color,omitempty"` + LabelColor string `json:"label_color,omitempty"` + LabelSecondaryColor string `json:"label_secondary_color,omitempty"` + BackgroundImage string `json:"background_image,omitempty"` + LogoImage string `json:"logo_image,omitempty"` + IconImage string `json:"icon_image,omitempty"` + SupportURL string `json:"support_url,omitempty"` + SupportPhoneNumber string `json:"support_phone_number,omitempty"` + SupportEmail string `json:"support_email,omitempty"` + PrivacyPolicyURL string `json:"privacy_policy_url,omitempty"` + TermsAndConditionsURL string `json:"terms_and_conditions_url,omitempty"` + Metadata map[string]interface{} `json:"metadata,omitempty"` } // UpdateTemplateParams defines parameters for updating an existing template diff --git a/services/console_test.go b/services/console_test.go index cc6eacc..f7c6d35 100644 --- a/services/console_test.go +++ b/services/console_test.go @@ -157,29 +157,26 @@ func TestConsoleService_CreateTemplate(t *testing.T) { server, service := setupConsoleTestServer() defer server.Close() - design := models.TemplateDesign{ - BackgroundColor: "#FFFFFF", - LabelColor: "#000000", - LabelSecondaryColor: "#333333", - } - - supportInfo := models.SupportInfo{ - SupportURL: "https://help.example.com", - SupportPhoneNumber: "+1-555-123-4567", - SupportEmail: "support@example.com", - PrivacyPolicyURL: "https://example.com/privacy", - TermsAndConditionsURL: "https://example.com/terms", - } - params := models.CreateTemplateParams{ - Name: "Employee NFC key", - Platform: "apple", - UseCase: "employee_badge", - Protocol: "desfire", - WatchCount: 2, - IPhoneCount: 3, - Design: design, - SupportInfo: supportInfo, + Name: "Employee NFC key", + Platform: "apple", + UseCase: "employee_badge", + Protocol: "desfire", + AllowOnMultipleDevices: true, + WatchCount: 2, + IPhoneCount: 3, + BackgroundColor: "#FFFFFF", + LabelColor: "#000000", + LabelSecondaryColor: "#333333", + SupportURL: "https://help.example.com", + SupportPhoneNumber: "+1-555-123-4567", + SupportEmail: "support@example.com", + PrivacyPolicyURL: "https://example.com/privacy", + TermsAndConditionsURL: "https://example.com/terms", + Metadata: map[string]interface{}{ + "version": "2.1", + "approval_status": "approved", + }, } ctx := context.Background()