-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEmotionRepository.swift
More file actions
30 lines (24 loc) · 1.04 KB
/
Copy pathEmotionRepository.swift
File metadata and controls
30 lines (24 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//
// EmotionRepository.swift
// DataSource
//
// Created by 최정인 on 7/28/25.
//
import Domain
final class EmotionRepository: EmotionRepositoryProtocol {
private let networkService = NetworkService.shared
func fetchEmotions() async throws -> [EmotionEntity] {
let endpoint = EmotionEndpoint.fetchEmotions
guard let response = try await networkService.request(endpoint: endpoint, type: [EmotionResponseDTO].self)
else { return [] }
let emotionEntities = response.compactMap({ $0.toEmotionEntity() })
return emotionEntities
}
func registerEmotion(emotion: String) async throws -> [RecommendedRoutineEntity] {
let endpoint = EmotionEndpoint.registerEmotion(emotion: emotion)
guard let response = try await networkService.request(endpoint: endpoint, type: RecommendedRoutineListResponseDTO.self)
else { return [] }
let recommendedRoutineEntity = response.recommendedRoutines.compactMap({ $0.toRecommendedRoutineEntity() })
return recommendedRoutineEntity
}
}