-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/iOS/GWL-442
- Loading branch information
Showing
23 changed files
with
642 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
iOS/Projects/Features/Home/Sources/Data/FeedRepository.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// FeedRepository.swift | ||
// HomeFeature | ||
// | ||
// Created by MaraMincho on 12/7/23. | ||
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import Combine | ||
import CommonNetworkingKeyManager | ||
import Foundation | ||
import Trinet | ||
|
||
// MARK: - FeedRepository | ||
|
||
public struct FeedRepository: FeedRepositoryRepresentable { | ||
let decoder = JSONDecoder() | ||
let provider: TNProvider<FeedEndPoint> | ||
init(session: URLSessionProtocol = URLSession.shared) { | ||
provider = .init(session: session) | ||
} | ||
|
||
public func fetchFeed(at page: Int) -> AnyPublisher<[FeedElement], Never> { | ||
return Future<[FeedElement], Error> { promise in | ||
Task { [provider] in | ||
do { | ||
let data = try await provider.request(.fetchPosts(page: page), interceptor: TNKeychainInterceptor.shared) | ||
let feedElementList = try decoder.decode([FeedElement].self, from: data) | ||
promise(.success(feedElementList)) | ||
} catch { | ||
promise(.failure(error)) | ||
} | ||
} | ||
} | ||
.catch { _ in return Empty() } | ||
.eraseToAnyPublisher() | ||
} | ||
} | ||
|
||
// MARK: - FeedEndPoint | ||
|
||
public enum FeedEndPoint: TNEndPoint { | ||
case fetchPosts(page: Int) | ||
public var path: String { | ||
return "" | ||
} | ||
|
||
public var method: TNMethod { | ||
return .post | ||
} | ||
|
||
public var query: Encodable? { | ||
return nil | ||
} | ||
|
||
public var body: Encodable? { | ||
switch self { | ||
case let .fetchPosts(page): | ||
return page | ||
} | ||
} | ||
|
||
public var headers: TNHeaders { | ||
return .default | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...ojects/Features/Home/Sources/Domain/RepositoryInterface/FeedRepositoryRepresentable.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// FeedRepositoryRepresentable.swift | ||
// HomeFeature | ||
// | ||
// Created by MaraMincho on 1/2/24. | ||
// Copyright © 2024 kr.codesquad.boostcamp8. All rights reserved. | ||
// | ||
|
||
import Combine | ||
import Foundation | ||
|
||
// MARK: - FeedRepositoryRepresentable | ||
|
||
public protocol FeedRepositoryRepresentable { | ||
func fetchFeed(at page: Int) -> AnyPublisher<[FeedElement], Never> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.