@@ -13,6 +13,16 @@ var configDefaults = {
1313 timeout : false
1414} ;
1515
16+ function headers ( apiVersion ) {
17+ const nodeVersion = process . versions . node ;
18+ const userAgent = 'button-client-node/' + version + ' node/' + nodeVersion ;
19+
20+ return merge ( compact ( { 'X-Button-API-Version' : apiVersion } ) , {
21+ 'Content-Type' : 'application/json' ,
22+ 'User-Agent' : userAgent
23+ } ) ;
24+ }
25+
1626function client ( apiKey , config ) {
1727 //
1828 // #client provides the top-level interface to making API requests to Button.
@@ -26,6 +36,8 @@ function client(apiKey, config) {
2636 // @param {bool= } config.secure will use HTTPS if true and HTTP if false
2737 // @param {number= } config.timeout a timeout in ms to abort API calls
2838 // @param {Func= } config.promise a function which should return a promise
39+ // @param {string= } config.apiVersion a string pinning your API version for
40+ // the request (YYYY-MM-DD)
2941 // @returns {Object } a client
3042 //
3143 if ( ! apiKey ) {
@@ -44,10 +56,7 @@ function client(apiKey, config) {
4456
4557 var requestOptions = merge ( requestConfig , {
4658 auth : apiKey + ':' ,
47- headers : {
48- 'Content-Type' : 'application/json' ,
49- 'User-Agent' : 'button-client-node/' + version + ' node/' + process . versions . node
50- }
59+ headers : headers ( config . apiVersion )
5160 } ) ;
5261
5362 var maybePromiseRequest = maybePromise (
0 commit comments