File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
swagger-config/transactional/javascript/templates Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,12 @@ var exports = function (apiKey = '') {
1919 '{ {{mediaType} }}'{ {#hasMore} }, { {/hasMore} }{ {/produces} }
2020 ];{ {/-first} }{ {/operation} }{ {/operations} }{ {/-first} }{ {/apis} }{ {/apiInfo} }
2121
22+ this.requestConfig = {
23+ headers: {
24+ ' User-Agent' : ' Transactional-JS/{{{projectVersion}}}' ,
25+ } ,
26+ };
27+
2228 // API Routes{ {#apiInfo} }{ {#apis} }{ {#operations} }{ {#operation} }{ {#-first} }
2329 this.{ {#tags} }{ {{name} }}{ {/tags} } = new { {baseName} }(this);{ {/-first} }{ {/operation} }{ {/operations} }{ {/apis} }{ {/apiInfo} }
2430};
@@ -51,7 +57,7 @@ exports.prototype.post = function post(path, body = {}) {
5157 }
5258
5359 return axiosInstance
54- .post(url, body)
60+ .post(url, body, _this.requestConfig )
5561 .then(function (response) {
5662 return response.data;
5763 } )
@@ -72,6 +78,14 @@ exports.prototype.setDefaultTimeoutMs = function (timeoutMs) {
7278 axiosInstance.defaults.timeout = timeoutMs;
7379}
7480
81+ /**
82+ * @param { Object} headers Add header to request. Example: { ' User-Agent' : ' custom-value' }
83+ */
84+ exports.prototype.setRequestHeaders = function (headers) {
85+ var _this = this;
86+ _this.requestConfig.headers = Object.assign (_this.requestConfig.headers, headers);
87+ } ;
88+
7589// The default API client implementation.
7690exports.instance = function (apiKey) {
7791 return new exports(apiKey);
You can’t perform that action at this time.
0 commit comments