Skip to content

Commit d6a2903

Browse files
author
Max Pothier
committed
add methods in Client for secondary and secondary count
1 parent 5fe4cd5 commit d6a2903

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/us_enrichment/Client.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,46 @@ class Client {
6767
.catch(reject);
6868
});
6969
}
70+
71+
sendSecondary(lookup) {
72+
if (typeof lookup === "undefined") throw new Errors.UndefinedLookupError();
73+
74+
let request = new Request();
75+
request.parameters = buildInputData(lookup, keyTranslationFormat);
76+
77+
request.baseUrlParam = lookup.smartyKey + "/secondary";
78+
79+
return new Promise((resolve, reject) => {
80+
this.sender.send(request)
81+
.then(response => {
82+
if (response.error) reject(response.error);
83+
84+
lookup.response = response.payload;
85+
resolve(lookup);
86+
})
87+
.catch(reject);
88+
});
89+
}
90+
91+
sendSecondaryCount(lookup) {
92+
if (typeof lookup === "undefined") throw new Errors.UndefinedLookupError();
93+
94+
let request = new Request();
95+
request.parameters = buildInputData(lookup, keyTranslationFormat);
96+
97+
request.baseUrlParam = lookup.smartyKey + "/secondary/count";
98+
99+
return new Promise((resolve, reject) => {
100+
this.sender.send(request)
101+
.then(response => {
102+
if (response.error) reject(response.error);
103+
104+
lookup.response = response.payload;
105+
resolve(lookup);
106+
})
107+
.catch(reject);
108+
});
109+
}
70110
}
71111

72112
module.exports = Client;

0 commit comments

Comments
 (0)