Skip to content

Commit

Permalink
🎨 Refactor Entity and DTO to align with server products search API sp…
Browse files Browse the repository at this point in the history
…ecification
  • Loading branch information
WhiteHyun committed May 6, 2024
1 parent 6104031 commit adc8ca8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
16 changes: 8 additions & 8 deletions APIService/Sources/SearchAPI/Requests/SearchProductRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 1
self.limit = limit
self.offset = offset
self.date = date
}
}
18 changes: 6 additions & 12 deletions APIService/Sources/SearchAPI/Responses/SearchProductResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion APIService/Sources/SearchAPI/SearchEndPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ extension SearchEndPoint: EndPoint {
public var path: String {
switch self {
case .fetchProducts:
"/v2/search"
"/v2/products/search"
}
}

Expand Down

0 comments on commit adc8ca8

Please sign in to comment.