Skip to content
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

Feature/#8 home section UI, API implementation #12

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
10 changes: 8 additions & 2 deletions MarketKurly.xcodeproj/project.pbxproj
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ด๊ฑฐ discard ํ•ด๋„ ๋˜์ง€ ์•Š๋‚˜์š” ?!

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@
8BC226782CEDEB6B00FD38B7 /* Exceptions for "MarketKurly" folder in "MarketKurly" target */ = {
isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
membershipExceptions = (
Data/API/.gitkeep,
Data/Models/Request/.gitkeep,
Data/Models/Response/.gitkeep,
Info.plist,
Presentation/Detail/.gitkeep,
Presentation/Review/.gitkeep,
Presentation/Wish/.gitkeep,
);
target = 8BDE91B22CE9FE840093C44C /* MarketKurly */;
};
Expand Down Expand Up @@ -284,7 +290,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = ZB98N98LJ5;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = MarketKurly/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand Down Expand Up @@ -313,7 +319,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = "";
DEVELOPMENT_TEAM = ZB98N98LJ5;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = MarketKurly/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand Down
18 changes: 18 additions & 0 deletions MarketKurly/Core/Extensions/Formatter+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Formatter+.swift
// MarketKurly
//
// Created by ์ตœ์ง€์„ on 11/24/24.
//

import Foundation

extension Formatter {
static let currency: NumberFormatter = {
let formatter = NumberFormatter()
formatter.numberStyle = .decimal // ์ฒœ ๋‹จ์œ„๋กœ ',' ์ถ”๊ฐ€
formatter.maximumFractionDigits = 0 // ์†Œ์ˆ˜์  ์ž๋ฆฌ๋Š” ์—†๋„๋ก ์„ค์ •
formatter.minimumFractionDigits = 0
return formatter
}()
}
26 changes: 26 additions & 0 deletions MarketKurly/Core/Network/Home/HomeApi.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// HomeApi.swift
// MarketKurly
//
// Created by ์ตœ์ง€์„ on 11/28/24.
//

import Foundation

struct HomeApi {
static let shared = HomeApi()

private let client = KurlyClient.shared

func getHomeData(completion: @escaping (Result<HomeDto, NetworkError>) -> Void) {
client.request(HomeDto.self, target: HomeTarget.getHomeData) { result in
switch result {
case .success(let data):
completion(.success(data))
case .failure(let error):
completion(.failure(error))
}
}
}
}

14 changes: 14 additions & 0 deletions MarketKurly/Core/Network/Home/HomeDto.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// HomeDTO.swift
// MarketKurly
//
// Created by ์ตœ์ง€์„ on 11/28/24.
//

import Foundation

struct HomeDto: Codable, Hashable {
let mainBottomData: [HomeRecommendListItem]?
let mainTopProducts: [HomeWishListItem]?
let mainMiddleProducts: [HomeRankingListItem]?
}
41 changes: 41 additions & 0 deletions MarketKurly/Core/Network/Home/HomeTarget.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//
// HomeTarget.swift
// MarketKurly
//
// Created by ์ตœ์ง€์„ on 11/28/24.
//

import Foundation
import Alamofire

enum HomeTarget {
case getHomeData
}

extension HomeTarget: TargetType {
var baseURL: String {
return "http://211.188.50.209:8080"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์š”๊ฑฐ ์•ˆ์ˆจ๊ฒจ๋„ ๊ดœ์ฐฎ์„๊นŒ์—ฌ

}

var method: Alamofire.HTTPMethod {
switch self {
case .getHomeData: return .get
}
}
var path: String {
switch self {
case .getHomeData: return "/api/v1/products/main"
}
}

var parameters: RequestParameters {
switch self {
case .getHomeData: return .none
}
}

var encoding: ParameterEncoding {
return JSONEncoding.default
}
}

4 changes: 2 additions & 2 deletions MarketKurly/Core/Network/KurlyClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ final class KurlyClient: NetworkRequestable {
switch response.result {
case .success:
do {
let decodedData = try JSONDecoder().decode(T.self, from: data)
completion(.success(decodedData))
let decodedData = try JSONDecoder().decode(ResponseData<T>.self, from: data)
completion(.success(decodedData.data))
} catch {
completion(.failure(.parsingError))
}
Expand Down
12 changes: 12 additions & 0 deletions MarketKurly/Core/Network/ResponseData.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// ResponseData.swift
// MarketKurly
//
// Created by ์ตœ์ง€์„ on 11/28/24.
//

struct ResponseData<T: Decodable>: Decodable {
let success: Bool
let message: String
let data: T
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "icn_home_fashion.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "icn_home_homeliving.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "icn_home_kurlycurator.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "icn_home_kurlymembers.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "icn_home_livecommerce.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "icn_home_lowestprice.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "icn_home_luck.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "icn_home_members.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading