Skip to content

Commit

Permalink
feat: Add GET associations (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikuroXina authored Aug 21, 2023
1 parent 5b9c458 commit 92735e6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ API とは別に登録処理用の簡易的な画面を `/` (ルート) で用

### 関連付け情報

`GET /members/{id}/associations` は特定のメンバーに関連付けられたアカウント情報のリストを取得します.

以下のエンドポイントは, ヘッダーに `Authorization: Bearer <oauth-token>` の形式の認証情報が必要です. この `<oauth-token>` は Discord の OAuth トークンであり, これには `identify``guilds.members.read` の scope が付与されている必要があります.

`PUT /members/{id}/associations` は特定のメンバーに関連付けられたアカウント情報を, リクエスト本文のリストで上書きします. スキーマの詳細は openapi.yaml を確認してください.
Expand Down
15 changes: 15 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,21 @@ paths:
404:
description: "Not Found"
/members/{discordId}/associations:
get:
summary: "Retrieves associated links."
tags: ["associations"]
deprecated: false
responses:
200:
description: "Links list"
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/AssociatedLink"
404:
description: "Not Found"
put:
summary: "Replaces associated links with the given list."
tags: ["associations"]
Expand Down
3 changes: 3 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ app.use("/members/:id/associations", async (c, next) => {
await next();
});

app.put("/members/:id/associations", async (c) => {
return c.json(c.get("member").associatedLinks);
});
app.put("/members/:id/associations", async (c) => {
const id = c.req.param("id");
const result = AssociatedLinksSchema.safeParse(await c.req.json());
Expand Down

0 comments on commit 92735e6

Please sign in to comment.