Skip to content

Commit

Permalink
fix(request): modify UA to have version of the SDK
Browse files Browse the repository at this point in the history
The current User-Agent header reports the version of the Smartcar API
being hit, which is allow in the URL, it should instead have the
version of the SDK being used
  • Loading branch information
gurpreetatwal committed Jul 11, 2018
1 parent 83d8bce commit 9a9398b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/util.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
'use strict';

const StatusCodeError = require('request-promise/errors').StatusCodeError;
const _ = require('lodash');
const request = require('request-promise');
const {StatusCodeError} = require('request-promise/errors');

const config = require('./config');
const errors = require('./errors');
const {version} = require('../package.json');

const util = {};

Expand Down Expand Up @@ -52,7 +53,7 @@ util.getUrl = function(id, endpoint) {
util.request = request.defaults({
json: true,
headers: {
'User-Agent': `smartcar-node-sdk:${config.version}`,
'User-Agent': `smartcar-node-sdk:${version}`,
},
});

Expand Down
4 changes: 2 additions & 2 deletions test/lib/vehicle.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const nock = require('nock');
const test = require('ava');

const Vehicle = require('../../lib/vehicle');
const config = require('../../lib/config');
const {version} = require('../../package.json');

const VID = 'ada7207c-3c0a-4027-a47f-6215ce6f7b93';
const TOKEN = '9ad942c6-32b8-4af2-ada6-5e8ecdbad9c2';
const USER_AGENT = `smartcar-node-sdk:${config.version}`;
const USER_AGENT = `smartcar-node-sdk:${version}`;

const vehicle = new Vehicle(VID, TOKEN);

Expand Down

0 comments on commit 9a9398b

Please sign in to comment.