Skip to content

Commit 3cc0034

Browse files
committed
[feat] #187 관심사 수정 api 연동
1 parent ad594f5 commit 3cc0034

File tree

6 files changed

+35
-4
lines changed

6 files changed

+35
-4
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// InterestRequest.swift
3+
// CoreKit
4+
//
5+
// Created by 김도형 on 3/1/25.
6+
//
7+
8+
import Foundation
9+
10+
public struct InterestRequest: Encodable {
11+
public let interests: [String]
12+
13+
public init(interests: [String]) {
14+
self.interests = interests
15+
}
16+
}

Projects/CoreKit/Sources/Data/Network/User/UserClient+LiveKey.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ extension UserClient: DependencyKey {
3535
},
3636
유저_관심사_목록_조회: {
3737
try await provider.request(.유저_관심사_목록_조회)
38+
},
39+
관심사_수정: { model in
40+
try await provider.requestNoBody(.관심사_수정(model: model))
3841
}
3942
)
4043
}()

Projects/CoreKit/Sources/Data/Network/User/UserClient+TestKey.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ extension UserClient: TestDependencyKey {
1818
관심사_목록_조회: { InterestResponse.mock },
1919
닉네임_조회: { .mock },
2020
fcm_토큰_저장: { _ in .mock },
21-
유저_관심사_목록_조회: { InterestResponse.mock }
21+
유저_관심사_목록_조회: { InterestResponse.mock },
22+
관심사_수정: { _ in }
2223
)
2324
}()
2425
}

Projects/CoreKit/Sources/Data/Network/User/UserClient.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ public struct UserClient {
1616
public var 닉네임_조회: @Sendable () async throws -> BaseUserResponse
1717
public var fcm_토큰_저장: @Sendable (_ model: FCMRequest) async throws -> FCMResponse
1818
public var 유저_관심사_목록_조회: @Sendable () async throws -> [InterestResponse]
19+
public var 관심사_수정: @Sendable (_ model: InterestRequest) async throws -> Void
1920
}

Projects/CoreKit/Sources/Data/Network/User/UserEndpoint.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public enum UserEndpoint {
1818
case 닉네임_조회
1919
case fcm_토큰_저장(model: FCMRequest)
2020
case 유저_관심사_목록_조회
21+
case 관심사_수정(model: InterestRequest)
2122
}
2223

2324
extension UserEndpoint: TargetType {
@@ -37,14 +38,15 @@ extension UserEndpoint: TargetType {
3738
return "/interests"
3839
case .fcm_토큰_저장:
3940
return "/fcm"
40-
case .유저_관심사_목록_조회:
41+
case .유저_관심사_목록_조회, .관심사_수정:
4142
return "/myinterests"
4243
}
4344
}
4445

4546
public var method: Moya.Method {
4647
switch self {
47-
case .닉네임_수정:
48+
case .닉네임_수정,
49+
.관심사_수정:
4850
return .put
4951

5052
case .회원등록,
@@ -67,6 +69,8 @@ extension UserEndpoint: TargetType {
6769
return .requestJSONEncodable(model)
6870
case let .fcm_토큰_저장(model):
6971
return .requestJSONEncodable(model)
72+
case let .관심사_수정(model):
73+
return .requestJSONEncodable(model)
7074
case .닉네임_중복_체크,
7175
.관심사_목록_조회,
7276
.닉네임_조회,

Projects/Feature/FeatureRecommend/Sources/Recommend/RecommendFeature.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,13 @@ private extension RecommendFeature {
193193
return shared(.async(.관심사_조회_API), state: &state)
194194
case .키워드_선택_버튼_눌렀을때:
195195
state.showKeywordSheet = false
196-
return .none
196+
state.selectedInterest = nil
197+
return .run { [ interests = state.selectedInterestList ] send in
198+
let request = InterestRequest(interests: interests.map(\.description))
199+
try await userClient.관심사_수정(model: request)
200+
await send(.async(.유저_관심사_조회_API))
201+
await send(.async(.추천_조회_API))
202+
}
197203
}
198204
}
199205

0 commit comments

Comments
 (0)