Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public struct CollectionListResponseDTO: Decodable {
public let createdAt: [Int]
public let recentBookmarks: [BookmarkDTO]

public func toDomain() -> CollectionListResponse {
return CollectionListResponse(collectionId: collectionId, name: name, createdAt: createdAt, recentBookmarks: recentBookmarks.toDomain())
public func toDomain() -> CollectionResponse {
return CollectionResponse(collectionId: collectionId, name: name, createdAt: createdAt, recentBookmarks: recentBookmarks.toDomain())
}
}
8 changes: 8 additions & 0 deletions MLS/Data/Data/Network/Endpoints/CollectionEndPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,12 @@ public enum CollectionEndPoint {
public static func createCollectionList(body: Encodable) -> EndPoint {
.init(baseURL: base, path: "/api/v1/collections", method: .POST, body: body)
}

public static func fetchCollection(id: Int) -> ResponsableEndPoint<[BookmarkDTO]> {
.init(
baseURL: base,
path: "/api/v1/collections/\(id)/bookmarks",
method: .GET
)
}
}
14 changes: 9 additions & 5 deletions MLS/Data/Data/Repository/CollectionAPIRepositoryImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,27 @@ public class CollectionAPIRepositoryImpl: CollectionAPIRepository {
self.tokenInterceptor = tokenInterceptor
}

public func fetchCollectionList() -> Observable<[CollectionListResponse]> {
public func fetchCollectionList() -> Observable<[CollectionResponse]> {
let endPoint = CollectionEndPoint.fetchCollectionList()
return provider.requestData(endPoint: endPoint, interceptor: tokenInterceptor).map {
$0.map {$0.toDomain()}
}
return provider.requestData(endPoint: endPoint, interceptor: tokenInterceptor)
.map { $0.map { $0.toDomain() }
}
}

public func createCollectionList(name: String) -> Completable {
let endPoint = CollectionEndPoint.createCollectionList(body: CreateCollectionRequestDTO(name: name))
return provider.requestData(endPoint: endPoint, interceptor: tokenInterceptor)
}

public func fetchCollectionUseCase(id: Int) -> Observable<[BookmarkResponse]> {
let endPoint = CollectionEndPoint.fetchCollection(id: id)
return provider.requestData(endPoint: endPoint, interceptor: tokenInterceptor)
.map { $0.toDomain() }
}
}

private extension CollectionAPIRepositoryImpl {
struct CreateCollectionRequestDTO: Encodable {
let name: String
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public final class FetchCollectionListUseCaseImpl: FetchCollectionListUseCase {
self.repository = repository
}

public func execute() -> Observable<[CollectionListResponse]> {
public func execute() -> Observable<[CollectionResponse]> {
return repository.fetchCollectionList()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import DomainInterface

import RxSwift

public final class FetchCollectionUseCaseImpl: FetchCollectionUseCase {
private let repository: CollectionAPIRepository

public init(repository: CollectionAPIRepository) {
self.repository = repository
}

public func execute(id: Int) -> Observable<[BookmarkResponse]> {
return repository.fetchCollectionUseCase(id: id)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
public struct CollectionListResponse {
public struct CollectionResponse: Equatable {
public let collectionId: Int
public let name: String
public var name: String
public let createdAt: [Int]
public let recentBookmarks: [BookmarkResponse]
public var recentBookmarks: [BookmarkResponse]

public init(collectionId: Int, name: String, createdAt: [Int], recentBookmarks: [BookmarkResponse]) {
self.collectionId = collectionId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import RxSwift

public protocol CollectionAPIRepository {
// 컬렉션 목록 조회
func fetchCollectionList() -> Observable<[CollectionListResponse]>
func fetchCollectionList() -> Observable<[CollectionResponse]>
// 컬렉션 목록 추가
func createCollectionList(name: String) -> Completable
// 컬렉션 상세 조회
func fetchCollectionUseCase(id: Int) -> Observable<[BookmarkResponse]>
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import RxSwift

public protocol FetchCollectionListUseCase {
func execute() -> Observable<[CollectionListResponse]>
func execute() -> Observable<[CollectionResponse]>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import RxSwift

public protocol FetchCollectionUseCase {
func execute(id: Int) -> Observable<[BookmarkResponse]>
}
2 changes: 1 addition & 1 deletion MLS/MLS.xcworkspace/xcshareddata/swiftpm/Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading