Skip to content

Commit 4c35f24

Browse files
authored
Merge pull request #119 from katayama8000/remove-star
Add `Remove star`
2 parents 401445f + 2424226 commit 4c35f24

File tree

6 files changed

+42
-2
lines changed

6 files changed

+42
-2
lines changed

dist/backlog.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,13 @@ var Backlog = /** @class */ (function (_super) {
676676
Backlog.prototype.postStar = function (params) {
677677
return this.post('stars', params);
678678
};
679+
/**
680+
* https://developer.nulab.com/docs/backlog/api/2/remove-star/
681+
*/
682+
Backlog.prototype.removeStar = function (starId) {
683+
var endpoint = "stars/".concat(starId);
684+
return this.delete(endpoint);
685+
};
679686
/**
680687
* https://developer.nulab.com/docs/backlog/api/2/get-notification/
681688
*/

dist/backlog.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/types/backlog.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,10 @@ export default class Backlog extends Request {
444444
* https://developer.nulab.com/docs/backlog/api/2/add-star/
445445
*/
446446
postStar(params: Option.Project.PostStarParams): Promise<void>;
447+
/**
448+
* https://developer.nulab.com/docs/backlog/api/2/remove-star/
449+
*/
450+
removeStar(starId: number): Promise<void>;
447451
/**
448452
* https://developer.nulab.com/docs/backlog/api/2/get-notification/
449453
*/

src/backlog.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,14 @@ export default class Backlog extends Request {
874874
return this.post('stars', params);
875875
}
876876

877+
/**
878+
* https://developer.nulab.com/docs/backlog/api/2/remove-star/
879+
*/
880+
public removeStar(starId: number): Promise<void> {
881+
const endpoint = `stars/${starId}`;
882+
return this.delete(endpoint);
883+
}
884+
877885
/**
878886
* https://developer.nulab.com/docs/backlog/api/2/get-notification/
879887
*/

test/mock.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let undiciInterceptable: Interceptable;
1010
type BodyMatcher = (body: string | Record<string, any>) => boolean;
1111

1212
interface MockParams {
13-
method: "GET" | "POST";
13+
method: "GET" | "POST" | "DELETE";
1414
path: string;
1515
query?: Record<string, any>;
1616
body?: BodyMatcher;
@@ -42,6 +42,8 @@ export const mockRequest = ({
4242
interceptor = nockScope.get(newPath);
4343
} else if (method === "POST" ) {
4444
interceptor = nockScope.post(newPath, body);
45+
} else if (method === "DELETE") {
46+
interceptor = nockScope.delete(newPath);
4547
}
4648

4749
interceptor

test/test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,4 +299,23 @@ describe("Backlog API", () => {
299299
throw err
300300
});
301301
});
302+
303+
it('should remove star.', (done) => {
304+
const starId = 123;
305+
mockRequest({
306+
method: "DELETE",
307+
path: `/api/v2/stars/${starId}`,
308+
query: { apiKey },
309+
status: 204,
310+
data: [],
311+
times: 1,
312+
});
313+
backlog.removeStar(starId).then(data => {
314+
// Should resolve without error and without any value
315+
assert(data === undefined);
316+
done();
317+
}).catch(err => {
318+
throw err;
319+
});
320+
});
302321
});

0 commit comments

Comments
 (0)