Skip to content

Commit 4668347

Browse files
ShapeKim98stealmh
authored andcommitted
[feat] #120 컨텐츠 개수 api 작성
1 parent 4927aac commit 4668347

File tree

3 files changed

+60
-4
lines changed

3 files changed

+60
-4
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// UnreadCountResponse.swift
3+
// CoreKit
4+
//
5+
// Created by 김도형 on 9/21/24.
6+
//
7+
8+
import Foundation
9+
10+
public struct BookmarkCountResponse: Decodable {
11+
let count: Int
12+
}
13+
14+
public struct UnreadCountResponse: Decodable {
15+
let count: Int
16+
}
17+
18+
extension UnreadCountResponse {
19+
static let mock: UnreadCountResponse = .init(count: 10)
20+
}
21+
22+
extension BookmarkCountResponse {
23+
static let mock: BookmarkCountResponse = .init(count: 10)
24+
}
25+
26+
extension UnreadCountResponse {
27+
enum CodingKeys: String, CodingKey {
28+
case count = "unreadContentCount"
29+
}
30+
}
31+
32+
extension BookmarkCountResponse {
33+
enum CodingKeys: String, CodingKey {
34+
case count = "bookmarkContentCount"
35+
}
36+
}

Projects/CoreKit/Sources/Data/Network/Remind/RemindClient.swift

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ public struct RemindClient {
1919
public var 즐겨찾기_링크모음_조회: @Sendable (
2020
_ model: BasePageableRequest
2121
) async throws -> ContentListInquiryResponse
22+
public var 읽지않음_컨텐츠_개수_조회: @Sendable ()
23+
async throws -> UnreadCountResponse
24+
public var 즐겨찾기_컨텐츠_개수_조회: @Sendable ()
25+
async throws -> BookmarkCountResponse
26+
2227
}
2328

2429
extension RemindClient: DependencyKey {
@@ -34,6 +39,12 @@ extension RemindClient: DependencyKey {
3439
},
3540
즐겨찾기_링크모음_조회: { model in
3641
try await provider.request(.즐겨찾기_링크모음_조회(model: model))
42+
},
43+
읽지않음_컨텐츠_개수_조회: {
44+
try await provider.request(.읽지않음_컨텐츠_개수_조회)
45+
},
46+
즐겨찾기_컨텐츠_개수_조회: {
47+
try await provider.request(.즐겨찾기_컨텐츠_개수_조회)
3748
}
3849
)
3950
}()
@@ -42,7 +53,9 @@ extension RemindClient: DependencyKey {
4253
.init(
4354
오늘의_리마인드_조회: { [.mock(id: 0), .mock(id: 1), .mock(id: 2)]},
4455
읽지않음_컨텐츠_조회: { _ in .mock },
45-
즐겨찾기_링크모음_조회: { _ in .mock }
56+
즐겨찾기_링크모음_조회: { _ in .mock },
57+
읽지않음_컨텐츠_개수_조회: { .mock },
58+
즐겨찾기_컨텐츠_개수_조회: { .mock }
4659
)
4760
}()
4861
}

Projects/CoreKit/Sources/Data/Network/Remind/RemindEndpoint.swift

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public enum RemindEndpoint {
1414
case 오늘의_리마인드_조회
1515
case 읽지않음_컨텐츠_조회(model: BasePageableRequest)
1616
case 즐겨찾기_링크모음_조회(model: BasePageableRequest)
17+
case 읽지않음_컨텐츠_개수_조회
18+
case 즐겨찾기_컨텐츠_개수_조회
1719
}
1820

1921
extension RemindEndpoint: TargetType {
@@ -31,22 +33,25 @@ extension RemindEndpoint: TargetType {
3133
case .오늘의_리마인드_조회: return "/today"
3234
case .읽지않음_컨텐츠_조회(_): return "/unread"
3335
case .즐겨찾기_링크모음_조회(_): return "/bookmark"
36+
case .읽지않음_컨텐츠_개수_조회: return "/unread/count"
37+
case .즐겨찾기_컨텐츠_개수_조회: return "/bookmark/count"
3438
}
3539
}
3640

3741
public var method: Moya.Method {
3842
switch self {
3943
case .오늘의_리마인드_조회,
4044
.읽지않음_컨텐츠_조회,
41-
.즐겨찾기_링크모음_조회:
45+
.즐겨찾기_링크모음_조회,
46+
.읽지않음_컨텐츠_개수_조회,
47+
.즐겨찾기_컨텐츠_개수_조회:
4248
return .get
4349
}
4450
}
4551

4652
public var task: Moya.Task {
4753
switch self {
48-
case .오늘의_리마인드_조회:
49-
return .requestPlain
54+
case .오늘의_리마인드_조회: return .requestPlain
5055
case .읽지않음_컨텐츠_조회(let model),
5156
.즐겨찾기_링크모음_조회(let model):
5257
return .requestParameters(
@@ -57,6 +62,8 @@ extension RemindEndpoint: TargetType {
5762
],
5863
encoding: URLEncoding.default
5964
)
65+
case .읽지않음_컨텐츠_개수_조회: return .requestPlain
66+
case .즐겨찾기_컨텐츠_개수_조회: return .requestPlain
6067
}
6168
}
6269

0 commit comments

Comments
 (0)