@vouchfor/sdk 1.1.20 → 1.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -15,8 +15,8 @@ class IntegrationService extends BaseIntegrationService {
|
|
|
15
15
|
|
|
16
16
|
authenticate({ applicationId, entityId, mappingId }) {
|
|
17
17
|
if (applicationId) {
|
|
18
|
-
const
|
|
19
|
-
return this._request({ path: `applications/${applicationId}/entity` +
|
|
18
|
+
const path = entityId ? `/${entityId}` : '';
|
|
19
|
+
return this._request({ path: `applications/${applicationId}/entity` + path });
|
|
20
20
|
} else if (entityId) {
|
|
21
21
|
return this._request({ path: `entities/${entityId}` });
|
|
22
22
|
} else if (mappingId) {
|
|
@@ -21,8 +21,12 @@ class VouchService extends BaseRestService {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
get(id, apiKey) {
|
|
25
|
-
|
|
24
|
+
get(id, apiKey, media = false) {
|
|
25
|
+
const query = media ? '?media=true' : ''
|
|
26
|
+
return this._request({
|
|
27
|
+
apiKey,
|
|
28
|
+
path: `${id}`+ query
|
|
29
|
+
});
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
counts(id, apiKey) {
|
package/lib/shared/utils.js
CHANGED
|
@@ -24,8 +24,7 @@ function logHttpResponse({ req, res, body, result, logger }) {
|
|
|
24
24
|
const { protocol, method, host, _header: header } = req._currentRequest;
|
|
25
25
|
const get = req.type === 'GET';
|
|
26
26
|
const type = res.headers['content-type'] ?? 'application/json';
|
|
27
|
-
const
|
|
28
|
-
const data = (json && body ? JSON.stringify(body) : body || '') + '\n';
|
|
27
|
+
const data = (typeof body === 'object' ? JSON.stringify(body) : body || '') + '\n';
|
|
29
28
|
const request = header + (get ? '' : data);
|
|
30
29
|
const { httpVersion, statusCode, statusMessage } = res;
|
|
31
30
|
const headers = [];
|
|
@@ -51,8 +50,7 @@ function logHttpError({ req, err, body, logger }) {
|
|
|
51
50
|
const res = { headers: parseHttpHeaders(header) };
|
|
52
51
|
const get = req.type === 'GET';
|
|
53
52
|
const type = res.headers['content-type'] ?? 'application/json';
|
|
54
|
-
const
|
|
55
|
-
const data = (json && body ? JSON.stringify(body) : body || '') + '\n';
|
|
53
|
+
const data = (typeof body === 'object' ? JSON.stringify(body) : body || '') + '\n';
|
|
56
54
|
const request = header + (get ? '' : data);
|
|
57
55
|
const error = err + `\r\n`;
|
|
58
56
|
logger.info(`${(protocol + ' ' + method).toUpperCase()} request to host: ${host}\n`
|
|
@@ -120,7 +118,11 @@ module.exports = {
|
|
|
120
118
|
body.pipe(req);
|
|
121
119
|
} else {
|
|
122
120
|
if (body) {
|
|
123
|
-
|
|
121
|
+
if (typeof body === 'object') {
|
|
122
|
+
req.write(JSON.stringify(body));
|
|
123
|
+
} else {
|
|
124
|
+
req.write(body);
|
|
125
|
+
}
|
|
124
126
|
}
|
|
125
127
|
req.end();
|
|
126
128
|
}
|