Skip to content

Commit

Permalink
Add responce types for IssueComment, PullRequestComment #28
Browse files Browse the repository at this point in the history
  • Loading branch information
Makoto Motohashi committed May 25, 2023
1 parent f89b625 commit b794054
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 34 deletions.
24 changes: 12 additions & 12 deletions dist/types/backlog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,35 +333,35 @@ export default class Backlog extends Request {
/**
* https://developer.nulab.com/docs/backlog/api/2/get-comment-list/
*/
getIssueComments(issueIdOrKey: string | number, params: Option.Issue.GetIssueCommentsParams): Promise<any>;
getIssueComments(issueIdOrKey: string | number, params: Option.Issue.GetIssueCommentsParams): Promise<Entity.Issue.Comment[]>;
/**
* https://developer.nulab.com/docs/backlog/api/2/add-comment/
*/
postIssueComments(issueIdOrKey: string | number, params: Option.Issue.PostIssueCommentsParams): Promise<any>;
postIssueComments(issueIdOrKey: string | number, params: Option.Issue.PostIssueCommentsParams): Promise<Entity.Issue.Comment>;
/**
* https://developer.nulab.com/docs/backlog/api/2/count-comment/
*/
getIssueCommentsCount(issueIdOrKey: string | number): Promise<any>;
getIssueCommentsCount(issueIdOrKey: string | number): Promise<Entity.Issue.IssueCommentCount>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-comment/
*/
getIssueComment(issueIdOrKey: string | number, commentId: number): Promise<any>;
getIssueComment(issueIdOrKey: string | number, commentId: number): Promise<Entity.Issue.Comment>;
/**
* https://developer.nulab.com/docs/backlog/api/2/delete-comment/
*/
deleteIssueComment(issueIdOrKey: string | number, commentId: number): Promise<any>;
deleteIssueComment(issueIdOrKey: string | number, commentId: number): Promise<Entity.Issue.Comment>;
/**
* https://developer.nulab.com/docs/backlog/api/2/update-comment/
*/
patchIssueComment(issueIdOrKey: string | number, commentId: number, params: Option.Issue.PatchIssueCommentParams): Promise<any>;
patchIssueComment(issueIdOrKey: string | number, commentId: number, params: Option.Issue.PatchIssueCommentParams): Promise<Entity.Issue.Comment>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-list-of-comment-notifications/
*/
getIssueCommentNotifications(issueIdOrKey: string | number, commentId: number): Promise<Entity.Issue.CommentNotification[]>;
getIssueCommentNotifications(issueIdOrKey: string | number, commentId: number): Promise<Entity.CommentNotification.CommentNotification[]>;
/**
* https://developer.nulab.com/docs/backlog/api/2/add-comment-notification/
*/
postIssueCommentNotifications(issueIdOrKey: string | number, commentId: number, prams: Option.Issue.IssueCommentNotifications): Promise<any>;
postIssueCommentNotifications(issueIdOrKey: string | number, commentId: number, prams: Option.Issue.IssueCommentNotifications): Promise<Entity.Issue.Comment>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-list-of-issue-attachments/
*/
Expand Down Expand Up @@ -505,19 +505,19 @@ export default class Backlog extends Request {
/**
* https://developer.nulab.com/docs/backlog/api/2/get-pull-request-comment/
*/
getPullRequestComments(projectIdOrKey: string | number, repoIdOrName: string, number: number, params: Option.PullRequest.GetPullRequestCommentsParams): Promise<any>;
getPullRequestComments(projectIdOrKey: string | number, repoIdOrName: string, number: number, params: Option.PullRequest.GetPullRequestCommentsParams): Promise<Entity.PullRequest.Comment[]>;
/**
* https://developer.nulab.com/docs/backlog/api/2/add-pull-request-comment/
*/
postPullRequestComments(projectIdOrKey: string | number, repoIdOrName: string, number: number, params: Option.PullRequest.PostPullRequestCommentsParams): Promise<any>;
postPullRequestComments(projectIdOrKey: string | number, repoIdOrName: string, number: number, params: Option.PullRequest.PostPullRequestCommentsParams): Promise<Entity.PullRequest.Comment>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-number-of-pull-request-comments/
*/
getPullRequestCommentsCount(projectIdOrKey: string | number, repoIdOrName: string, number: number): Promise<any>;
getPullRequestCommentsCount(projectIdOrKey: string | number, repoIdOrName: string, number: number): Promise<Entity.PullRequest.PullRequestCommentCount>;
/**
* https://developer.nulab.com/docs/backlog/api/2/update-pull-request-comment-information/
*/
patchPullRequestComments(projectIdOrKey: string | number, repoIdOrName: string, number: number, commentId: number, params: Option.PullRequest.PatchPullRequestCommentsParams): Promise<any>;
patchPullRequestComments(projectIdOrKey: string | number, repoIdOrName: string, number: number, commentId: number, params: Option.PullRequest.PatchPullRequestCommentsParams): Promise<Entity.PullRequest.Comment>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-list-of-pull-request-attachment/
*/
Expand Down
66 changes: 61 additions & 5 deletions dist/types/entity.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,15 @@ export declare namespace DiskUsage {
details: ProjectDiskUsage[];
}
}
export declare namespace CommentNotification {
interface CommentNotification {
id: number;
alreadyRead: boolean;
reason: number;
user: User.User;
resourceAlreadyRead: boolean;
}
}
export declare namespace Issue {
interface IssueType {
id: number;
Expand Down Expand Up @@ -223,12 +232,20 @@ export declare namespace Issue {
interface IssueCount {
count: number;
}
interface CommentNotification {
interface IssueCommentCount {
count: number;
}
interface Comment {
id: number;
alreadyRead: boolean;
reason: number;
user: User.User;
resourceAlreadyRead: boolean;
projectId: number;
issueId: number;
content: string;
changeLog: ChangeLog.IssueChangeLog[];
createdUser: User.User;
created: string;
updated: string;
stars: Star.Star[];
notifications: CommentNotification.CommentNotification[];
}
}
export declare namespace Star {
Expand Down Expand Up @@ -289,3 +306,42 @@ export declare namespace Wiki {
count: number;
}
}
export declare namespace PullRequest {
interface Comment {
id: number;
content: string;
changeLog: ChangeLog.PullRequestChangeLog[];
createdUser: User.User;
created: string;
updated: string;
stars: Star.Star[];
notifications: CommentNotification.CommentNotification[];
}
interface PullRequestCommentCount {
count: number;
}
}
export declare namespace ChangeLog {
interface ChangeLog {
field: string;
newValue: string;
originalValue: string;
}
interface AttachmentInfo {
id: number;
type: string;
}
interface AttributeInfo {
id: number;
typeId: number;
}
interface NotificationInfo {
type: string;
}
interface IssueChangeLog extends ChangeLog {
attachmentInfo: AttachmentInfo;
attributeInfo: AttributeInfo;
notificationInfo: NotificationInfo;
}
type PullRequestChangeLog = ChangeLog;
}
24 changes: 12 additions & 12 deletions src/backlog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ export default class Backlog extends Request {
*/
public getIssueComments(
issueIdOrKey: string | number, params: Option.Issue.GetIssueCommentsParams
): Promise<any> {
): Promise<Entity.Issue.Comment[]> {
return this.get(`issues/${issueIdOrKey}/comments`, params);
}

Expand All @@ -676,28 +676,28 @@ export default class Backlog extends Request {
*/
public postIssueComments(
issueIdOrKey: string | number, params: Option.Issue.PostIssueCommentsParams
): Promise<any> {
): Promise<Entity.Issue.Comment> {
return this.post(`issues/${issueIdOrKey}/comments`, params);
}

/**
* https://developer.nulab.com/docs/backlog/api/2/count-comment/
*/
public getIssueCommentsCount(issueIdOrKey: string | number): Promise<any> {
public getIssueCommentsCount(issueIdOrKey: string | number): Promise<Entity.Issue.IssueCommentCount> {
return this.get(`issues/${issueIdOrKey}/comments/count`);
}

/**
* https://developer.nulab.com/docs/backlog/api/2/get-comment/
*/
public getIssueComment(issueIdOrKey: string | number, commentId: number): Promise<any> {
public getIssueComment(issueIdOrKey: string | number, commentId: number): Promise<Entity.Issue.Comment> {
return this.get(`issues/${issueIdOrKey}/comments/${commentId}`);
}

/**
* https://developer.nulab.com/docs/backlog/api/2/delete-comment/
*/
public deleteIssueComment(issueIdOrKey: string | number, commentId: number): Promise<any> {
public deleteIssueComment(issueIdOrKey: string | number, commentId: number): Promise<Entity.Issue.Comment> {
return this.delete(`issues/${issueIdOrKey}/comments/${commentId}`);
}

Expand All @@ -706,7 +706,7 @@ export default class Backlog extends Request {
*/
public patchIssueComment(
issueIdOrKey: string | number, commentId: number, params: Option.Issue.PatchIssueCommentParams
): Promise<any> {
): Promise<Entity.Issue.Comment> {
return this.patch(`issues/${issueIdOrKey}/comments/${commentId}`, params);
}

Expand All @@ -715,7 +715,7 @@ export default class Backlog extends Request {
*/
public getIssueCommentNotifications(
issueIdOrKey: string | number, commentId: number
): Promise<Entity.Issue.CommentNotification[]> {
): Promise<Entity.CommentNotification.CommentNotification[]> {
return this.get(`issues/${issueIdOrKey}/comments/${commentId}/notifications`);
}

Expand All @@ -724,7 +724,7 @@ export default class Backlog extends Request {
*/
public postIssueCommentNotifications(
issueIdOrKey: string | number, commentId: number, prams: Option.Issue.IssueCommentNotifications
): Promise<any> {
): Promise<Entity.Issue.Comment> {
return this.post(`issues/${issueIdOrKey}/comments/${commentId}/notifications`, prams);
}

Expand Down Expand Up @@ -1012,7 +1012,7 @@ export default class Backlog extends Request {
repoIdOrName: string,
number: number,
params: Option.PullRequest.GetPullRequestCommentsParams
): Promise<any> {
): Promise<Entity.PullRequest.Comment[]> {
return this.get(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/${number}/comments`, params);
}

Expand All @@ -1024,7 +1024,7 @@ export default class Backlog extends Request {
repoIdOrName: string,
number: number,
params: Option.PullRequest.PostPullRequestCommentsParams
): Promise<any> {
): Promise<Entity.PullRequest.Comment> {
return this.post(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/${number}/comments`, params);
}

Expand All @@ -1033,7 +1033,7 @@ export default class Backlog extends Request {
*/
public getPullRequestCommentsCount(
projectIdOrKey: string | number, repoIdOrName: string, number: number
): Promise<any> {
): Promise<Entity.PullRequest.PullRequestCommentCount> {
return this.get(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/${number}/comments/count`);
}

Expand All @@ -1046,7 +1046,7 @@ export default class Backlog extends Request {
number: number,
commentId: number,
params: Option.PullRequest.PatchPullRequestCommentsParams
): Promise<any> {
): Promise<Entity.PullRequest.Comment> {
return this.patch(`projects/${projectIdOrKey}/git/repositories/${repoIdOrName}/pullRequests/${number}/comments/${commentId}`, params);
}

Expand Down
76 changes: 71 additions & 5 deletions src/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ export namespace DiskUsage {
}
}

export namespace CommentNotification {
export interface CommentNotification {
id: number;
alreadyRead: boolean;
reason: number;
user: User.User;
resourceAlreadyRead: boolean;
}
}

export namespace Issue {
export interface IssueType {
id: number;
Expand Down Expand Up @@ -259,12 +269,21 @@ export namespace Issue {
count: number;
}

export interface CommentNotification {
export interface IssueCommentCount {
count: number;
}

export interface Comment {
id: number;
alreadyRead: boolean;
reason: number;
user: User.User;
resourceAlreadyRead: boolean;
projectId: number;
issueId: number;
content: string;
changeLog: ChangeLog.IssueChangeLog[];
createdUser: User.User;
created: string;
updated: string;
stars: Star.Star[];
notifications: CommentNotification.CommentNotification[];
}
}

Expand Down Expand Up @@ -332,4 +351,51 @@ export namespace Wiki {
export interface WikiCount {
count: number;
}
}

export namespace PullRequest {
export interface Comment {
id: number;
content: string;
changeLog: ChangeLog.PullRequestChangeLog[]
createdUser: User.User;
created: string;
updated: string;
stars: Star.Star[];
notifications: CommentNotification.CommentNotification[];
}

export interface PullRequestCommentCount {
count: number;
}
}

export namespace ChangeLog {
export interface ChangeLog {
field: string;
newValue: string;
originalValue: string;
}

export interface AttachmentInfo {
id: number;
type: string;
}

export interface AttributeInfo {
id: number;
typeId: number;
}

export interface NotificationInfo {
type: string;
}

export interface IssueChangeLog extends ChangeLog {
attachmentInfo: AttachmentInfo;
attributeInfo: AttributeInfo;
notificationInfo: NotificationInfo;
}

export type PullRequestChangeLog = ChangeLog;
}

0 comments on commit b794054

Please sign in to comment.