Skip to content

Commit

Permalink
♻️ [refactor] 카탈로그를 네트워크로 가져오는 로직 부분 중복코드 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
leeari95 committed Nov 15, 2024
1 parent 1d6cc0b commit a489ebd
Show file tree
Hide file tree
Showing 31 changed files with 138 additions and 449 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct AccessoriesResponseDTO: Codable {
let colors: [Color]?
}

extension AccessoriesResponseDTO {
extension AccessoriesResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct BagsResponseDTO: Codable {
let colors: [Color]?
}

extension BagsResponseDTO {
extension BagsResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct BottomsResponseDTO: Codable {
let colors: [Color]?
}

extension BottomsResponseDTO {
extension BottomsResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct DressUpResponseDTO: Codable {
let colors: [Color]?
}

extension DressUpResponseDTO {
extension DressUpResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct HeadwearResponseDTO: Codable {
let colors: [Color]?
}

extension HeadwearResponseDTO {
extension HeadwearResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct ShoesResponseDTO: Codable {
let variations: [WardrobeVariat]?
}

extension ShoesResponseDTO {
extension ShoesResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct SocksResponseDTO: Codable {
let colors: [Color]?
}

extension SocksResponseDTO {
extension SocksResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ struct WardrobeVariat: Codable {
}
}

extension TopsResponseDTO {
extension TopsResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct UmbrellasResponseDTO: Codable {
let recipe: RecipeResponseDTO?
}

extension UmbrellasResponseDTO {
extension UmbrellasResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct WetSuitResponseDTO: Codable {
let variations: [WardrobeVariat]?
}

extension WetSuitResponseDTO {
extension WetSuitResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// DomainConvertible.swift
// ACNH-wiki
//
// Created by Ari on 11/15/24.
//

import Foundation

protocol DomainConvertible: Decodable {
func toDomain() -> Item
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct CeilingDecorResponseDTO: Codable {
let recipe: RecipeResponseDTO?
}

extension CeilingDecorResponseDTO {
extension CeilingDecorResponseDTO: DomainConvertible {
func toDomain() -> Item {
let image = variations.first?.image
return Item(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ extension Item {
}
}

extension FencingResponseDTO {
extension FencingResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct FloorsResponseDTO: Codable {

}

extension FloorsResponseDTO {
extension FloorsResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ enum Kit: String, Codable {
case rainbowFeather = "Rainbow feather"
}

extension HousewaresResponseDTO {
extension HousewaresResponseDTO: DomainConvertible {
func toDomain() -> Item {
let image = image ?? variations?.first?.image
return Item(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct MiscellaneousResponseDTO: Codable {

}

extension MiscellaneousResponseDTO {
extension MiscellaneousResponseDTO: DomainConvertible {
func toDomain() -> Item {
let image = image ?? variations?.first?.image
return Item(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct OtherResponseDTO: Codable {

}

extension OtherResponseDTO {
extension OtherResponseDTO : DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct PhotosResponseDTO: Codable {
let variations: [Variant]
}

extension PhotosResponseDTO {
extension PhotosResponseDTO: DomainConvertible {

func toDomain() -> Item {
return Item(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct RecipeResponseDTO: Codable {
let materialsTranslations: [String: Translations?]
}

extension RecipeResponseDTO {
extension RecipeResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct RugsResponseDTO: Codable {
let seriesTranslations: Translations?
}

extension RugsResponseDTO {
extension RugsResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct SongResponseDTO: Codable {
let musicURL: String?
}

extension SongResponseDTO {
extension SongResponseDTO: DomainConvertible {
func toDomain() -> Item {
var sources = ["K.K. concert"]
var sourceNotes: [String]?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct WallMountedResponseDTO: Codable {

}

extension WallMountedResponseDTO {
extension WallMountedResponseDTO: DomainConvertible {
func toDomain() -> Item {
let image = image ?? variations?.first?.image
return Item(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct WallpaperResponseDTO: Codable {
let recipe: RecipeResponseDTO?
}

extension WallpaperResponseDTO {
extension WallpaperResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ extension Item {
}
}

extension GyroidsResponseDTO {
extension GyroidsResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ enum Concept: String, Codable, CaseIterable {
}
}

extension ArtResponseDTO {
extension ArtResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: self.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ enum Weather: String, Codable {
case rainOnly = "Rain only"
}

extension BugResponseDTO {
extension BugResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: self.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ enum Vision: String, Codable {
case wide = "Wide"
}

extension FishResponseDTO {
extension FishResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: self.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ enum Museum: String, Codable {
case room3 = "Room 3"
}

extension FossilsResponseDTO {
extension FossilsResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: self.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ enum MovementSpeed: String, Codable {
case verySlow = "Very slow"
}

extension SeaCreaturesResponseDTO {
extension SeaCreaturesResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: self.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extension Item {
}
}

extension ReactionsResponseDTO {
extension ReactionsResponseDTO: DomainConvertible {
func toDomain() -> Item {
return Item(
name: name,
Expand Down
Loading

0 comments on commit a489ebd

Please sign in to comment.