Skip to content

Commit

Permalink
Add responce types for Notification, Webhook, License, RateLimit, Iss…
Browse files Browse the repository at this point in the history
…ueParticipants #28
  • Loading branch information
mmktomato committed Jun 2, 2023
1 parent 823e117 commit 29effcb
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 26 deletions.
24 changes: 12 additions & 12 deletions dist/types/backlog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,23 +289,23 @@ export default class Backlog extends Request {
/**
* https://developer.nulab.com/docs/backlog/api/2/get-list-of-webhooks/
*/
getWebhooks(projectIdOrKey: string | number): Promise<any>;
getWebhooks(projectIdOrKey: string | number): Promise<Entity.Webhook.Webhook[]>;
/**
* https://developer.nulab.com/docs/backlog/api/2/add-webhook/
*/
postWebhook(projectIdOrKey: string | number, params: Option.Project.PostWebhookParams): Promise<any>;
postWebhook(projectIdOrKey: string | number, params: Option.Project.PostWebhookParams): Promise<Entity.Webhook.Webhook>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-webhook/
*/
getWebhook(projectIdOrKey: string | number, webhookId: string): Promise<any>;
getWebhook(projectIdOrKey: string | number, webhookId: string): Promise<Entity.Webhook.Webhook>;
/**
* https://developer.nulab.com/docs/backlog/api/2/update-webhook/
*/
patchWebhook(projectIdOrKey: string | number, webhookId: string, params: Option.Project.PatchWebhookParams): Promise<any>;
patchWebhook(projectIdOrKey: string | number, webhookId: string, params: Option.Project.PatchWebhookParams): Promise<Entity.Webhook.Webhook>;
/**
* https://developer.nulab.com/docs/backlog/api/2/delete-webhook/
*/
deleteWebhook(projectIdOrKey: string | number, webhookId: string): Promise<any>;
deleteWebhook(projectIdOrKey: string | number, webhookId: string): Promise<Entity.Webhook.Webhook>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-issue-list/
*/
Expand Down Expand Up @@ -377,7 +377,7 @@ export default class Backlog extends Request {
/**
* https://developer.nulab.com/docs/backlog/api/2/get-issue-participant-list/
*/
getIssueParticipants(issueIdOrKey: string | number): Promise<any>;
getIssueParticipants(issueIdOrKey: string | number): Promise<Entity.User.User[]>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-list-of-linked-shared-files/
*/
Expand Down Expand Up @@ -461,19 +461,19 @@ export default class Backlog extends Request {
/**
* https://developer.nulab.com/docs/backlog/api/2/get-notification/
*/
getNotifications(params: Option.Notification.GetNotificationsParams): Promise<any>;
getNotifications(params: Option.Notification.GetNotificationsParams): Promise<Entity.Notification.Notification[]>;
/**
* https://developer.nulab.com/docs/backlog/api/2/count-notification/
*/
getNotificationsCount(params: Option.Notification.GetNotificationsCountParams): Promise<any>;
getNotificationsCount(params: Option.Notification.GetNotificationsCountParams): Promise<Entity.Notification.NotificationCount>;
/**
* https://developer.nulab.com/docs/backlog/api/2/reset-unread-notification-count/
*/
resetNotificationsMarkAsRead(): Promise<any>;
resetNotificationsMarkAsRead(): Promise<Entity.Notification.NotificationCount>;
/**
* https://developer.nulab.com/docs/backlog/api/2/read-notification/
*/
markAsReadNotification(id: number): Promise<any>;
markAsReadNotification(id: number): Promise<void>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-list-of-git-repositories/
*/
Expand Down Expand Up @@ -581,7 +581,7 @@ export default class Backlog extends Request {
/**
* https://developer.nulab.com/docs/backlog/api/2/get-licence
*/
getLicence(): Promise<any>;
getLicence(): Promise<Entity.License.License>;
/**
* https://developer.nulab.com/docs/backlog/api/2/get-list-of-teams/
*/
Expand Down Expand Up @@ -621,7 +621,7 @@ export default class Backlog extends Request {
/**
* https://developer.nulab.com/docs/backlog/api/2/get-rate-limit/
*/
getRateLimit(): Promise<any>;
getRateLimit(): Promise<Entity.RateLimit.RateLimit>;
private download;
private upload;
private parseFileData;
Expand Down
84 changes: 84 additions & 0 deletions dist/types/entity.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,3 +432,87 @@ export declare namespace Team {
updated: string;
}
}
export declare namespace Notification {
interface Notification {
id: number;
alreadyRead: boolean;
reason: number;
resourceAlreadyRead: boolean;
project: Project.Project;
issue?: Issue.Issue;
comment?: Issue.Comment;
pullRequest?: PullRequest.PullRequest;
pullRequestComment?: PullRequest.Comment;
sender: User.User;
created: string;
}
interface NotificationCount {
count: number;
}
}
export declare namespace Webhook {
interface Webhook {
id: number;
name: string;
description: string;
hookUrl: string;
allEvent: boolean;
activityTypeIds: Types.WebhookActivityId[];
createdUser: User.User;
created: string;
updatedUser: User.User;
updated: string;
}
}
export declare namespace License {
interface License {
active: boolean;
attachmentLimit: number;
attachmentLimitPerFile: number;
attachmentNumLimit: number;
attribute: boolean;
attributeLimit: number;
burndown: boolean;
commentLimit: number;
componentLimit: number;
fileSharing: boolean;
gantt: boolean;
git: boolean;
issueLimit: number;
licenceTypeId: number;
limitDate: string;
nulabAccount: boolean;
parentChildIssue: boolean;
postIssueByMail: boolean;
projectLimit: number;
pullRequestAttachmentLimitPerFile: number;
pullRequestAttachmentNumLimit: number;
remoteAddress: boolean;
remoteAddressLimit: number;
startedOn: string;
storageLimit: number;
subversion: boolean;
subversionExternal: boolean;
userLimit: number;
versionLimit: number;
wikiAttachment: boolean;
wikiAttachmentLimitPerFile: number;
wikiAttachmentNumLimit: number;
}
}
export declare namespace RateLimit {
interface RateLimit {
rateLimit: ApiRateLimits;
}
interface ApiRateLimits {
read: ApiRateLimit;
update: ApiRateLimit;
search: ApiRateLimit;
icon: ApiRateLimit;
}
interface ApiRateLimit {
limit: number;
remaining: number;
reset: number;
}
}
2 changes: 1 addition & 1 deletion dist/types/option.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export declare namespace Project {
description?: string;
hookUrl?: string;
allEvent?: boolean;
activityTypeIds?: number[];
activityTypeIds?: Types.WebhookActivityId[];
}
interface PatchWebhookParams {
name?: string;
Expand Down
1 change: 1 addition & 0 deletions dist/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ export declare enum CustomFieldType {
CheckBox = 7,
Radio = 8
}
export declare type WebhookActivityId = number;
24 changes: 12 additions & 12 deletions src/backlog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ export default class Backlog extends Request {
*/
public getWebhooks(
projectIdOrKey: string | number
): Promise<any> {
): Promise<Entity.Webhook.Webhook[]> {
return this.get(`projects/${projectIdOrKey}/webhooks`);
}

Expand All @@ -586,7 +586,7 @@ export default class Backlog extends Request {
*/
public postWebhook(
projectIdOrKey: string | number, params: Option.Project.PostWebhookParams
): Promise<any> {
): Promise<Entity.Webhook.Webhook> {
return this.post(`projects/${projectIdOrKey}/webhooks`, params);
}

Expand All @@ -595,7 +595,7 @@ export default class Backlog extends Request {
*/
public getWebhook(
projectIdOrKey: string | number, webhookId: string
): Promise<any> {
): Promise<Entity.Webhook.Webhook> {
return this.get(`projects/${projectIdOrKey}/webhooks/${webhookId}`);
}

Expand All @@ -604,7 +604,7 @@ export default class Backlog extends Request {
*/
public patchWebhook(
projectIdOrKey: string | number, webhookId: string, params: Option.Project.PatchWebhookParams
): Promise<any> {
): Promise<Entity.Webhook.Webhook> {
return this.patch(`projects/${projectIdOrKey}/webhooks/${webhookId}`, params);
}

Expand All @@ -613,7 +613,7 @@ export default class Backlog extends Request {
*/
public deleteWebhook(
projectIdOrKey: string | number, webhookId: string
): Promise<any> {
): Promise<Entity.Webhook.Webhook> {
return this.delete(`projects/${projectIdOrKey}/webhooks/${webhookId}`);
}

Expand Down Expand Up @@ -752,7 +752,7 @@ export default class Backlog extends Request {
/**
* https://developer.nulab.com/docs/backlog/api/2/get-issue-participant-list/
*/
public getIssueParticipants(issueIdOrKey: string | number): Promise<any> {
public getIssueParticipants(issueIdOrKey: string | number): Promise<Entity.User.User[]> {
return this.get(`issues/${issueIdOrKey}/participants`);
}

Expand Down Expand Up @@ -907,7 +907,7 @@ export default class Backlog extends Request {
*/
public getNotifications(
params: Option.Notification.GetNotificationsParams
): Promise<any> {
): Promise<Entity.Notification.Notification[]> {
return this.get('notifications', params);
}

Expand All @@ -916,21 +916,21 @@ export default class Backlog extends Request {
*/
public getNotificationsCount(
params: Option.Notification.GetNotificationsCountParams
): Promise<any> {
): Promise<Entity.Notification.NotificationCount> {
return this.get('notifications/count', params);
}

/**
* https://developer.nulab.com/docs/backlog/api/2/reset-unread-notification-count/
*/
public resetNotificationsMarkAsRead(): Promise<any> {
public resetNotificationsMarkAsRead(): Promise<Entity.Notification.NotificationCount> {
return this.post('notifications/markAsRead');
}

/**
* https://developer.nulab.com/docs/backlog/api/2/read-notification/
*/
public markAsReadNotification(id: number): Promise<any> {
public markAsReadNotification(id: number): Promise<void> {
return this.post(`notifications/${id}/markAsRead`);
}

Expand Down Expand Up @@ -1165,7 +1165,7 @@ export default class Backlog extends Request {
/**
* https://developer.nulab.com/docs/backlog/api/2/get-licence
*/
public getLicence(): Promise<any> {
public getLicence(): Promise<Entity.License.License> {
return this.get(`space/licence`);
}

Expand Down Expand Up @@ -1235,7 +1235,7 @@ export default class Backlog extends Request {
/**
* https://developer.nulab.com/docs/backlog/api/2/get-rate-limit/
*/
public getRateLimit(): Promise<any> {
public getRateLimit(): Promise<Entity.RateLimit.RateLimit> {
return this.get("rateLimit");
}

Expand Down
91 changes: 91 additions & 0 deletions src/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,4 +490,95 @@ export namespace Team {
updatedUser: User.User;
updated: string;
}
}

export namespace Notification {
export interface Notification {
id: number;
alreadyRead: boolean;
reason: number;
resourceAlreadyRead: boolean;
project: Project.Project;
issue?: Issue.Issue;
comment?: Issue.Comment;
pullRequest?: PullRequest.PullRequest;
pullRequestComment?: PullRequest.Comment;
sender: User.User;
created: string;
}

export interface NotificationCount {
count: number;
}
}

export namespace Webhook {
export interface Webhook {
id: number;
name: string;
description: string;
hookUrl: string;
allEvent: boolean;
activityTypeIds: Types.WebhookActivityId[];
createdUser: User.User;
created: string;
updatedUser: User.User;
updated: string;
}
}

export namespace License {
export interface License {
active: boolean;
attachmentLimit: number;
attachmentLimitPerFile: number;
attachmentNumLimit: number;
attribute: boolean;
attributeLimit: number;
burndown: boolean;
commentLimit: number;
componentLimit: number;
fileSharing: boolean;
gantt: boolean;
git: boolean;
issueLimit: number;
licenceTypeId: number;
limitDate: string;
nulabAccount: boolean;
parentChildIssue: boolean;
postIssueByMail: boolean;
projectLimit: number;
pullRequestAttachmentLimitPerFile: number;
pullRequestAttachmentNumLimit: number;
remoteAddress: boolean;
remoteAddressLimit: number;
startedOn: string;
storageLimit: number;
subversion: boolean;
subversionExternal: boolean;
userLimit: number;
versionLimit: number;
wikiAttachment: boolean;
wikiAttachmentLimitPerFile: number;
wikiAttachmentNumLimit: number;
}
}

export namespace RateLimit {
export interface RateLimit {
rateLimit: ApiRateLimits;
}

export interface ApiRateLimits {
read: ApiRateLimit;
update: ApiRateLimit;
search: ApiRateLimit;
icon: ApiRateLimit;
}

export interface ApiRateLimit {
limit: number;
remaining: number;
reset: number;
}
}
2 changes: 1 addition & 1 deletion src/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
description?: string;
hookUrl?: string;
allEvent?: boolean;
activityTypeIds?: number[];
activityTypeIds?: Types.WebhookActivityId[];
}

export interface PatchWebhookParams {
Expand Down
Loading

0 comments on commit 29effcb

Please sign in to comment.