Added implementation method to add upcoming pass information

This commit is contained in:
Alexander Cerutti
2025-09-17 21:46:53 +02:00
parent 51388ddf81
commit 8fc00dc9bb
2 changed files with 37 additions and 0 deletions

View File

@@ -261,6 +261,34 @@ export default class PKPass extends Bundle {
this[propsSymbol].preferredStyleSchemes = value; 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 * Allows setting a transitType property
* for a boardingPass. * for a boardingPass.

View File

@@ -24,6 +24,15 @@ export const PREFERRED_STYLE_SCHEMES = {
"Cannot set preferredStyleSchemes because not compliant with Apple specifications - %s", "Cannot set preferredStyleSchemes because not compliant with Apple specifications - %s",
} as const; } 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 = { export const PASS_TYPE = {
INVALID: INVALID:
"Cannot set type because not compliant with Apple specifications. Refer to https://apple.co/3aFpSfg for a list of valid props - %s", "Cannot set type because not compliant with Apple specifications. Refer to https://apple.co/3aFpSfg for a list of valid props - %s",