Skip to content

Commit 02c9b72

Browse files
committed
プロジェクト関連の機能を追加
1 parent ea8a761 commit 02c9b72

File tree

1 file changed

+57
-2
lines changed

1 file changed

+57
-2
lines changed

src/qiita.ts

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ export class Qiita {
588588
* @param title 生成される投稿のタイトルの雛形
589589
* @return テンプレート
590590
*/
591-
public createTemplate = (body: string, name: string, tags: Qiita.Tagging, title: string): Promise<Qiita.Template> => {
591+
public createTemplate = (body: string, name: string, tags: Qiita.Tagging[], title: string): Promise<Qiita.Template> => {
592592
return this.post(`${this.endpoint}${this.version}/templates`, { body, name, tags, title });
593593
}
594594

@@ -600,8 +600,63 @@ export class Qiita {
600600
* @param title 生成される投稿のタイトルの雛形
601601
* @return テンプレート
602602
*/
603-
public updateTempalte = (body: string, name: string, tags: Qiita.Tagging, title: string): Promise<Qiita.Template> => {
603+
public updateTempalte = (body: string, name: string, tags: Qiita.Tagging[], title: string): Promise<Qiita.Template> => {
604604
return this.patch(`${this.endpoint}${this.version}/templates`, { body, name, tags, title });
605605
}
606606

607+
/**
608+
* チーム内に存在するプロジェクト一覧をプロジェクト作成日時の降順で返します。
609+
* @param page ページ番号 (1から100まで)
610+
* @param perPage 1ページあたりに含まれる要素数 (1から100まで)
611+
* @return プロジェクト一覧
612+
*/
613+
public fetchProjects = (page: string, perPage: string): Promise<Qiita.Project[]> => {
614+
return this.get(`${this.endpoint}${this.version}/projects`, {
615+
page,
616+
per_page: perPage,
617+
});
618+
}
619+
620+
/**
621+
* プロジェクトを新たに作成します。
622+
* @param archived このプロジェクトが進行中かどうか
623+
* @param body Markdown形式の本文
624+
* @param name プロジェクト名
625+
* @param tags 投稿に付いたタグ一覧
626+
* @return プロジェクト
627+
*/
628+
public createProject = (archived: boolean, body: string, name: string, tags: Qiita.Tagging[]): Promise<Qiita.Project> => {
629+
return this.post(`${this.endpoint}${this.version}/projects`, { archived, body, name, tags });
630+
}
631+
632+
/**
633+
* プロジェクトを削除します。
634+
* @param projectId プロジェクトID
635+
* @return 空のオブジェクト
636+
*/
637+
public deleteProject = (projectId: string): Promise<{}> => {
638+
return this.delete(`${this.endpoint}${this.version}/projects/${projectId}`);
639+
}
640+
641+
/**
642+
* プロジェクトを返します。
643+
* @param projectId プロジェクトID
644+
* @return プロジェクト
645+
*/
646+
public fetchProject = (projectId: string): Promise<Qiita.Project> => {
647+
return this.get(`${this.endpoint}${this.version}/projects/${projectId}`);
648+
}
649+
650+
/**
651+
* プロジェクトを更新します。
652+
* @param archived このプロジェクトが進行中かどうか
653+
* @param body Markdown形式の本文
654+
* @param name プロジェクト名
655+
* @param tags 投稿に付いたタグ一覧
656+
* @return プロジェクト
657+
*/
658+
public updateProject = (archived: boolean, body: string, name: string, tags: Qiita.Tagging[]): Promise<Qiita.Project> => {
659+
return this.patch(`${this.endpoint}${this.version}/projects`, { archived, body, name, tags });
660+
}
661+
607662
}

0 commit comments

Comments
 (0)