From ba3a2df001ae46e3af027a69bdaf59968c2e6be6 Mon Sep 17 00:00:00 2001 From: Alexander Cerutti Date: Tue, 28 Sep 2021 01:01:11 +0200 Subject: [PATCH] Added overrides validation and changed PKPass.prototype.type's type --- src/PKPass.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/PKPass.ts b/src/PKPass.ts index c573112..54c0e12 100644 --- a/src/PKPass.ts +++ b/src/PKPass.ts @@ -40,7 +40,7 @@ export default class PKPass extends Bundle { [placeholder: string]: string; }; } = {}; - public type: string = undefined; /** @TODO change type */ + public type: Schemas.PassTypesProps = undefined; /** * Either create a pass from another one @@ -150,6 +150,14 @@ export default class PKPass extends Bundle { const [fileName, contentBuffer] = buffer; this.addBuffer(fileName, contentBuffer); } + + /** Overrides validation and pushing in props */ + const overridesValidation = Schemas.getValidated( + overrides, + Schemas.OverridablePassProps, + ); + + Object.assign(this[propsSymbol], overridesValidation); } /** @@ -334,7 +342,7 @@ export default class PKPass extends Bundle { "eventTicket", "storeCard", "generic", - ] as string[]; /** @TODO fix this type */ + ] as Schemas.PassTypesProps[]; this.type = possibleTypes.find((type) => Boolean(data[type])); @@ -367,6 +375,7 @@ export default class PKPass extends Bundle { this[fieldKeysPoolSymbol], ...data[this.type]?.backFields, ), + transitType: undefined /** Setter + Getter */, }; }