mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 19:25:23 +00:00
Improved methods comments
This commit is contained in:
@@ -413,6 +413,18 @@ export default class PKPass extends Bundle {
|
||||
return super.addBuffer(pathName, buffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given data from a pass.json, reads them to bring them
|
||||
* into the current pass instance.
|
||||
*
|
||||
* **Warning**: if this file contains a type (boardingPass,
|
||||
* coupon, and so on), it will replace the current one,
|
||||
* causing, therefore, the destroy of the fields added
|
||||
* previously.
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
|
||||
private [importMetadataSymbol](data: Schemas.PassProps) {
|
||||
const possibleTypes = [
|
||||
"boardingPass",
|
||||
@@ -470,6 +482,11 @@ export default class PKPass extends Bundle {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the manifest starting from files
|
||||
* added to the bundle
|
||||
*/
|
||||
|
||||
private [createManifestSymbol](): Buffer {
|
||||
const manifest = Object.entries(this[filesSymbol]).reduce<{
|
||||
[key: string]: string;
|
||||
@@ -484,6 +501,13 @@ export default class PKPass extends Bundle {
|
||||
return Buffer.from(JSON.stringify(manifest));
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the last validation checks against props,
|
||||
* applies the props to pass.json and creates l10n
|
||||
* files and folders and creates manifest and
|
||||
* signature files
|
||||
*/
|
||||
|
||||
private [closePassSymbol]() {
|
||||
/**
|
||||
* Filtering colors props that have an
|
||||
@@ -512,6 +536,10 @@ export default class PKPass extends Bundle {
|
||||
const passJson = Buffer.from(JSON.stringify(this[propsSymbol]));
|
||||
super.addBuffer("pass.json", passJson);
|
||||
|
||||
// *********************************** //
|
||||
// *** LOCALIZATION FILES CREATION *** //
|
||||
// *********************************** //
|
||||
|
||||
const localizationEntries = Object.entries(this[localizationSymbol]);
|
||||
|
||||
for (
|
||||
@@ -529,6 +557,10 @@ export default class PKPass extends Bundle {
|
||||
}
|
||||
}
|
||||
|
||||
// *********************** //
|
||||
// *** PERSONALIZATION *** //
|
||||
// *********************** //
|
||||
|
||||
const fileNames = Object.keys(this[filesSymbol]);
|
||||
const meetsPersonalizationRequirements = Boolean(
|
||||
this[filesSymbol]["personalization.json"] &&
|
||||
@@ -554,6 +586,10 @@ export default class PKPass extends Bundle {
|
||||
}
|
||||
}
|
||||
|
||||
// ****************************** //
|
||||
// *** SIGNATURE AND MANIFEST *** //
|
||||
// ****************************** //
|
||||
|
||||
const manifestBuffer = this[createManifestSymbol]();
|
||||
super.addBuffer("manifest.json", manifestBuffer);
|
||||
|
||||
@@ -799,7 +835,10 @@ export default class PKPass extends Bundle {
|
||||
let finalBarcodes: Schemas.Barcode[];
|
||||
|
||||
if (typeof barcodes[0] === "string") {
|
||||
/** A string has been received instead of objects. We can only auto-fill them all with the same data. */
|
||||
/**
|
||||
* A string has been received instead of objects. We can
|
||||
* only auto-fill them all with the same data.
|
||||
*/
|
||||
|
||||
const supportedFormats: Array<Schemas.BarcodeFormat> = [
|
||||
"PKBarcodeFormatQR",
|
||||
|
||||
Reference in New Issue
Block a user