-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlaceRepository.swift
More file actions
55 lines (47 loc) · 1.61 KB
/
PlaceRepository.swift
File metadata and controls
55 lines (47 loc) · 1.61 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//
// PlaceRepository.swift
// Data
//
// Created by 최안용 on 2/14/26.
// Copyright © 2026 NDGL-iOS. All rights reserved.
//
import Foundation
import Domain
import Networks
public final class PlaceRepository: PlaceRepositoryInterface {
private let service: PlaceServiceProtocol
private let googlePlacesService: GooglePlacesServiceProtocol
public init(service: PlaceServiceProtocol, googlePlacesService: GooglePlacesServiceProtocol) {
self.service = service
self.googlePlacesService = googlePlacesService
}
public func searchPlaces(keyword: String) async throws -> [PlaceSearchResult] {
do {
let response = try await googlePlacesService.searchText(keyword: keyword)
return (response.places ?? []).compactMap { $0.toDomain() }
} catch {
throw error.toNDGLError()
}
}
public func registerPlace(googlePlaceId: String) async throws {
do {
try await service.registerPlace(googlePlaceId: googlePlaceId)
} catch {
throw error.toNDGLError()
}
}
public func fetchPlacePhotos(googlePlaceId: String) async throws -> [PlacePhoto] {
do {
return try await service.getPlacePhotos(googlePlaceId: googlePlaceId).toDomain()
} catch {
throw error.toNDGLError()
}
}
public func fetchPlaceDetail(googlePlaceId: String) async throws -> PlaceDetail {
do {
return try await service.getPlaceDetails(googlePlaceId: googlePlaceId).toDomain()
} catch {
throw error.toNDGLError()
}
}
}