Skip to content

Commit b4d8f00

Browse files
set header
1 parent eab3af2 commit b4d8f00

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/ApiClient.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@
6464
* @type {Array.<String>}
6565
* @default {}
6666
*/
67-
this.defaultHeaders = {};
67+
const pkgJson = require('../package.json');
68+
this.defaultHeaders = {
69+
'user-agent': `sendinblue_clientAPI/v${pkgJson.version}/node`
70+
};
6871

6972
/**
7073
* The default HTTP timeout for all API calls.
@@ -578,6 +581,13 @@
578581
}
579582
};
580583

584+
exports.setUserAgent = function(header) {
585+
if (typeof header == 'string' && header.substr(0,11).trim().toLowerCase() === 'sendinblue_') {
586+
exports.instance.defaultHeaders['user-agent'] = header;
587+
}
588+
return;
589+
};
590+
581591
/**
582592
* The default API client implementation.
583593
* @type {module:ApiClient}

0 commit comments

Comments
 (0)