-
Notifications
You must be signed in to change notification settings - Fork 0
혼합 광고·채팅 흐름·Tuist 캐시 개선과 전체 모듈 문서화 #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6a5b723
e609c93
7dee2d1
cfade26
17937a7
072111c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| public struct FeedAd: Equatable, Sendable, Identifiable { | ||
| public let code: String | ||
| public let network: String | ||
| public let title: String | ||
| public let subtitle: String | ||
| public let imageURL: String | ||
| public let ctaText: String | ||
| public let clickURL: String | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 [P3] Minor
|
||
| public let label: String | ||
|
|
||
| public var id: String { code } | ||
|
|
||
| public init( | ||
| code: String, | ||
| network: String, | ||
| title: String, | ||
| subtitle: String, | ||
| imageURL: String, | ||
| ctaText: String, | ||
| clickURL: String, | ||
| label: String | ||
| ) { | ||
| self.code = code | ||
| self.network = network | ||
| self.title = title | ||
| self.subtitle = subtitle | ||
| self.imageURL = imageURL | ||
| self.ctaText = ctaText | ||
| self.clickURL = clickURL | ||
| self.label = label | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import ComposableArchitecture | ||
|
|
||
| public protocol FeedAdInterface: Sendable { | ||
| func fetchAds() async throws -> [FeedAd] | ||
| func recordImpressions(codes: [String]) async throws | ||
| } | ||
|
|
||
| public enum FeedAdUseCaseDependency: TestDependencyKey { | ||
| public static var testValue: FeedAdInterface { MockFeedAdClient() } | ||
| } | ||
|
Comment on lines
+8
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Replace this standalone AGENTS.md reference: AGENTS.md:L641-L643 Useful? React with 👍 / 👎. |
||
|
|
||
| public enum FeedAdRepositoryDependency: TestDependencyKey { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [P2] Major
|
||
| public static var testValue: FeedAdInterface { MockFeedAdClient() } | ||
| } | ||
|
|
||
| public extension DependencyValues { | ||
| var feedAdRepository: FeedAdInterface { | ||
| get { self[FeedAdRepositoryDependency.self] } | ||
| set { self[FeedAdRepositoryDependency.self] = newValue } | ||
| } | ||
|
|
||
| var feedAdUseCase: FeedAdInterface { | ||
| get { self[FeedAdUseCaseDependency.self] } | ||
| set { self[FeedAdUseCaseDependency.self] = newValue } | ||
| } | ||
| } | ||
|
|
||
| private struct MockFeedAdClient: FeedAdInterface { | ||
| func fetchAds() async throws -> [FeedAd] { [] } | ||
| func recordImpressions(codes: [String]) async throws {} | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import Foundation | ||
|
|
||
| import DependencyPackagePlugin | ||
| import DependencyPlugin | ||
| import ProjectTemplatePlugin | ||
|
|
||
| import ProjectDescription | ||
|
|
||
| let project = Project.makeModule( | ||
| name: "AdDomain", | ||
| bundleId: .appBundleID(name: ".AdDomain"), | ||
| product: .framework, | ||
| settings: .settings(), | ||
| dependencies: [ | ||
| .serviceAssembly, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [P2] Major
|
||
| ], | ||
| hasTests: true, | ||
| hasInterface: true, | ||
| interfaceDependencies: [ | ||
| .SPM.composableArchitecture, | ||
| ], | ||
| hasTesting: false | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import AdDomainInterface | ||
| import ComposableArchitecture | ||
|
|
||
| extension FeedAdUseCaseDependency: DependencyKey { | ||
| public static var liveValue: FeedAdInterface { FeedAdUseCaseImpl() } | ||
| } | ||
|
|
||
| extension FeedAdRepositoryDependency: DependencyKey { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [P2] Major
|
||
| public static var liveValue: FeedAdInterface { FeedAdRepositoryImpl() } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,25 @@ | ||||||
| import AdDomainInterface | ||||||
|
|
||||||
| struct FeedAdDTO: Decodable, Sendable { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [P2] Major
|
||||||
| let code: String | ||||||
| let network: String | ||||||
| let title: String | ||||||
| let subtitle: String | ||||||
| let imageUrl: String | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 [P4] Readability
Suggested change
|
||||||
| let ctaText: String | ||||||
| let clickUrl: String | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 [P4] Readability
Suggested change
|
||||||
| let label: String | ||||||
|
|
||||||
| func toDomain() -> FeedAd { | ||||||
| FeedAd( | ||||||
| code: code, | ||||||
| network: network, | ||||||
| title: title, | ||||||
| subtitle: subtitle, | ||||||
| imageURL: imageUrl, | ||||||
| ctaText: ctaText, | ||||||
| clickURL: clickUrl, | ||||||
| label: label | ||||||
| ) | ||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import APIEndpoint | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [P2] Major
|
||
| import AdDomainInterface | ||
| import ComposableArchitecture | ||
| import PickeNetwork | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [P2] Major
|
||
|
|
||
| public struct FeedAdRepositoryImpl: FeedAdInterface { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [P2] Major
|
||
| @Dependency(\.networkClient) private var client | ||
|
|
||
| public init() {} | ||
|
|
||
| public func fetchAds() async throws -> [FeedAd] { | ||
| let data = try await client.send( | ||
| AdsService.list(query: AdsQueryRequest()), | ||
| as: [FeedAdDTO].self | ||
| ) | ||
| return data.map { $0.toDomain() } | ||
| } | ||
|
|
||
| public func recordImpressions(codes: [String]) async throws { | ||
| _ = try await client.send( | ||
| AdsService.impressions(body: AdsImpressionsRequest(codes: codes)), | ||
| as: PickeEmptyResponse.self | ||
| ) | ||
|
Comment on lines
+20
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the impressions endpoint returns a normal no-content success or an envelope whose Useful? React with 👍 / 👎. |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import AdDomainInterface | ||
| import ComposableArchitecture | ||
|
|
||
| public struct FeedAdUseCaseImpl: FeedAdInterface { | ||
| @Dependency(\.feedAdRepository) private var feedAdRepository | ||
|
|
||
| public init() {} | ||
|
|
||
| public func fetchAds() async throws -> [FeedAd] { | ||
| return try await feedAdRepository.fetchAds() | ||
| } | ||
|
|
||
| public func recordImpressions(codes: [String]) async throws { | ||
| try await feedAdRepository.recordImpressions(codes: codes) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // | ||
| // AdTests.swift | ||
| // AdTests | ||
| // | ||
|
|
||
| import Foundation | ||
| @testable import PickeNetwork | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [P2] Major
|
||
| @testable import AdDomain | ||
| import AdDomainInterface | ||
| import APIEndpoint | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [P2] Major
|
||
| import Testing | ||
|
|
||
| struct AdDomainTests { | ||
| @Test func 광고_DTO를_도메인으로_매핑한다() { | ||
| let dto = FeedAdDTO( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [P2] Major
|
||
| code: "a1", | ||
| network: "ADPICK", | ||
| title: "상품", | ||
| subtitle: "상점 · 2.8%", | ||
| imageUrl: "https://example.com/image.jpg", | ||
| ctaText: "구매하러 가기", | ||
| clickUrl: "https://ad.picke.store/c/a1", | ||
| label: "광고" | ||
| ) | ||
|
|
||
| #expect(dto.toDomain() == FeedAd( | ||
| code: "a1", | ||
| network: "ADPICK", | ||
| title: "상품", | ||
| subtitle: "상점 · 2.8%", | ||
| imageURL: "https://example.com/image.jpg", | ||
| ctaText: "구매하러 가기", | ||
| clickURL: "https://ad.picke.store/c/a1", | ||
| label: "광고" | ||
| )) | ||
| } | ||
|
|
||
| @Test func 광고_조회_요청을_매핑한다() throws { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [P2] Major API 요청 매핑 테스트는 |
||
| let request = try AdsService.list(query: AdsQueryRequest()).asURLRequest() | ||
| #expect(request.url?.path == "/api/v1/ads") | ||
| #expect(request.httpMethod == "GET") | ||
| #expect(request.url?.query?.contains("slot=HOME_FEED") == true) | ||
| #expect(request.url?.query?.contains("os=IOS") == true) | ||
| #expect(request.url?.query?.contains("size=20") == true) | ||
| } | ||
|
|
||
| @Test func 광고_노출은_codes_JSON을_POST한다() throws { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 [P2] Major API 요청 매핑 테스트는 |
||
| let request = try AdsService.impressions( | ||
| body: AdsImpressionsRequest(codes: ["first", "second"]) | ||
| ).asURLRequest() | ||
| #expect(request.url?.path == "/api/v1/ads/impressions") | ||
| #expect(request.httpMethod == "POST") | ||
| let data = try #require(request.httpBody) | ||
| let body = try JSONDecoder().decode([String: [String]].self, from: data) | ||
| #expect(body == ["codes": ["first", "second"]]) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 [P3] Minor
imageURL과clickURL속성은String대신URL타입으로 선언하는 것이 더 안전하고, 타입 안정성을 높이며,URL객체에서 제공하는 유용한 기능을 활용할 수 있습니다.