[KR] 질문 API - 2022-dimipay-recruit/Flutter-Server GitHub Wiki
질문 API
/posts/public
POST request:
- body
- title: string (/^.{1,50}$/)
- content: string (/^.{1,4000}$/)
- isAnnony: boolean (익명인지 여부)
- imageLink: string (사용 안 할 경우 빈값)
- header
- authorization: string (Bearer + JWT)
response:
{
status: 'success',
data: {
id: string (UUID)
}
}
error:
- 400
- Invalid authorization token
- Invalid authorization header type
/posts/public
GET request:
- query (?page[index]=0&page[size]=100&page[order]=desc와 같은 형태로 요청)
- page
- index?: string (/^[1-9][0-9]+$|^[0-9]$/, 기본 0)
- size?: string (/^[1-9][0-9]+$|^[0-9]$/, 기본 100)
- order?: 'desc' | 'asc' (기본 asc)
- page
- header
- authorization: string (Bearer + JWT)
response:
{
status: 'success',
data: {
id: string (UUID),
title: string (/^.{1,50}$/),
content: string (/^.{1,4000}$/),
createdAt: string (ISO 8601 time),
updatedAt: string (ISO 8601 time),
isAnnony: boolean (익명인지 여부),
isCommunity: boolean (커뮤니티 질문인지 여부, 커뮤니티이므로 언제나 true),
imageLink: string (없을 경우 빈 값),
denied: boolean (답변이 거절되었는지),
reveiverId: string | null (수신인, 커뮤니티이므로 언제나 null),
authorId: string (UUID, 작성인),
author: {
id: string (UUID),
link: string (/^[a-z0-9]{6,16}$/),
nickname: string (/^.{3,20}$/),
email: string,
profileImage: string,
description: string,
},
loveCount: number (좋아요 수),
answerCount: number (답변 수)
}[]
}
/posts/userId/:id
POST - params
- id: (UUID, 유저) request:
- body
- title: string (/^.{1,50}$/)
- content: string (/^.{1,4000}$/)
- isAnnony: boolean (익명인지 여부)
- imageLink: string (사용 안 할 경우 빈값)
- header
- authorization: string (Bearer + JWT)
response:
{
status: 'success',
data: {
id: string (UUID)
}
}
error:
- 400
- Invalid authorization token
- Invalid authorization header type
/posts/userId/:id
GET request:
- params
- id: (UUID, 유저)
- query (?page[index]=0&page[size]=100&page[order]=desc와 같은 형태로 요청)
- page
- index?: string (/^[1-9][0-9]+$|^[0-9]$/, 기본 0)
- size?: string (/^[1-9][0-9]+$|^[0-9]$/, 기본 100)
- order?: 'desc' | 'asc' (기본 asc)
- page
- header
- authorization: string (Bearer + JWT)
response:
{
status: 'success',
data: {
id: string (UUID),
title: string (/^.{1,50}$/),
content: string (/^.{1,4000}$/),
createdAt: string (ISO 8601 time),
updatedAt: string (ISO 8601 time),
isAnnony: boolean (익명인지 여부),
isCommunity: boolean (커뮤니티 질문인지 여부, 개인이므로 언제나 false),
imageLink: string (없을 경우 빈 값),
denied: boolean (답변이 거절되었는지),
reveiverId: string | null (수신인, 개인이므로 언제나 string),
reveiver: {
id: string (UUID),
link: string (/^[a-z0-9]{6,16}$/),
nickname: string (/^.{3,20}$/),
email: string,
profileImage: string,
description: string,
},
authorId: string (UUID, 작성인),
author: {
id: string (UUID),
link: string (/^[a-z0-9]{6,16}$/),
nickname: string (/^.{3,20}$/),
email: string,
profileImage: string,
description: string,
},
loveCount: number (좋아요 수),
answerCount: number (답변 수)
}[]
}
error:
- 400
- Invalid authorization token
- Invalid authorization header type
/posts/:id
PATCH request:
- params
- id: (UUID, 글(질문))
- header
- authorization: string (Bearer + JWT)
- body
- title?: string (/^.{1,50}$/)
- content?: string (/^.{1,4000}$/)
response:
{
status: 'success',
(변경된 요소 + id 응답)
data: {
id: string (UUID),
title?: string (/^.{1,50}$/),
content?: string (/^.{1,4000}$/),
}
}
error:
- 401
- Unauthorized user
- 400
- Invalid authorization token
- Invalid authorization header type
/posts/:id
GET request:
- params
- id: (UUID, 글(질문))
- header
- authorization: string (Bearer + JWT)
response:
{
status: 'success',
data: {
id: string (UUID),
title: string (/^.{1,50}$/),
content: string (/^.{1,4000}$/),
createdAt: string (ISO 8601 time),
updatedAt: string (ISO 8601 time),
isAnnony: boolean (익명인지 여부),
isCommunity: boolean (커뮤니티 질문인지 여부),
imageLink: string (없을 경우 빈 값),
denied: boolean (답변이 거절되었는지),
reveiverId: string | null (수신인, 커뮤니티 질문인지 여부에 따라 결정),
(수신인, 커뮤니티 질문인지 여부에 따라 결정)
reveiver?: {
id: string (UUID),
link: string (/^[a-z0-9]{6,16}$/),
nickname: string (/^.{3,20}$/),
email: string,
profileImage: string,
description: string,
},
authorId: string (UUID, 작성인),
author: {
id: string (UUID),
link: string (/^[a-z0-9]{6,16}$/),
nickname: string (/^.{3,20}$/),
email: string,
profileImage: string,
description: string,
},
loveCount: number (좋아요 수),
answerCount: number (답변 수)
}[]
}
error:
- 400
- Invalid authorization token
- Invalid authorization header type
/posts/:id
DELETE request:
- params
- id: (UUID, 글(질문))
- header
- authorization: string (Bearer + JWT)
response:
{
status: 'success',
data: null
}
error:
- 401
- Unauthorized user
- 400
- Invalid authorization token
- Invalid authorization header type
/posts/:id/love
POST request:
- params
- id: (UUID, 글(질문))
- header
- authorization: string (Bearer + JWT)
response:
{
status: 'success',
data: {
id: string (UUID)
}
}
error:
- 400
- Invalid authorization token
- Invalid authorization header type
/posts/:id/love
DELETE request:
- params
- id: (UUID, 글(질문))
- header
- authorization: string (Bearer + JWT)
response:
{
status: 'success',
data: null
}
error:
- 400
- Invalid authorization token
- Invalid authorization header type
/posts/:id/bookmark
POST request:
- params
- id: (UUID, 글(질문))
- header
- authorization: string (Bearer + JWT)
response:
{
status: 'success',
data: {
id: string (UUID)
}
}
error:
- 400
- Invalid authorization token
- Invalid authorization header type
/posts/:id/bookmark
DELETE request:
- params
- id: (UUID, 글(질문))
- header
- authorization: string (Bearer + JWT)
response:
{
status: 'success',
data: null
}
error:
- 400
- Invalid authorization token
- Invalid authorization header type
/posts/:id/report
POST request:
- params
- id: (UUID, 글(질문))
- body
- reason: 신고 이유 (자유로운 string)
- header
- authorization: string (Bearer + JWT)
response:
{
status: 'success',
data: {
id: string (UUID, 신고한 글의 UUID)
}
}
error:
- 400
- Invalid authorization token
- Invalid authorization header type
/posts/:id/deny
POST request:
- params
- id: (UUID, 글(질문))
- header
- authorization: string (Bearer + JWT)
response:
{
status: 'success',
data: {
id: string (UUID)
}
}
error:
- 400
- Invalid authorization token
- Invalid authorization header type