mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 21:25:26 +00:00
Removed forgotter useless parameters and fixed nfc method to accept null;
Added null to more signatures;
This commit is contained in:
25
src/pass.ts
25
src/pass.ts
@@ -75,10 +75,10 @@ export class Pass implements PassIndexSignature {
|
|||||||
this[passProps] = {
|
this[passProps] = {
|
||||||
...(
|
...(
|
||||||
[
|
[
|
||||||
"barcodes", "barcode",
|
"barcodes", "barcode",
|
||||||
"expirationDate", "voided",
|
"expirationDate", "voided",
|
||||||
"beacons", "locations",
|
"beacons", "locations",
|
||||||
"relevantDate", "nfc"
|
"relevantDate", "nfc"
|
||||||
].reduce<schema.ValidPass>((acc, current) =>
|
].reduce<schema.ValidPass>((acc, current) =>
|
||||||
!this.passCore.hasOwnProperty(current) && acc ||
|
!this.passCore.hasOwnProperty(current) && acc ||
|
||||||
({ ...acc, [current]: this.passCore[current] || undefined })
|
({ ...acc, [current]: this.passCore[current] || undefined })
|
||||||
@@ -207,7 +207,7 @@ export class Pass implements PassIndexSignature {
|
|||||||
* @see https://apple.co/2KOv0OW - Passes support localization
|
* @see https://apple.co/2KOv0OW - Passes support localization
|
||||||
*/
|
*/
|
||||||
|
|
||||||
localize(lang?: string, translations?: { [key: string]: string }): this {
|
localize(lang: string, translations?: { [key: string]: string }): this {
|
||||||
if (lang && typeof lang === "string" && (typeof translations === "object" || translations === undefined)) {
|
if (lang && typeof lang === "string" && (typeof translations === "object" || translations === undefined)) {
|
||||||
this.l10nTranslations[lang] = translations || {};
|
this.l10nTranslations[lang] = translations || {};
|
||||||
}
|
}
|
||||||
@@ -223,7 +223,7 @@ export class Pass implements PassIndexSignature {
|
|||||||
* @returns {this}
|
* @returns {this}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
expiration(date?: Date): this | string {
|
expiration(date: Date | null): this | string {
|
||||||
if (date === null) {
|
if (date === null) {
|
||||||
delete this[passProps]["expirationDate"];
|
delete this[passProps]["expirationDate"];
|
||||||
return this;
|
return this;
|
||||||
@@ -277,7 +277,7 @@ export class Pass implements PassIndexSignature {
|
|||||||
* @returns {Pass}
|
* @returns {Pass}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
locations(...data: schema.Location[]): this {
|
locations(...data: schema.Location[] | null): this {
|
||||||
if (data === null) {
|
if (data === null) {
|
||||||
delete this[passProps]["locations"];
|
delete this[passProps]["locations"];
|
||||||
return this;
|
return this;
|
||||||
@@ -298,7 +298,7 @@ export class Pass implements PassIndexSignature {
|
|||||||
* @returns {Pass}
|
* @returns {Pass}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
relevantDate(date?: Date): this | string {
|
relevantDate(date: Date | null): this | string {
|
||||||
if (date === null) {
|
if (date === null) {
|
||||||
delete this[passProps]["relevantDate"];
|
delete this[passProps]["relevantDate"];
|
||||||
return this;
|
return this;
|
||||||
@@ -322,7 +322,7 @@ export class Pass implements PassIndexSignature {
|
|||||||
* @return {this} Improved this with length property and other methods
|
* @return {this} Improved this with length property and other methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
barcodes(first?: string | schema.Barcode, ...data: schema.Barcode[]): this {
|
barcodes(first: null | string | schema.Barcode, ...data: schema.Barcode[]): this {
|
||||||
if (first === null) {
|
if (first === null) {
|
||||||
delete this[passProps]["barcodes"];
|
delete this[passProps]["barcodes"];
|
||||||
return this;
|
return this;
|
||||||
@@ -436,9 +436,10 @@ export class Pass implements PassIndexSignature {
|
|||||||
* @returns {this}
|
* @returns {this}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nfc(data?: schema.NFC): this | schema.NFC {
|
nfc(data: schema.NFC | null): this | schema.NFC {
|
||||||
if (data === undefined) {
|
if (data === null) {
|
||||||
return this[passProps]["nfc"];
|
delete this[passProps]["nfc"];
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(typeof data === "object" && !Array.isArray(data) && schema.isValid(data, "nfcDict"))) {
|
if (!(typeof data === "object" && !Array.isArray(data) && schema.isValid(data, "nfcDict"))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user