mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 19:25:23 +00:00
Introduced support to primaryFields, secondaryFields, etc.
This commit is contained in:
13
index.js
13
index.js
@@ -4,7 +4,8 @@ const forge = require("node-forge");
|
|||||||
const archiver = require("archiver");
|
const archiver = require("archiver");
|
||||||
const async = require("async");
|
const async = require("async");
|
||||||
const stream = require("stream");
|
const stream = require("stream");
|
||||||
const schema = require("./schema.js");
|
const schema = require("./schema");
|
||||||
|
const fields = require("./fields");
|
||||||
|
|
||||||
const util = require("util");
|
const util = require("util");
|
||||||
|
|
||||||
@@ -18,6 +19,8 @@ class Pass {
|
|||||||
this.Certificates = {};
|
this.Certificates = {};
|
||||||
this.model = "";
|
this.model = "";
|
||||||
this.l10n = {};
|
this.l10n = {};
|
||||||
|
|
||||||
|
fields.areas.forEach(a => this[a] = new fields.FieldsArea());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -173,6 +176,8 @@ class Pass {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let type = passTypes[index];
|
let type = passTypes[index];
|
||||||
|
|
||||||
|
this.type = type;
|
||||||
return schema.isValid(passFile[type], schema.constants[(type === "boardingPass" ? "boarding" : "basic") + "Structure"]);
|
return schema.isValid(passFile[type], schema.constants[(type === "boardingPass" ? "boarding" : "basic") + "Structure"]);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
@@ -296,6 +301,12 @@ class Pass {
|
|||||||
|
|
||||||
Object.assign(passFile, options);
|
Object.assign(passFile, options);
|
||||||
|
|
||||||
|
fields.areas.forEach(area => {
|
||||||
|
if (this[area].fields.length) {
|
||||||
|
passFile[this.type][area].push(...this[area].fields);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return Promise.resolve(Buffer.from(JSON.stringify(passFile)));
|
return Promise.resolve(Buffer.from(JSON.stringify(passFile)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user