커뮤니티 게시물 전체보기, 좋아요, 댓글 추가 API 적용
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user