[KR] 질문 API - 2022-dimipay-recruit/Flutter-Server GitHub Wiki

질문 API


POST /posts/public

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

GET /posts/public

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)
  • 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 (답변 수)
  }[]
}

POST /posts/userId/:id

  • 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

GET /posts/userId/:id

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)
  • 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

PATCH /posts/:id

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

GET /posts/:id

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

DELETE /posts/:id

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

POST /posts/:id/love

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

DELETE /posts/:id/love

request:

  • params
    • id: (UUID, 글(질문))
  • header
    • authorization: string (Bearer + JWT)

response:

{
  status: 'success',
  data: null
}

error:

  • 400
    • Invalid authorization token
    • Invalid authorization header type

POST /posts/:id/bookmark

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

DELETE /posts/:id/bookmark

request:

  • params
    • id: (UUID, 글(질문))
  • header
    • authorization: string (Bearer + JWT)

response:

{
  status: 'success',
  data: null
}

error:

  • 400
    • Invalid authorization token
    • Invalid authorization header type

POST /posts/:id/report

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

POST /posts/:id/deny

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