-
Notifications
You must be signed in to change notification settings - Fork 2
쪽지 API
- 쪽지방 생성, 쪽지 생성 api를 분리
- 첫 쪽지 전송, 첫 쪽지 전송이 아닌 경우 api를 분리
추후 논의하여 위 두 가지 경우 중 하나를 결정할 예정- API 하나로 통합
-
URL
/api/v1/message-rooms
-
Method:
POST
-
URL Params
Required:
None
-
Data Params
{ "createdFrom": 103, "receiverId": 56, "isAnonymous": true }
-
createdFrom
: 쪽지가 생성된 게시글의 post_id -
receiverId
: 받는 사람의 user_id -
isAnonymous
: 익명 여부
-
-
Success Response:
-
Code: 201 CREATED
Content:{ "message": "쪽지방 생성 완료", "data": { "messageRoomId": 22 } }
-
Code: 201 CREATED
-
Error Response:
-
Code: 404 NOT FOUND
Content:{ error : "Resource doesn't exist" }
Description: 존재하지 않는 post_id, user_id로 요청했을 때 에러 발생
-
Code: 404 NOT FOUND
-
URL
/api/v1/message-rooms/{messageRoomId}
-
Method:
GET
-
URL Params
Required:
messageRoomId = [integer]
-
Data Params
None
-
Success Response:
-
Code: 200 OK
Content:{ "message": "쪽지방 조회 성공", "data": { "messageRoomId": 22, "createdFrom": 103, "senderId": 72, "receiverId": 56, "isAnonymous": true } }
-
Code: 200 OK
-
Error Response:
-
Code: 404 NOT FOUND
Content:{ error : "Resource doesn't exist" }
Description: 존재하지 않는 message_room_id로 요청했을 때 에러 발생
-
Code: 404 NOT FOUND
-
URL
/api/v1/message-rooms?createdFrom={createdFrom}&firstInterlocutor={firstInterlocutor}&secondInterlocutor={secondInterlocutor}&isAnonymous={isAnonymous}
-
Method:
GET
-
URL Params
Required:
createdFrom = [integer]
firstInterlocutor = [integer]
secondInterlocutor = [integer]
isAnonymous = [boolean] -
Data Params
None
-
Success Response:
-
Code: 200 OK
Content:{ "message": "쪽지방 조회 성공", "data": { "createdFrom": 103, "senderId": 72, "receiverId": 56, "isAnonymous": true } }
-
Code: 200 OK
-
Error Response:
-
Code: 404 NOT FOUND
Content:{ error : "Resource doesn't exist" }
Description: 존재하지 않는 post_id, user_id로 요청했을 때 에러 발생 -
Code: 404 NOT FOUND
Content:{ error : "Message room doesn't exist" }
Description: 요청 데이터와 일치하는 쪽지방이 없는 경우
-
Code: 404 NOT FOUND
-
URL
/api/v1/message-rooms/{userId}
-
Method:
GET
-
URL Params
Required:
userId = [integer]
-
Data Params
None
-
Success Response:
-
Code: 200 OK
Content:{ "message": "쪽지방 조회 성공", "data": { "userId": 32, "content": [ { "messageRoomId": 112, "senderId": 72, "receiverId": 56, "isAnonymous": true, "lastMessage": "감사합니다!!", "createdAt": "2022-06-11T11:22:12" }, { "messageRoomId": 12, "senderId": 52, "receiverId": 26, "isAnonymous": true, "lastMessage": "안녕하세요", "createdAt": "2022-06-03T12:54:41" }, ... ], "pageable": // TODO } }
-
Code: 200 OK
-
Error Response:
-
Code: 404 NOT FOUND
Content:{ error : "Resource doesn't exist" }
Description: 존재하지 않는 user_id 요청했을 때 에러 발생
-
Code: 404 NOT FOUND
-
URL
/api/v1/message-rooms/{messageRoomId}
-
Method:
DELETE
-
URL Params
Required:
messageRoomId = [integer]
-
Data Params
None
-
Success Response:
-
Code: 200 OK
Content:{ "message": "쪽지방 삭제 성공" }
-
Code: 200 OK
-
Error Response:
-
Code: 404 NOT FOUND
Content:{ error : "Resource doesn't exist" }
Description: 존재하지 않는 message_room_id로 요청했을 때 에러 발생
-
Code: 404 NOT FOUND
-
URL
/api/v1/message-rooms/{messageRoomId}/messages
-
Method:
POST
-
URL Params
Required:
messageRoomId = [integer]
-
Data Params
{ "message": "안녕하세요~" }
-
Success Response:
-
Code: 200 OK
Content:{ "message": "쪽지 전송 성공" }
-
Code: 200 OK
-
Error Response:
-
Code: 404 NOT FOUND
Content:{ error : "Resource doesn't exist" }
Description: 존재하지 않는 message_room_id로 요청했을 때 에러 발생 -
Code: 400 BAD REQUEST
Content:{ error : "It is impossible to send a message." }
Description: 차단 상태의 쪽지방에 메세지를 전송한 경우
-
Code: 404 NOT FOUND
-
URL
/api/v1/message-rooms/{messageRoomId}/messages
-
Method:
GET
-
URL Params
Required:
messageRoomId = [integer]
-
Data Params
None
-
Success Response:
-
Code: 200 OK
Content:{ "message": "쪽지 조회 성공", "data": { "messageRoomId": 132, "content": [ { "message": "안녕하세요", "senderId": 72, "receiverId": 56, "createdAt": "2022-06-11T11:22:12" }, { "message": "네~" "senderId": 56, "receiverId": 72, "createdAt": "2022-06-03T12:54:41" }, ... ], "pageable": // TODO } }
-
Code: 200 OK
-
Error Response:
-
Code: 404 NOT FOUND
Content:{ error : "Resource doesn't exist" }
Description: 존재하지 않는 message_room_id로 요청했을 때 에러 발생
-
Code: 404 NOT FOUND
-
URL
/api/v1/message-rooms/{messageRoomId}
-
Method:
PATCH
-
URL Params
Required:
messageRoomId = [integer]
-
Data Params
None
-
Success Response:
-
Code: 200 OK
Content:{ "message": "쪽지방 차단 성공" }
-
Code: 200 OK
-
Error Response:
-
Code: 404 NOT FOUND
Content:{ error : "Resource doesn't exist" }
Description: 존재하지 않는 message_room_id로 요청했을 때 에러 발생
-
Code: 404 NOT FOUND