커뮤니티 게시물 전체보기, 좋아요, 댓글 추가 API 적용

This commit is contained in:
Yu Sung
2023-12-20 14:28:20 +09:00
parent 28b64ba8a8
commit 02764f5fe8
11 changed files with 313 additions and 43 deletions

View File

@@ -10,6 +10,9 @@ import Moya
enum CreatorCommunityApi {
case createCommunityPost(parameters: [MultipartFormData])
case getCommunityPostList(creatorId: Int, page: Int, size: Int)
case communityPostLike(postId: Int)
case createCommunityPostComment(comment: String, postId: Int, parentId: Int?)
}
extension CreatorCommunityApi: TargetType {
@@ -19,15 +22,24 @@ extension CreatorCommunityApi: TargetType {
var path: String {
switch self {
case .createCommunityPost:
case .createCommunityPost, .getCommunityPostList:
return "/creator-community"
case .communityPostLike:
return "/creator-community/like"
case .createCommunityPostComment:
return "/creator-community/comment"
}
}
var method: Moya.Method {
switch self {
case .createCommunityPost:
case .createCommunityPost, .communityPostLike, .createCommunityPostComment:
return .post
case .getCommunityPostList:
return .get
}
}
@@ -35,6 +47,23 @@ extension CreatorCommunityApi: TargetType {
switch self {
case .createCommunityPost(let parameters):
return .uploadMultipart(parameters)
case .getCommunityPostList(let creatorId, let page, let size):
let parameters = [
"creatorId": creatorId,
"page": page - 1,
"size": size,
"timezone": TimeZone.current.identifier
] as [String: Any]
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
case .communityPostLike(let postId):
let request = PostCommunityPostLikeRequest(postId: postId)
return .requestJSONEncodable(request)
case .createCommunityPostComment(let comment, let postId, let parentId):
let request = CreateCommunityPostCommentRequest(comment: comment, postId: postId, parentId: parentId)
return .requestJSONEncodable(request)
}
}