Skip to content

Commit

Permalink
refactor baseURL rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
eshanholtz committed Mar 18, 2020
1 parent 5a139ce commit 82c129a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
14 changes: 6 additions & 8 deletions packages/client/src/classes/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Client {

//Empty default request
this.defaultRequest = {
baseURL: 'https://api.sendgrid.com/',
baseUrl: 'https://api.sendgrid.com/',
url: '',
method: 'GET',
headers: {},
Expand All @@ -62,11 +62,7 @@ class Client {
* Set default request
*/
setDefaultRequest(key, value) {
if (key === 'baseUrl') {
this.defaultRequest.baseURL = value;
} else {
this.defaultRequest[key] = value;
}
this.defaultRequest[key] = value;
return this;
}

Expand Down Expand Up @@ -94,7 +90,7 @@ class Client {

let options = {
url: opts.uri || opts.url,
baseURL: opts.baseUrl,
baseUrl: opts.baseUrl,
method: opts.method,
data: opts.body,
params: opts.qs,
Expand All @@ -103,8 +99,10 @@ class Client {

//Merge data with empty request
options = mergeData(this.defaultRequest, options);

options.headers = this.createHeaders(options.headers);
options.baseURL = options.baseUrl;
delete options.baseUrl;

return options;
}

Expand Down
14 changes: 1 addition & 13 deletions packages/client/src/client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,7 @@ describe('test_access_settings_activity_get', () => {
request.method = 'GET';
request.url = '/v3/access_settings/activity';
it('should have the correct response code', () => {
<<<<<<< HEAD
return testRequest(request, 200);
=======
const sgClient = require('./client');
sgClient.setApiKey('SendGrid API Key');
sgClient.setDefaultRequest('baseURL', baseURL);
sgClient.setDefaultHeader('X-Mock', 200);
return sgClient
.request(request)
.then(([response, body]) => {
expect(response.statusCode).to.equal(200);
});
>>>>>>> this fails
return testRequest(request, 200);
});
});

Expand Down

0 comments on commit 82c129a

Please sign in to comment.