diff --git a/examples/models/posterEventTicketWithNewSeats.pass/pass.json b/examples/models/posterEventTicketWithNewSeats.pass/pass.json index 992be12..dcd5b41 100644 --- a/examples/models/posterEventTicketWithNewSeats.pass/pass.json +++ b/examples/models/posterEventTicketWithNewSeats.pass/pass.json @@ -20,6 +20,38 @@ ], "primaryFields": [ { "key": "event_name", "label": "event-name", "value": "Dune" } + ], + "additionalInfoFields": [ + { + "key": "additionalInfo-1", + "label": "Additional Info 1", + "value": "The text to show" + }, + { + "key": "additionalInfo-1", + "label": "Additional Info 2", + "value": "The text to show 2" + }, + { + "key": "lineItem3", + "label": "Emergency Contact", + "value": "+1 8716 12736131", + "dataDetectorTypes": [ + "PKDataDetectorTypePhoneNumber", + "used only on Watch" + ] + }, + { + "key": "lineItem4", + "label": "Test link", + "value": "https://apple.com", + "dataDetectorTypes": [ + "PKDataDetectorTypeLink", + "used only on Watch" + ], + "textAlignment": "", + "attributedValue": "Used literally on iPhone, used correctly on Watch" + } ] }, "semantics": { diff --git a/src/PKPass.ts b/src/PKPass.ts index b92046c..8140090 100644 --- a/src/PKPass.ts +++ b/src/PKPass.ts @@ -359,6 +359,18 @@ export default class PKPass extends Bundle { return this[propsSymbol][this.type].backFields; } + /** + * Allows accessing to backFields object + * + * @throws (automatically) if no valid pass.json + * has been parsed yet or, anyway, if current + * type is not "eventTicket". + */ + + public get additionalInfoFields(): Schemas.Field[] { + return this[propsSymbol]["eventTicket"].additionalInfoFields; + } + /** * Allows setting a pass type. * @@ -420,6 +432,11 @@ export default class PKPass extends Bundle { sharedKeysPool, Schemas.Field, ), + additionalInfoFields: new FieldsArray( + this, + sharedKeysPool, + Schemas.Field, + ), transitType: undefined, }; } @@ -589,6 +606,7 @@ export default class PKPass extends Bundle { auxiliaryFields = [], backFields = [], transitType, + additionalInfoFields = [], } = data[type] || {}; this.headerFields.push(...headerFields); @@ -596,6 +614,7 @@ export default class PKPass extends Bundle { this.secondaryFields.push(...secondaryFields); this.auxiliaryFields.push(...auxiliaryFields); this.backFields.push(...backFields); + this.additionalInfoFields.push(...additionalInfoFields); if (this.type === "boardingPass") { this.transitType = transitType; diff --git a/src/schemas/PassFields.ts b/src/schemas/PassFields.ts index 41eef7d..76ae0fe 100644 --- a/src/schemas/PassFields.ts +++ b/src/schemas/PassFields.ts @@ -19,6 +19,7 @@ export interface PassFields { primaryFields: Field[]; secondaryFields: Field[]; transitType?: TransitType; + additionalInfoFields?: Field[]; } export const PassFields = Joi.object().keys({ @@ -28,4 +29,5 @@ export const PassFields = Joi.object().keys({ primaryFields: Joi.array().items(Field), secondaryFields: Joi.array().items(Field), transitType: TransitType, + additionalInfoFields: Joi.array().items(Field), });