Skip to content

Commit c7486f3

Browse files
author
Max Pothier
committed
adds custom parameters for us_street
1 parent d6c0c59 commit c7486f3

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

src/InputData.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class InputData {
88
if (this.lookupFieldIsPopulated(lookupField)) this.data[apiField] = this.formatData(this.lookup[lookupField]);
99
}
1010

11+
addCustomParameter(key, value) {
12+
this.data[key] = value;
13+
}
14+
1115
formatData(field) {
1216
if (Array.isArray(field)) return field.join(";");
1317
else return field;

src/us_street/Lookup.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ class Lookup {
1919
this.inputId = inputId;
2020
this.format = format;
2121
this.result = [];
22+
this.customParameters = {};
2223
}
24+
25+
addCustomParameter(key, value) {
26+
this.customParameters[key] = value;
27+
}
28+
2329
}
2430

2531
module.exports = Lookup;

src/util/buildInputData.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@ const InputData = require("../InputData");
33
module.exports = (lookup, keyTranslationFormat) => {
44
let inputData = new InputData(lookup);
55

6+
const hasCustomParameters = Object.keys(lookup.customParameters).length > 0;
7+
68
for (let key in keyTranslationFormat) {
79
inputData.add(key, keyTranslationFormat[key]);
810
}
911

12+
if (hasCustomParameters) {
13+
for (let key in lookup.customParameters) {
14+
inputData.addCustomParameter(key, lookup.customParameters[key]);
15+
}
16+
}
17+
1018
return inputData.data;
1119
};

0 commit comments

Comments
 (0)