From 8fc00dc9bb03d81ae730ed96aef3e5e266204e8e Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Wed, 17 Sep 2025 21:46:53 +0200 Subject: [PATCH] Added implementation method to add upcoming pass information --- src/PKPass.ts | 28 ++++++++++++++++++++++++++++ src/messages.ts | 9 +++++++++ 2 files changed, 37 insertions(+) diff --git a/src/PKPass.ts b/src/PKPass.ts index 197e321..3a7cb22 100644 --- a/src/PKPass.ts +++ b/src/PKPass.ts @@ -261,6 +261,34 @@ export default class PKPass extends Bundle { this[propsSymbol].preferredStyleSchemes = value; } + public set upcomingPassInformation( + value: Schemas.UpcomingPassInformationEntry[], + ) { + Utils.assertUnfrozen(this); + + if (this.type !== "eventTicket") { + throw new TypeError( + Messages.UPCOMING_PASS_INFORMATION.UNEXPECTED_PASS_TYPE, + ); + } + + if (!this.preferredStyleSchemes?.includes("posterEventTicket")) { + throw new TypeError( + Messages.UPCOMING_PASS_INFORMATION.UNEXPECTED_STYLE_SCHEME, + ); + } + + for (const entry of value) { + Schemas.assertValidity( + Schemas.UpcomingPassInformationEntry, + entry, + Messages.UPCOMING_PASS_INFORMATION.INVALID, + ); + } + + this[propsSymbol].upcomingPassInformation = value; + } + /** * Allows setting a transitType property * for a boardingPass. diff --git a/src/messages.ts b/src/messages.ts index f87d9fb..c0ce833 100644 --- a/src/messages.ts +++ b/src/messages.ts @@ -24,6 +24,15 @@ export const PREFERRED_STYLE_SCHEMES = { "Cannot set preferredStyleSchemes because not compliant with Apple specifications - %s", } as const; +export const UPCOMING_PASS_INFORMATION = { + UNEXPECTED_PASS_TYPE: + "Cannot set upcomingPassInformation on a pass with type different from eventTicket.", + UNEXPECTED_STYLE_SCHEME: + "Cannot set upcomingPassInformation because 'preferredStyleSchemes' does not include 'posterEventTicket' style.", + INVALID: + "Cannot set upcomingPassInformation: validation failed. Be sure to follow the Apple specifications. - %s", +} as const; + export const PASS_TYPE = { INVALID: "Cannot set type because not compliant with Apple specifications. Refer to https://apple.co/3aFpSfg for a list of valid props - %s",