Introduced support to primaryFields, secondaryFields, etc.

This commit is contained in:
alexandercerutti
2018-08-18 16:31:20 +02:00
parent 03ea03a752
commit 1e0b08af6a

View File

@@ -4,7 +4,8 @@ const forge = require("node-forge");
const archiver = require("archiver");
const async = require("async");
const stream = require("stream");
const schema = require("./schema.js");
const schema = require("./schema");
const fields = require("./fields");
const util = require("util");
@@ -18,6 +19,8 @@ class Pass {
this.Certificates = {};
this.model = "";
this.l10n = {};
fields.areas.forEach(a => this[a] = new fields.FieldsArea());
}
/**
@@ -173,6 +176,8 @@ class Pass {
}
let type = passTypes[index];
this.type = type;
return schema.isValid(passFile[type], schema.constants[(type === "boardingPass" ? "boarding" : "basic") + "Structure"]);
} catch (e) {
return false;
@@ -296,6 +301,12 @@ class Pass {
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)));
}