feat(main): 홈 대화 탭을 추가한다

This commit is contained in:
Yu Sung
2026-07-08 15:54:07 +09:00
parent 403eee262f
commit 09443761af
13 changed files with 938 additions and 23 deletions

View File

@@ -0,0 +1,45 @@
import Foundation
import Moya
enum MainChatApi {
case getChatRooms(filter: String, cursor: String?)
}
extension MainChatApi: TargetType {
var baseURL: URL {
return URL(string: BASE_URL)!
}
var path: String {
switch self {
case .getChatRooms:
return "/api/v2/chat/rooms"
}
}
var method: Moya.Method {
switch self {
case .getChatRooms:
return .get
}
}
var task: Moya.Task {
switch self {
case .getChatRooms(let filter, let cursor):
var parameters: [String: Any] = [
"filter": filter
]
if let cursor {
parameters["cursor"] = cursor
}
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
}
}
var headers: [String: String]? {
return ["Authorization": "Bearer \(UserDefaults.string(forKey: UserDefaultsKey.token))"]
}
}

View File

@@ -0,0 +1,12 @@
import Foundation
import Combine
import CombineMoya
import Moya
final class MainChatRepository {
private let api = MoyaProvider<MainChatApi>()
func getChatRooms(filter: String, cursor: String?) -> AnyPublisher<Response, MoyaError> {
return api.requestPublisher(.getChatRooms(filter: filter, cursor: cursor))
}
}