From 425b4cf5d1f8795df677ad48538a9a9a143794e7 Mon Sep 17 00:00:00 2001 From: SeungHyun Hong Date: Tue, 7 May 2024 17:04:13 +0900 Subject: [PATCH] =?UTF-8?q?:twisted=5Frightwards=5Farrows:=20=EC=84=9C?= =?UTF-8?q?=EB=B2=84=20=EB=AA=85=EC=84=B8=EC=84=9C=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EA=B2=8C=20EndPoint,=20DTO,=20Entity=20=EC=9E=AC=EC=88=98?= =?UTF-8?q?=EC=A0=95=20(#146)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :art: Refactor Entity and DTO to align with server credits API specification * :art: Refactor Entity and DTO to align with server notices API specification * :art: Refactor Entity and DTO to align with server products list API specification * :art: Refactor Entity and DTO to align with server products price history API specification * :art: Refactor Entity and DTO to align with server products search API specification * :white_check_mark: Update code to pass the unit test --- .../Sources/CreditsAPI/CreditsService.swift | 4 +-- .../Responses/CreditsResponse.swift | 5 ++-- APIService/Sources/HomeAPI/HomeEndPoint.swift | 5 ---- APIService/Sources/HomeAPI/HomeService.swift | 6 ---- .../Requests/ProductCountRequest.swift | 30 ------------------- .../HomeAPI/Requests/ProductRequest.swift | 16 ++++------ .../Responses/ProductCountResponse.swift | 12 -------- .../HomeAPI/Responses/ProductResponse.swift | 12 ++------ .../HomeAPISupport/HomeURLProtocol.swift | 5 +--- .../Mocks/HomeProductCountResponse.json | 3 -- .../NoticeAPI/NoticeDetailService.swift | 2 +- .../Sources/NoticeAPI/NoticeEndPoint.swift | 4 +-- .../Sources/NoticeAPI/NoticeService.swift | 4 +-- .../Requests/NoticeListRequest.swift | 11 ++----- .../NoticeAPI/Responses/NoticeResponse.swift | 10 ++----- .../NoticeAPISupport/NoticeURLProtocol.swift | 2 +- .../ProductInfoAPI/ProductInfoService.swift | 16 ++++------ .../ProductDetailPricesResponse.swift | 13 -------- .../Responses/ProductDetailResponse.swift | 26 ++++++++-------- .../Requests/SearchProductRequest.swift | 16 +++++----- .../Responses/SearchProductResponse.swift | 18 ++++------- .../Sources/SearchAPI/SearchEndPoint.swift | 2 +- .../Mocks/SearchProductResponse.json | 10 ------- .../NetworkAPIKit/NetworkProvider.swift | 9 ++++-- .../Entity/Common/ConvenienceStore.swift | 5 ++-- Entity/Sources/Entity/Common/Order.swift | 6 ++-- Entity/Sources/Entity/Common/Promotion.swift | 6 ++-- Entity/Sources/Entity/Credits/Credits.swift | 4 +-- .../xcschemes/PyeonHaeng-iOS.xcscheme | 2 +- .../Resources/Localizable.xcstrings | 22 ++------------ .../ConvenienceSelectBottomSheetView.swift | 4 --- .../View/HomeProductDetailSelectionView.swift | 15 ++++++++-- .../Scenes/HomeScene/View/HomeView.swift | 1 - .../HomeScene/ViewModel/HomeViewModel.swift | 22 ++------------ .../ViewModel/ProductConfiguration.swift | 4 +-- .../OnboardingScene/OnboardingPage.swift | 2 +- .../ProductInfoDetailView.swift | 1 - .../ProductSearchScene/SearchView.swift | 2 -- .../ViewModel/NoticeConfiguration.swift | 2 +- .../Notice/ViewModel/NoticeViewModel.swift | 3 +- .../ProductConfigurationTests.swift | 2 +- .../Ministop.imageset/Contents.json | 15 ---------- .../BrandImage/Ministop.imageset/Ministop.svg | 18 ----------- .../Sources/Extensions/Image+Resource.swift | 1 - 44 files changed, 100 insertions(+), 278 deletions(-) delete mode 100644 APIService/Sources/HomeAPI/Requests/ProductCountRequest.swift delete mode 100644 APIService/Sources/HomeAPI/Responses/ProductCountResponse.swift delete mode 100644 APIService/Sources/HomeAPISupport/Mocks/HomeProductCountResponse.json delete mode 100644 APIService/Sources/ProductInfoAPI/Responses/ProductDetailPricesResponse.swift delete mode 100644 Shared/Sources/DesignSystem/Resources/Images.xcassets/BrandImage/Ministop.imageset/Contents.json delete mode 100644 Shared/Sources/DesignSystem/Resources/Images.xcassets/BrandImage/Ministop.imageset/Ministop.svg diff --git a/APIService/Sources/CreditsAPI/CreditsService.swift b/APIService/Sources/CreditsAPI/CreditsService.swift index 8436ec0..3362655 100644 --- a/APIService/Sources/CreditsAPI/CreditsService.swift +++ b/APIService/Sources/CreditsAPI/CreditsService.swift @@ -38,8 +38,8 @@ private extension Credits { init(dto: CreditsResponse) { self.init( title: dto.title, - body: dto.body, - date: dto.date + content: dto.content, + date: dto.createdAt ) } } diff --git a/APIService/Sources/CreditsAPI/Responses/CreditsResponse.swift b/APIService/Sources/CreditsAPI/Responses/CreditsResponse.swift index 941e67b..9c6ce2d 100644 --- a/APIService/Sources/CreditsAPI/Responses/CreditsResponse.swift +++ b/APIService/Sources/CreditsAPI/Responses/CreditsResponse.swift @@ -11,7 +11,8 @@ import Foundation // MARK: - ProductResponse struct CreditsResponse: Decodable { + let id: Int let title: String - let body: String - let date: Date + let content: String + let createdAt: Date } diff --git a/APIService/Sources/HomeAPI/HomeEndPoint.swift b/APIService/Sources/HomeAPI/HomeEndPoint.swift index 0d05b59..cdb82e8 100644 --- a/APIService/Sources/HomeAPI/HomeEndPoint.swift +++ b/APIService/Sources/HomeAPI/HomeEndPoint.swift @@ -12,7 +12,6 @@ import NetworkAPIKit public enum HomeEndPoint { case fetchProducts(ProductRequest) - case fetchCount(ProductCountRequest) } // MARK: EndPoint @@ -26,8 +25,6 @@ extension HomeEndPoint: EndPoint { switch self { case .fetchProducts: "/v2/products" - case .fetchCount: - "/v2/products/count" } } @@ -35,8 +32,6 @@ extension HomeEndPoint: EndPoint { switch self { case let .fetchProducts(requestModel): .query(requestModel) - case let .fetchCount(requestModel): - .query(requestModel) } } diff --git a/APIService/Sources/HomeAPI/HomeService.swift b/APIService/Sources/HomeAPI/HomeService.swift index 43ac0b5..39c260e 100644 --- a/APIService/Sources/HomeAPI/HomeService.swift +++ b/APIService/Sources/HomeAPI/HomeService.swift @@ -13,7 +13,6 @@ import NetworkAPIKit public protocol HomeServiceRepresentable { func fetchProductList(request: ProductRequest) async throws -> Paginated - func fetchProductCount(request: ProductCountRequest) async throws -> Int } // MARK: - HomeService @@ -33,11 +32,6 @@ extension HomeService: HomeServiceRepresentable { let response: ProductResponse = try await network.request(with: HomeEndPoint.fetchProducts(request)) return Paginated(dto: response) } - - public func fetchProductCount(request: ProductCountRequest) async throws -> Int { - let countResponse: ProductCountResponse = try await network.request(with: HomeEndPoint.fetchCount(request)) - return countResponse.count - } } private extension Paginated where Model == Product { diff --git a/APIService/Sources/HomeAPI/Requests/ProductCountRequest.swift b/APIService/Sources/HomeAPI/Requests/ProductCountRequest.swift deleted file mode 100644 index 89a3651..0000000 --- a/APIService/Sources/HomeAPI/Requests/ProductCountRequest.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// ProductCountRequest.swift -// -// -// Created by 홍승현 on 2/2/24. -// - -import Entity -import Foundation - -// MARK: - ProductCountRequest - -public struct ProductCountRequest: Encodable { - public let convenienceStore: ConvenienceStore - public let promotion: Promotion - - public init(convenienceStore: ConvenienceStore, promotion: Promotion) { - self.convenienceStore = convenienceStore - self.promotion = promotion - } -} - -// MARK: ProductCountRequest.CodingKeys - -extension ProductCountRequest { - enum CodingKeys: String, CodingKey { - case convenienceStore = "store" - case promotion - } -} diff --git a/APIService/Sources/HomeAPI/Requests/ProductRequest.swift b/APIService/Sources/HomeAPI/Requests/ProductRequest.swift index eb8ebdf..13f36c2 100644 --- a/APIService/Sources/HomeAPI/Requests/ProductRequest.swift +++ b/APIService/Sources/HomeAPI/Requests/ProductRequest.swift @@ -12,22 +12,16 @@ public struct ProductRequest: Encodable { public let store: ConvenienceStore public let promotion: Promotion public let order: Order - public let pageSize: Int + public let limit: Int public let offset: Int + public let date: Date - enum CodingKeys: String, CodingKey { - case store - case promotion - case order - case pageSize = "page_size" - case offset - } - - public init(store: ConvenienceStore, promotion: Promotion, order: Order, pageSize: Int, offset: Int) { + public init(store: ConvenienceStore, promotion: Promotion, order: Order, limit: Int, offset: Int, date: Date = .now) { self.store = store self.promotion = promotion self.order = order - self.pageSize = pageSize + self.limit = limit self.offset = offset + self.date = date } } diff --git a/APIService/Sources/HomeAPI/Responses/ProductCountResponse.swift b/APIService/Sources/HomeAPI/Responses/ProductCountResponse.swift deleted file mode 100644 index 07bdf66..0000000 --- a/APIService/Sources/HomeAPI/Responses/ProductCountResponse.swift +++ /dev/null @@ -1,12 +0,0 @@ -// -// ProductCountResponse.swift -// -// -// Created by 홍승현 on 2/2/24. -// - -import Foundation - -struct ProductCountResponse: Decodable { - let count: Int -} diff --git a/APIService/Sources/HomeAPI/Responses/ProductResponse.swift b/APIService/Sources/HomeAPI/Responses/ProductResponse.swift index 06e790c..e5f9f2c 100644 --- a/APIService/Sources/HomeAPI/Responses/ProductResponse.swift +++ b/APIService/Sources/HomeAPI/Responses/ProductResponse.swift @@ -15,12 +15,6 @@ struct ProductResponse: Decodable, Paginatable { let hasMore: Bool let results: [ProductItemResponse] - - enum CodingKeys: String, CodingKey { - case count - case hasMore = "has_more" - case results - } } // MARK: - ProductItemResponse @@ -36,11 +30,11 @@ struct ProductItemResponse: Decodable { enum CodingKeys: String, CodingKey { case id - case imageURL = "img" + case imageURL = "imageUrl" case price - case date + case date = "eventDate" case name - case promotion = "tag" + case promotion case convenienceStore = "store" } } diff --git a/APIService/Sources/HomeAPISupport/HomeURLProtocol.swift b/APIService/Sources/HomeAPISupport/HomeURLProtocol.swift index dc45c5f..b76bd57 100644 --- a/APIService/Sources/HomeAPISupport/HomeURLProtocol.swift +++ b/APIService/Sources/HomeAPISupport/HomeURLProtocol.swift @@ -12,11 +12,8 @@ import NetworkAPIKit public final class HomeURLProtocol: URLProtocol { private lazy var mockData: [String: Data?] = [ HomeEndPoint.fetchProducts( - .init(store: .gs25, promotion: .allItems, order: .normal, pageSize: 0, offset: 0) + .init(store: .gs25, promotion: .allItems, order: .normal, limit: 0, offset: 0) ).path: loadMockData(fileName: "HomeProductResponse"), - HomeEndPoint.fetchCount( - .init(convenienceStore: .gs25, promotion: .allItems) - ).path: loadMockData(fileName: "HomeProductCountResponse"), ] override public class func canInit(with _: URLRequest) -> Bool { diff --git a/APIService/Sources/HomeAPISupport/Mocks/HomeProductCountResponse.json b/APIService/Sources/HomeAPISupport/Mocks/HomeProductCountResponse.json deleted file mode 100644 index 93406bd..0000000 --- a/APIService/Sources/HomeAPISupport/Mocks/HomeProductCountResponse.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "count": 24 -} diff --git a/APIService/Sources/NoticeAPI/NoticeDetailService.swift b/APIService/Sources/NoticeAPI/NoticeDetailService.swift index 98d9596..a55fff7 100644 --- a/APIService/Sources/NoticeAPI/NoticeDetailService.swift +++ b/APIService/Sources/NoticeAPI/NoticeDetailService.swift @@ -40,7 +40,7 @@ private extension NoticeDetail { init(dto: NoticeItemResponse) { self.init( title: dto.title, - context: dto.body + context: dto.content ) } } diff --git a/APIService/Sources/NoticeAPI/NoticeEndPoint.swift b/APIService/Sources/NoticeAPI/NoticeEndPoint.swift index 0d2e2d1..e66d793 100644 --- a/APIService/Sources/NoticeAPI/NoticeEndPoint.swift +++ b/APIService/Sources/NoticeAPI/NoticeEndPoint.swift @@ -25,9 +25,9 @@ extension NoticeEndPoint: EndPoint { public var path: String { switch self { case .fetchList: - "/v2/notice" + "/v2/notices" case let .fetchDetail(id): - "/v2/notice/\(id)" + "/v2/notices/\(id)" } } diff --git a/APIService/Sources/NoticeAPI/NoticeService.swift b/APIService/Sources/NoticeAPI/NoticeService.swift index dba5d92..8344f24 100644 --- a/APIService/Sources/NoticeAPI/NoticeService.swift +++ b/APIService/Sources/NoticeAPI/NoticeService.swift @@ -54,7 +54,7 @@ private extension Notice { init(dto: NoticeItemResponse) { self.init( id: dto.id, - date: dto.date, + date: dto.createdAt, title: dto.title ) } @@ -64,7 +64,7 @@ private extension NoticeDetail { init(dto: NoticeItemResponse) { self.init( title: dto.title, - context: dto.body + context: dto.content ) } } diff --git a/APIService/Sources/NoticeAPI/Requests/NoticeListRequest.swift b/APIService/Sources/NoticeAPI/Requests/NoticeListRequest.swift index 9cde3e7..9b049a5 100644 --- a/APIService/Sources/NoticeAPI/Requests/NoticeListRequest.swift +++ b/APIService/Sources/NoticeAPI/Requests/NoticeListRequest.swift @@ -8,16 +8,11 @@ import Foundation public struct NoticeListRequest: Encodable { - let pageSize: Int + let limit: Int let offset: Int - public init(pageSize: Int, offset: Int) { - self.pageSize = pageSize + public init(limit: Int, offset: Int) { + self.limit = limit self.offset = offset } - - enum CodingKeys: String, CodingKey { - case pageSize = "page_size" - case offset - } } diff --git a/APIService/Sources/NoticeAPI/Responses/NoticeResponse.swift b/APIService/Sources/NoticeAPI/Responses/NoticeResponse.swift index 21d00ac..5da21c6 100644 --- a/APIService/Sources/NoticeAPI/Responses/NoticeResponse.swift +++ b/APIService/Sources/NoticeAPI/Responses/NoticeResponse.swift @@ -15,12 +15,6 @@ struct NoticeResponse: Decodable, Paginatable { let hasMore: Bool let results: [NoticeItemResponse] - - enum CodingKeys: String, CodingKey { - case count - case hasMore = "has_more" - case results - } } // MARK: - NoticeItemResponse @@ -28,6 +22,6 @@ struct NoticeResponse: Decodable, Paginatable { struct NoticeItemResponse: Decodable { let id: Int let title: String - let body: String? - let date: Date + let content: String + let createdAt: Date } diff --git a/APIService/Sources/NoticeAPISupport/NoticeURLProtocol.swift b/APIService/Sources/NoticeAPISupport/NoticeURLProtocol.swift index 38fd251..7917a3b 100644 --- a/APIService/Sources/NoticeAPISupport/NoticeURLProtocol.swift +++ b/APIService/Sources/NoticeAPISupport/NoticeURLProtocol.swift @@ -11,7 +11,7 @@ import NoticeAPI public final class NoticeURLProtocol: URLProtocol { private lazy var mockData: [String: Data?] = [ - NoticeEndPoint.fetchList(.init(pageSize: 0, offset: 0)).path: loadMockData(fileName: "NoticeListResponse"), + NoticeEndPoint.fetchList(.init(limit: 0, offset: 0)).path: loadMockData(fileName: "NoticeListResponse"), NoticeEndPoint.fetchDetail(2).path: loadMockData(fileName: "NoticeDetailResponse"), ] diff --git a/APIService/Sources/ProductInfoAPI/ProductInfoService.swift b/APIService/Sources/ProductInfoAPI/ProductInfoService.swift index 3140cf7..fe88f3b 100644 --- a/APIService/Sources/ProductInfoAPI/ProductInfoService.swift +++ b/APIService/Sources/ProductInfoAPI/ProductInfoService.swift @@ -32,29 +32,25 @@ extension ProductInfoService: ProductInfoServiceRepresentable { let response: ProductDetailResponse = try await network.request( with: ProductInfoEndPoint.fetchProduct(productID) ) - if let item = response.results.first { - return DetailProduct(dto: item) - } else { - return DetailProduct(id: 0, imageURL: nil, price: 0, name: "", promotion: .allItems, convenienceStore: ._7Eleven, date: .distantPast) - } + return DetailProduct(dto: response) } public func fetchProductPrice(productID: Int) async throws -> [DetailProduct] { - let response: ProductDetailPricesResponse = try await network.request( + let response: [ProductDetailResponse] = try await network.request( with: ProductInfoEndPoint.fetchPrices(productID) ) - return response.results.map(DetailProduct.init(dto:)) + return response.map(DetailProduct.init(dto:)) } } private extension DetailProduct { - init(dto: ProductDetailItemResponse) { + init(dto: ProductDetailResponse) { self.init( id: dto.id, - imageURL: dto.img, + imageURL: dto.imageURL, price: dto.price, name: dto.name, - promotion: dto.tag, + promotion: dto.promotion, convenienceStore: dto.store, date: dto.date ) diff --git a/APIService/Sources/ProductInfoAPI/Responses/ProductDetailPricesResponse.swift b/APIService/Sources/ProductInfoAPI/Responses/ProductDetailPricesResponse.swift deleted file mode 100644 index 60fdd18..0000000 --- a/APIService/Sources/ProductInfoAPI/Responses/ProductDetailPricesResponse.swift +++ /dev/null @@ -1,13 +0,0 @@ -// -// ProductDetailPricesResponse.swift -// -// -// Created by 김응철 on 3/14/24. -// - -import Foundation - -struct ProductDetailPricesResponse: Decodable { - let count: Int - let results: [ProductDetailItemResponse] -} diff --git a/APIService/Sources/ProductInfoAPI/Responses/ProductDetailResponse.swift b/APIService/Sources/ProductInfoAPI/Responses/ProductDetailResponse.swift index 28b9252..ce0074d 100644 --- a/APIService/Sources/ProductInfoAPI/Responses/ProductDetailResponse.swift +++ b/APIService/Sources/ProductInfoAPI/Responses/ProductDetailResponse.swift @@ -8,22 +8,22 @@ import Entity import Foundation -// MARK: - ProductDetailResponse - struct ProductDetailResponse: Decodable { - let count: Int - let results: [ProductDetailItemResponse] -} - -// MARK: - ProductDetailItemResponse - -struct ProductDetailItemResponse: Decodable { + let id: Int let name: String - let img: URL? let price: Int + let promotion: Promotion let store: ConvenienceStore - let tag: Promotion - let proinfo: Int let date: Date - let id: Int + let imageURL: URL? + + enum CodingKeys: String, CodingKey { + case id + case name + case price + case promotion + case store + case date = "eventDate" + case imageURL = "imageUrl" + } } diff --git a/APIService/Sources/SearchAPI/Requests/SearchProductRequest.swift b/APIService/Sources/SearchAPI/Requests/SearchProductRequest.swift index 4f78e9f..8c95aa2 100644 --- a/APIService/Sources/SearchAPI/Requests/SearchProductRequest.swift +++ b/APIService/Sources/SearchAPI/Requests/SearchProductRequest.swift @@ -10,21 +10,21 @@ import Foundation public struct SearchProductRequest: Encodable { public let name: String - public let order: Order - public let pageSize: Int + public let limit: Int public let offset: Int + public let date: Date enum CodingKeys: String, CodingKey { case name = "product_name" - case order - case pageSize = "page_size" + case limit case offset + case date } - public init(name: String) { + public init(name: String, limit: Int = 5000, offset: Int = 1, date: Date = .now) { self.name = name - order = .normal - pageSize = 5000 - offset = 0 + self.limit = limit + self.offset = offset + self.date = date } } diff --git a/APIService/Sources/SearchAPI/Responses/SearchProductResponse.swift b/APIService/Sources/SearchAPI/Responses/SearchProductResponse.swift index 2e207c2..2623c89 100644 --- a/APIService/Sources/SearchAPI/Responses/SearchProductResponse.swift +++ b/APIService/Sources/SearchAPI/Responses/SearchProductResponse.swift @@ -15,32 +15,26 @@ struct SearchProductResponse: Decodable, Paginatable { let hasMore: Bool let results: [SearchProductItemResponse] - - enum CodingKeys: String, CodingKey { - case count - case hasMore = "has_more" - case results - } } // MARK: - SearchProductItemResponse struct SearchProductItemResponse: Decodable { let id: Int - let imageURL: URL? - let date: Date - let price: Int let name: String + let price: Int let promotion: Promotion let convenienceStore: ConvenienceStore + let date: Date + let imageURL: URL? enum CodingKeys: String, CodingKey { case id - case imageURL = "img" + case imageURL = "imageUrl" case price - case date + case date = "eventDate" case name - case promotion = "tag" + case promotion case convenienceStore = "store" } } diff --git a/APIService/Sources/SearchAPI/SearchEndPoint.swift b/APIService/Sources/SearchAPI/SearchEndPoint.swift index eea02d2..31f4aff 100644 --- a/APIService/Sources/SearchAPI/SearchEndPoint.swift +++ b/APIService/Sources/SearchAPI/SearchEndPoint.swift @@ -24,7 +24,7 @@ extension SearchEndPoint: EndPoint { public var path: String { switch self { case .fetchProducts: - "/v2/search" + "/v2/products/search" } } diff --git a/APIService/Sources/SearchAPISupport/Mocks/SearchProductResponse.json b/APIService/Sources/SearchAPISupport/Mocks/SearchProductResponse.json index 93cc6c7..af5e70d 100644 --- a/APIService/Sources/SearchAPISupport/Mocks/SearchProductResponse.json +++ b/APIService/Sources/SearchAPISupport/Mocks/SearchProductResponse.json @@ -32,16 +32,6 @@ "date": "2024-02-01T00:00:00Z", "id": 81629 }, - { - "name": "칠성)펩시콜라제로355ml", - "img": "https://www.ministop.co.kr/MiniStopHomePage/page/pic.do?n=event1plus1.[YOUXY1LS_]1plus1_160.jpg", - "price": 1900, - "store": "MINISTOP", - "tag": "1+1", - "proinfo": 0, - "date": "2024-02-01T00:00:00Z", - "id": 85911 - }, { "name": "CJ)워터젤리복숭아130G", "img": "https://image.woodongs.com/imgsvr/item/GD_8801007038032_035.jpg", diff --git a/Core/Sources/NetworkAPIKit/NetworkProvider.swift b/Core/Sources/NetworkAPIKit/NetworkProvider.swift index 979a094..16c8250 100644 --- a/Core/Sources/NetworkAPIKit/NetworkProvider.swift +++ b/Core/Sources/NetworkAPIKit/NetworkProvider.swift @@ -43,7 +43,9 @@ public struct NetworkProvider: Networking { case .plain: break case let .body(data): - request.httpBody = try JSONEncoder().encode(data) + let encoder = JSONEncoder() + encoder.dateEncodingStrategy = .iso8601 + request.httpBody = try encoder.encode(data) case let .query(data): var components = URLComponents(string: url.absoluteString) components?.queryItems = data.toDictionary.map { URLQueryItem(name: $0, value: "\($1)") } @@ -76,6 +78,7 @@ public struct NetworkProvider: Networking { guard 200 ..< 300 ~= response.statusCode else { logger?.error("⚠️⚠️===Response Status Code Error: \(response.statusCode)==⚠️⚠️\n") + logger?.error("⬇️⬇️===Received Data===⬇️⬇️\n\(data.prettyJSONData ?? "None")\n⬆️⬆️===============⬆️⬆️\n") throw NetworkError.failedResponse(statusCode: response.statusCode) } @@ -114,7 +117,9 @@ private extension Data { private extension Encodable { var toDictionary: [String: Any] { - guard let data = try? JSONEncoder().encode(self), + let encoder = JSONEncoder() + encoder.dateEncodingStrategy = .iso8601 + guard let data = try? encoder.encode(self), let jsonData = try? JSONSerialization.jsonObject(with: data), let dictionaryData = jsonData as? [String: Any] else { diff --git a/Entity/Sources/Entity/Common/ConvenienceStore.swift b/Entity/Sources/Entity/Common/ConvenienceStore.swift index 85f3767..e82888d 100644 --- a/Entity/Sources/Entity/Common/ConvenienceStore.swift +++ b/Entity/Sources/Entity/Common/ConvenienceStore.swift @@ -11,7 +11,6 @@ import SwiftUI public enum ConvenienceStore: String, Codable, CaseIterable { case cu = "CU" case gs25 = "GS25" - case _7Eleven = "7-ELEVEn" - case emart24 - case ministop = "MINISTOP" + case _7Eleven = "SEVEN_ELEVEN" + case emart24 = "EMART24" } diff --git a/Entity/Sources/Entity/Common/Order.swift b/Entity/Sources/Entity/Common/Order.swift index 78815a6..3aceace 100644 --- a/Entity/Sources/Entity/Common/Order.swift +++ b/Entity/Sources/Entity/Common/Order.swift @@ -8,7 +8,7 @@ import Foundation public enum Order: String, Codable { - case normal - case ascending = "asc" - case descending = "desc" + case normal = "NORMAL" + case ascending = "ASC" + case descending = "DESC" } diff --git a/Entity/Sources/Entity/Common/Promotion.swift b/Entity/Sources/Entity/Common/Promotion.swift index 23dba63..fd9aac5 100644 --- a/Entity/Sources/Entity/Common/Promotion.swift +++ b/Entity/Sources/Entity/Common/Promotion.swift @@ -9,7 +9,7 @@ import Foundation /// 행사 종류 public enum Promotion: String, Codable, CaseIterable { - case buyOneGetOneFree = "1+1" - case buyTwoGetOneFree = "2+1" - case allItems = "All" + case buyOneGetOneFree = "BUY_ONE_GET_ONE_FREE" + case buyTwoGetOneFree = "BUY_TWO_GET_ONE_FREE" + case allItems = "ALL" } diff --git a/Entity/Sources/Entity/Credits/Credits.swift b/Entity/Sources/Entity/Credits/Credits.swift index 5ecc4c8..28e7529 100644 --- a/Entity/Sources/Entity/Credits/Credits.swift +++ b/Entity/Sources/Entity/Credits/Credits.swift @@ -18,9 +18,9 @@ public struct Credits { /// 크레딧 생성 날짜 public let date: Date - public init(title: String, body: String, date: Date) { + public init(title: String, content: String, date: Date) { self.title = title - self.body = body + body = content self.date = date } } diff --git a/PyeonHaeng-iOS.xcodeproj/xcshareddata/xcschemes/PyeonHaeng-iOS.xcscheme b/PyeonHaeng-iOS.xcodeproj/xcshareddata/xcschemes/PyeonHaeng-iOS.xcscheme index ce61faf..d73670d 100644 --- a/PyeonHaeng-iOS.xcodeproj/xcshareddata/xcschemes/PyeonHaeng-iOS.xcscheme +++ b/PyeonHaeng-iOS.xcodeproj/xcshareddata/xcschemes/PyeonHaeng-iOS.xcscheme @@ -43,7 +43,7 @@ : View where ViewModel: HomeView promotionModalPresented = true } label: { HStack(spacing: Metrics.buttonSpacing) { - Text(verbatim: viewModel.state.productConfiguration.promotion.rawValue) + Text(verbatim: viewModel.state.productConfiguration.promotion.displayName) .font(.title2) Image.arrowTriangleDownFill .renderingMode(.template) @@ -91,8 +92,16 @@ struct HomeProductDetailSelectionView: View where ViewModel: HomeView ._7Eleven case .emart24: .emart24 - case .ministop: - .ministop + } + } +} + +private extension Promotion { + var displayName: String { + switch self { + case .allItems: "All" + case .buyOneGetOneFree: "1+1" + case .buyTwoGetOneFree: "2+1" } } } diff --git a/PyeonHaeng-iOS/Sources/Scenes/HomeScene/View/HomeView.swift b/PyeonHaeng-iOS/Sources/Scenes/HomeScene/View/HomeView.swift index 6cec671..f8f6d7d 100644 --- a/PyeonHaeng-iOS/Sources/Scenes/HomeScene/View/HomeView.swift +++ b/PyeonHaeng-iOS/Sources/Scenes/HomeScene/View/HomeView.swift @@ -88,7 +88,6 @@ struct HomeView: View where ViewModel: HomeViewModelRepresentable { isFirstLaunch = true } viewModel.trigger(.fetchProducts) - viewModel.trigger(.fetchCount) } } } diff --git a/PyeonHaeng-iOS/Sources/Scenes/HomeScene/ViewModel/HomeViewModel.swift b/PyeonHaeng-iOS/Sources/Scenes/HomeScene/ViewModel/HomeViewModel.swift index 6528839..2faeb5c 100644 --- a/PyeonHaeng-iOS/Sources/Scenes/HomeScene/ViewModel/HomeViewModel.swift +++ b/PyeonHaeng-iOS/Sources/Scenes/HomeScene/ViewModel/HomeViewModel.swift @@ -16,7 +16,6 @@ import Log enum HomeAction { case fetchProducts case loadMoreProducts - case fetchCount case changeOrder case changeConvenienceStore(ConvenienceStore) case changePromotion(Promotion) @@ -90,25 +89,17 @@ final class HomeViewModel: HomeViewModelRepresentable { try await fetchProducts(replace: false) } - case .fetchCount: - await performAsyncAction { - try await fetchProductCounts() - } - case .changeOrder: state.productConfiguration.toggleOrder() trigger(.fetchProducts) - trigger(.fetchCount) case let .changeConvenienceStore(store): state.productConfiguration.change(convenienceStore: store) trigger(.fetchProducts) - trigger(.fetchCount) case let .changePromotion(promotion): state.productConfiguration.change(promotion: promotion) trigger(.fetchProducts) - trigger(.fetchCount) } } @@ -122,7 +113,7 @@ final class HomeViewModel: HomeViewModelRepresentable { store: state.productConfiguration.store, promotion: state.productConfiguration.promotion, order: state.productConfiguration.order, - pageSize: state.productConfiguration.pageSize, + limit: state.productConfiguration.pageSize, offset: state.productConfiguration.offset ) @@ -134,6 +125,7 @@ final class HomeViewModel: HomeViewModelRepresentable { state.productConfiguration.update(meta: paginatedModel) } + state.totalCount = paginatedModel.count if replace { state.products = paginatedModel.results } else { @@ -144,14 +136,4 @@ final class HomeViewModel: HomeViewModelRepresentable { throw error } } - - private func fetchProductCounts() async throws { - let total = try await service.fetchProductCount( - request: .init( - convenienceStore: state.productConfiguration.store, - promotion: state.productConfiguration.promotion - ) - ) - state.totalCount = total - } } diff --git a/PyeonHaeng-iOS/Sources/Scenes/HomeScene/ViewModel/ProductConfiguration.swift b/PyeonHaeng-iOS/Sources/Scenes/HomeScene/ViewModel/ProductConfiguration.swift index 772b678..e5bb536 100644 --- a/PyeonHaeng-iOS/Sources/Scenes/HomeScene/ViewModel/ProductConfiguration.swift +++ b/PyeonHaeng-iOS/Sources/Scenes/HomeScene/ViewModel/ProductConfiguration.swift @@ -15,7 +15,7 @@ struct ProductConfiguration { private(set) var promotion: Promotion = .allItems private(set) var order: Order = .normal let pageSize: Int = 20 - private(set) var offset: Int = 0 + private(set) var offset: Int = 1 private(set) var loadingState: PagingState = .idle } @@ -47,7 +47,7 @@ extension ProductConfiguration { /// 페이징 관련 옵션들을 재설정합니다. mutating func resetPagingOptions() { - offset = 0 + offset = 1 loadingState = .idle } diff --git a/PyeonHaeng-iOS/Sources/Scenes/OnboardingScene/OnboardingPage.swift b/PyeonHaeng-iOS/Sources/Scenes/OnboardingScene/OnboardingPage.swift index a29c783..c11705b 100644 --- a/PyeonHaeng-iOS/Sources/Scenes/OnboardingScene/OnboardingPage.swift +++ b/PyeonHaeng-iOS/Sources/Scenes/OnboardingScene/OnboardingPage.swift @@ -25,7 +25,7 @@ struct OnboardingPage: Identifiable { OnboardingPage( title: "Numerous benefits in one place", body: """ - Find the myriad of promotional information from 7-Eleven, CU, emart24, GS25, MiniStop all in one place with ’`Pyeonhaeng`’. + Find the myriad of promotional information from 7-Eleven, CU, emart24, GS25 all in one place with ’`Pyeonhaeng`’. """, image: .onboarding2, tag: 1 diff --git a/PyeonHaeng-iOS/Sources/Scenes/ProductInfoScene/ProductInfoDetailView.swift b/PyeonHaeng-iOS/Sources/Scenes/ProductInfoScene/ProductInfoDetailView.swift index 092dcf3..d9a7ce3 100644 --- a/PyeonHaeng-iOS/Sources/Scenes/ProductInfoScene/ProductInfoDetailView.swift +++ b/PyeonHaeng-iOS/Sources/Scenes/ProductInfoScene/ProductInfoDetailView.swift @@ -100,7 +100,6 @@ private struct DetailView: View { case .gs25: .gs25 case ._7Eleven: ._7Eleven case .emart24: .emart24 - case .ministop: .ministop } } } diff --git a/PyeonHaeng-iOS/Sources/Scenes/ProductSearchScene/SearchView.swift b/PyeonHaeng-iOS/Sources/Scenes/ProductSearchScene/SearchView.swift index 4747166..06457d8 100644 --- a/PyeonHaeng-iOS/Sources/Scenes/ProductSearchScene/SearchView.swift +++ b/PyeonHaeng-iOS/Sources/Scenes/ProductSearchScene/SearchView.swift @@ -161,8 +161,6 @@ private struct SearchHeaderView: View { ._7Eleven case .emart24: .emart24 - case .ministop: - .ministop } } } diff --git a/PyeonHaeng-iOS/Sources/Scenes/SettingsScene/Notice/ViewModel/NoticeConfiguration.swift b/PyeonHaeng-iOS/Sources/Scenes/SettingsScene/Notice/ViewModel/NoticeConfiguration.swift index 74e5593..b3eebea 100644 --- a/PyeonHaeng-iOS/Sources/Scenes/SettingsScene/Notice/ViewModel/NoticeConfiguration.swift +++ b/PyeonHaeng-iOS/Sources/Scenes/SettingsScene/Notice/ViewModel/NoticeConfiguration.swift @@ -12,7 +12,7 @@ import Foundation struct NoticeConfiguration { let pageSize: Int = 20 - private(set) var offset: Int = 0 + private(set) var offset: Int = 1 private(set) var loadingState: PagingState = .idle } diff --git a/PyeonHaeng-iOS/Sources/Scenes/SettingsScene/Notice/ViewModel/NoticeViewModel.swift b/PyeonHaeng-iOS/Sources/Scenes/SettingsScene/Notice/ViewModel/NoticeViewModel.swift index 111c208..bd87638 100644 --- a/PyeonHaeng-iOS/Sources/Scenes/SettingsScene/Notice/ViewModel/NoticeViewModel.swift +++ b/PyeonHaeng-iOS/Sources/Scenes/SettingsScene/Notice/ViewModel/NoticeViewModel.swift @@ -20,7 +20,6 @@ enum NoticeAction { struct NoticeState { var noticeList: [Notice] = [] - var totalCount: Int = 0 fileprivate var noticeConfiguration: NoticeConfiguration = .init() } @@ -81,7 +80,7 @@ final class NoticeViewModel: NoticeViewModelRepresentable { state.noticeConfiguration.startLoading() let noticeList = try await service.fetchNoticeList( request: .init( - pageSize: state.noticeConfiguration.pageSize, + limit: state.noticeConfiguration.pageSize, offset: state.noticeConfiguration.offset ) ) diff --git a/PyeonHaeng-iOSTests/ProductConfigurationTests.swift b/PyeonHaeng-iOSTests/ProductConfigurationTests.swift index 1e225a4..4c0ecec 100644 --- a/PyeonHaeng-iOSTests/ProductConfigurationTests.swift +++ b/PyeonHaeng-iOSTests/ProductConfigurationTests.swift @@ -37,7 +37,7 @@ final class ProductConfigurationTests: XCTestCase { // Assert XCTAssertEqual(sut?.loadingState, .loadedAll, "loadingState should be .loadedAll when no more pages are available") - XCTAssertEqual(sut?.offset, 1, "offset should be incremented by 1 after update") + XCTAssertEqual(sut?.offset, 2, "offset should be incremented by 2 after update") } func testChangeConvenienceStoreUpdatesStore() { diff --git a/Shared/Sources/DesignSystem/Resources/Images.xcassets/BrandImage/Ministop.imageset/Contents.json b/Shared/Sources/DesignSystem/Resources/Images.xcassets/BrandImage/Ministop.imageset/Contents.json deleted file mode 100644 index b75d8fb..0000000 --- a/Shared/Sources/DesignSystem/Resources/Images.xcassets/BrandImage/Ministop.imageset/Contents.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "images" : [ - { - "filename" : "Ministop.svg", - "idiom" : "universal" - } - ], - "info" : { - "author" : "xcode", - "version" : 1 - }, - "properties" : { - "preserves-vector-representation" : true - } -} diff --git a/Shared/Sources/DesignSystem/Resources/Images.xcassets/BrandImage/Ministop.imageset/Ministop.svg b/Shared/Sources/DesignSystem/Resources/Images.xcassets/BrandImage/Ministop.imageset/Ministop.svg deleted file mode 100644 index 72209b7..0000000 --- a/Shared/Sources/DesignSystem/Resources/Images.xcassets/BrandImage/Ministop.imageset/Ministop.svg +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/Shared/Sources/DesignSystem/Sources/Extensions/Image+Resource.swift b/Shared/Sources/DesignSystem/Sources/Extensions/Image+Resource.swift index b63a152..e33080b 100644 --- a/Shared/Sources/DesignSystem/Sources/Extensions/Image+Resource.swift +++ b/Shared/Sources/DesignSystem/Sources/Extensions/Image+Resource.swift @@ -12,7 +12,6 @@ public extension Image { static let gs25: Image = .init(ImageResource.GS_25) static let _7Eleven: Image = .init(ImageResource._7Eleven) static let emart24: Image = .init(ImageResource.emart24) - static let ministop: Image = .init(ImageResource.ministop) static let appstore: Image = .init(.appstore) static let appstoreFill: Image = .init(.appstoreFill)