From 379b92d6a7f3feb5d03c24f1776b81b195e00e16 Mon Sep 17 00:00:00 2001 From: Auston Bunsen Date: Mon, 30 Mar 2026 20:42:58 -0400 Subject: [PATCH] Flatten UpdateTemplateParams to match API docs Replace nested Design/SupportInfo pointer structs with flat fields and add AllowOnMultipleDevices and Metadata fields. --- README.md | 28 ++++++++++++++-------------- models/models.go | 20 ++++++++++++++------ services/console_test.go | 22 +++++++++++----------- 3 files changed, 39 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 60352f8..21eab24 100644 --- a/README.md +++ b/README.md @@ -332,21 +332,21 @@ func main() { return } - 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", - } - + allowMulti := true params := accessgrid.UpdateTemplateParams{ - CardTemplateID: "0xd3adb00b5", - Name: "Updated Employee NFC key", - AllowOnMultipleDevices: true, - WatchCount: 2, - IPhoneCount: 3, - SupportInfo: supportInfo, + CardTemplateID: "0xd3adb00b5", + Name: "Updated Employee Access Pass", + AllowOnMultipleDevices: &allowMulti, + 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", } ctx := context.Background() diff --git a/models/models.go b/models/models.go index d278a66..c3fd09a 100644 --- a/models/models.go +++ b/models/models.go @@ -148,12 +148,20 @@ type CreateTemplateParams struct { // UpdateTemplateParams defines parameters for updating an existing template type UpdateTemplateParams struct { - CardTemplateID string `json:"card_template_id"` - Name string `json:"name,omitempty"` - WatchCount int `json:"watch_count,omitempty"` - IPhoneCount int `json:"iphone_count,omitempty"` - Design *TemplateDesign `json:"design,omitempty"` - SupportInfo *SupportInfo `json:"support_info,omitempty"` + CardTemplateID string `json:"card_template_id"` + Name string `json:"name,omitempty"` + AllowOnMultipleDevices *bool `json:"allow_on_multiple_devices,omitempty"` + WatchCount int `json:"watch_count,omitempty"` + IPhoneCount int `json:"iphone_count,omitempty"` + BackgroundColor string `json:"background_color,omitempty"` + LabelColor string `json:"label_color,omitempty"` + LabelSecondaryColor string `json:"label_secondary_color,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"` } // EventLogFilters defines parameters for filtering event logs diff --git a/services/console_test.go b/services/console_test.go index cc6eacc..6847477 100644 --- a/services/console_test.go +++ b/services/console_test.go @@ -203,18 +203,18 @@ func TestConsoleService_UpdateTemplate(t *testing.T) { server, service := setupConsoleTestServer() defer server.Close() - supportInfo := models.SupportInfo{ - SupportURL: "https://help.example.com", - SupportPhoneNumber: "+1-555-123-4567", - SupportEmail: "support@example.com", - } - + allowMulti := true params := models.UpdateTemplateParams{ - CardTemplateID: "0xd3adb00b5", - Name: "Updated Employee NFC key", - WatchCount: 2, - IPhoneCount: 3, - SupportInfo: &supportInfo, + CardTemplateID: "0xd3adb00b5", + Name: "Updated Employee NFC key", + AllowOnMultipleDevices: &allowMulti, + WatchCount: 2, + IPhoneCount: 3, + BackgroundColor: "#FFFFFF", + LabelColor: "#000000", + SupportURL: "https://help.example.com", + SupportPhoneNumber: "+1-555-123-4567", + SupportEmail: "support@example.com", } ctx := context.Background()