Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

Commit 5d7de53

Browse files
author
Rodrigo Fernandes
committed
Merge pull request #14 from codacy/api-2.0
api v2
2 parents da8c20e + 4f6f599 commit 5d7de53

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

lib/reporter.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'use strict';
33

44
var optionsValidation = Joi.object({
5-
endpoint: Joi.string().min(1).optional().example('https://codacy.com/coverage/:token/:commitId')
5+
endpoint: Joi.string().min(1).optional().example('https://codacy.com/api/2.0/coverage/:commitId/:language')
66
});
77
var tokenValidation = Joi.string().required().min(1).example('1234567890');//TODO: Revisit this validation to see if we can better validate the values
88
var commitIdValidation = Joi.string().required().min(1).example('1234567890'); //TODO: Revisit this validation to see if we can better validate the values
@@ -26,7 +26,7 @@
2626
throw optionsValid.error;
2727
}
2828

29-
var endpoint = options.endpoint || 'https://www.codacy.com/api/coverage/:token/:commitId';
29+
var endpoint = options.endpoint || 'https://www.codacy.com/api/2.0/coverage/:commitId/javascript';
3030
logger.debug('Setting up reporter communicating to: ' + endpoint);
3131

3232
return {
@@ -45,13 +45,18 @@
4545
return reject(validationErr);
4646
}
4747

48-
var url = endpoint.replace(':token', token).replace(':commitId', commitId);
48+
var url = endpoint.replace(':commitId', commitId);
4949
logger.trace(util.format('Sending POST to %s', url));
5050

5151
return request({
5252
url: url,
5353
method: 'POST',
5454
json: data,
55+
headers: {
56+
// jscs:disable
57+
'project_token': token
58+
// jscs:enable
59+
},
5560
resolveWithFullResponse: true
5661
}).then(function (res) {
5762
if (res.statusCode !== 200) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codacy-coverage",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "Code Coverage reporter for Codacy.com",
55
"keywords": [
66
"codacy",

test/handleInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
return helper.setupMockEndpoint('1234', '4321', bodyValidator)
4141
.then(function () {
4242
return expect(request({
43-
url: 'https://www.codacy.com/api/coverage/1234/4321',
43+
url: 'https://www.codacy.com/api/2.0/coverage/4321/javascript',
4444
method: 'POST',
4545
json: sampleCoverageData,
4646
resolveWithFullResponse: true

test/helper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
expect(bodyValidator).to.be.ok();
1818

1919
return resolve(nock('https://www.codacy.com')
20-
.post('/api/coverage/' + token + '/' + commitId, function (body) {
20+
.post('/api/2.0/coverage/' + commitId + '/javascript', function (body) {
2121
var result = bodyValidator.validate(body);
2222
return result.error ? false : true;
2323
})

test/reporter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
return helper.setupMockEndpoint('1234', '4321', bodyValidator)
4040
.then(function () {
4141
return expect(request({
42-
url: 'https://www.codacy.com/api/coverage/1234/4321',
42+
url: 'https://www.codacy.com/api/2.0/coverage/4321/javascript',
4343
method: 'POST',
4444
json: sampleCoverageData,
4545
resolveWithFullResponse: true

0 commit comments

Comments
 (0)