Skip to content

Commit ea8a761

Browse files
committed
テンプレート関連関数追加
1 parent 59a1cf1 commit ea8a761

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

src/qiita.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,5 +541,67 @@ export class Qiita {
541541
return this.put(`${this.endpoint}${this.version}/tags/${tagId}/following`);
542542
}
543543

544+
/**
545+
* ユーザが所属している全てのチームを、チーム作成日時の降順で返します。
546+
* @return チーム一覧
547+
*/
548+
public fetchTeams = (): Promise<Qiita.Team[]> => {
549+
return this.get(`${this.endpoint}${this.version}/teams`);
550+
}
551+
552+
/**
553+
* チーム内のテンプレート一覧を返します。
554+
* @param page ページ番号 (1から100まで)
555+
* @param perPage 1ページあたりに含まれる要素数 (1から100まで)
556+
* @return テンプレート一覧
557+
*/
558+
public fetchTemplates = (page: string, perPage: string): Promise<Qiita.Template[]> => {
559+
return this.get(`${this.endpoint}${this.version}/templates`, {
560+
page,
561+
per_page: perPage,
562+
});
563+
}
564+
565+
/**
566+
* テンプレートを削除します。
567+
* @param templateId テンプレートID
568+
* @return 空のオブジェクト
569+
*/
570+
public deleteTemplate = (templateId: string): Promise<{}> => {
571+
return this.delete(`${this.endpoint}${this.version}/templates/${templateId}`);
572+
}
573+
574+
/**
575+
* テンプレートを取得します。
576+
* @param tempalteId テンプレートID
577+
* @return テンプレート
578+
*/
579+
public fetchTempalte = (templateId: string): Promise<Qiita.Template> => {
580+
return this.get(`${this.endpoint}${this.version}/templates/${templateId}`);
581+
}
582+
583+
/**
584+
* 新しくテンプレートを作成します。
585+
* @param body テンプレートの本文
586+
* @param name テンプレートを判別するための名前
587+
* @param tags タグ一覧
588+
* @param title 生成される投稿のタイトルの雛形
589+
* @return テンプレート
590+
*/
591+
public createTemplate = (body: string, name: string, tags: Qiita.Tagging, title: string): Promise<Qiita.Template> => {
592+
return this.post(`${this.endpoint}${this.version}/templates`, { body, name, tags, title });
593+
}
594+
595+
/**
596+
* テンプレートを更新します。
597+
* @param body テンプレートの本文
598+
* @param name テンプレートを判別するための名前
599+
* @param tags タグ一覧
600+
* @param title 生成される投稿のタイトルの雛形
601+
* @return テンプレート
602+
*/
603+
public updateTempalte = (body: string, name: string, tags: Qiita.Tagging, title: string): Promise<Qiita.Template> => {
604+
return this.patch(`${this.endpoint}${this.version}/templates`, { body, name, tags, title });
605+
}
544606

545607
}

0 commit comments

Comments
 (0)