Skip to content

Commit 3e407a1

Browse files
authored
πŸ”— :: (#256) μ•Œλ¦Ό μ„€μ • 개발
πŸ”— :: (#256) μ•Œλ¦Ό μ„€μ • 개발
2 parents 696f298 + c9236cc commit 3e407a1

23 files changed

+651
-2
lines changed

β€ŽProjects/Core/Sources/Steps/MyPageStep.swiftβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import RxFlow
33
public enum MyPageStep: Step {
44
case myPageIsRequired
55
case tabsIsRequired
6+
case notificationSettingIsRequired
67
case writableReviewIsRequired(_ id: Int)
78
case noticeIsRequired
89
case confirmIsRequired
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import RxFlow
2+
3+
public enum NotificationSettingStep: Step {
4+
case notificationSettingIsRequired
5+
}

β€ŽProjects/Data/Sources/DI/UseCaseAssembly.swiftβ€Ž

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,5 +228,20 @@ public final class UseCaseAssembly: Assembly {
228228
notificationsRepository: resolver.resolve(NotificationsRepository.self)!
229229
)
230230
}
231+
container.register(SubscribeNotificationUseCase.self) { resolver in
232+
SubscribeNotificationUseCase(
233+
notificationsRepository: resolver.resolve(NotificationsRepository.self)!
234+
)
235+
}
236+
container.register(SubscribeAllNotificationUseCase.self) { resolver in
237+
SubscribeAllNotificationUseCase(
238+
notificationsRepository: resolver.resolve(NotificationsRepository.self)!
239+
)
240+
}
241+
container.register(FetchSubscribeStateUseCase.self) { resolver in
242+
FetchSubscribeStateUseCase(
243+
notificationsRepository: resolver.resolve(NotificationsRepository.self)!
244+
)
245+
}
231246
}
232247
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import Foundation
2+
import Domain
3+
4+
struct SubscribeStateListResponseDTO: Codable {
5+
let topics: [SubscribeStateResponseDTO]
6+
}
7+
8+
public struct SubscribeStateResponseDTO: Codable {
9+
let topic: NotificationType
10+
let isSubscribed: Bool
11+
12+
enum CodingKeys: String, CodingKey {
13+
case topic
14+
case isSubscribed = "subscribed"
15+
}
16+
}
17+
18+
extension SubscribeStateListResponseDTO {
19+
func toDomain() -> [SubscribeStateEntity] {
20+
topics.map {
21+
return SubscribeStateEntity.init(
22+
topic: $0.topic,
23+
isSubscribed: $0.isSubscribed
24+
)
25+
}
26+
}
27+
}

β€ŽProjects/Data/Sources/DataSource/API/NotificationsAPI.swiftβ€Ž

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import Domain
55
public enum NotificationsAPI {
66
case fetchNotificationList
77
case patchReadNotification(id: Int)
8+
case subscribeNotification(token: String, notificationType: NotificationType)
9+
case subscribeAllNotification
10+
case fetchSubscribeState
811
}
912

1013
extension NotificationsAPI: JobisAPI {
@@ -21,16 +24,28 @@ extension NotificationsAPI: JobisAPI {
2124

2225
case let .patchReadNotification(id):
2326
return "/\(id)"
27+
28+
case .subscribeNotification:
29+
return "/topic"
30+
31+
case .subscribeAllNotification:
32+
return "/topics"
33+
34+
case .fetchSubscribeState:
35+
return "/topic"
2436
}
2537
}
2638

2739
public var method: Method {
2840
switch self {
29-
case .fetchNotificationList:
41+
case .fetchNotificationList, .fetchSubscribeState:
3042
return .get
3143

3244
case .patchReadNotification:
3345
return .patch
46+
47+
case .subscribeNotification, .subscribeAllNotification:
48+
return .patch
3449
}
3550
}
3651

@@ -42,6 +57,16 @@ extension NotificationsAPI: JobisAPI {
4257
// // TODO: μΆ”ν›„ μ½μŒμ™€ μ•ˆμ½μŒ λΆ„κΈ°μ²˜λ¦¬ ν•„μš”
4358
["is_new": ""],
4459
encoding: URLEncoding.queryString)
60+
61+
case let .subscribeNotification(token, notificationType):
62+
return .requestParameters(
63+
parameters: [
64+
"token": token,
65+
"topic": notificationType.rawValue
66+
],
67+
encoding: URLEncoding.queryString
68+
)
69+
4570
default:
4671
return .requestPlain
4772
}

β€ŽProjects/Data/Sources/DataSource/Remote/RemoteNotificationsDataSource.swiftβ€Ž

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import Domain
55
public protocol RemoteNotificationsDataSource {
66
func fetchNotificationList() -> Single<[NotificationEntity]>
77
func patchReadNotification(id: Int) -> Completable
8+
func subscribeNotification(token: String, notificationType: NotificationType) -> Completable
9+
func subscribeAllNotification() -> Completable
10+
func fetchSubscribeState() -> Single<[SubscribeStateEntity]>
811
}
912

1013
final class RemoteNotificationsDataSourceImpl: RemoteBaseDataSource<NotificationsAPI>, RemoteNotificationsDataSource {
@@ -18,4 +21,20 @@ final class RemoteNotificationsDataSourceImpl: RemoteBaseDataSource<Notification
1821
request(.patchReadNotification(id: id))
1922
.asCompletable()
2023
}
24+
25+
func subscribeNotification(token: String, notificationType: NotificationType) -> Completable {
26+
request(.subscribeNotification(token: token, notificationType: notificationType))
27+
.asCompletable()
28+
}
29+
30+
func subscribeAllNotification() -> Completable {
31+
request(.subscribeAllNotification)
32+
.asCompletable()
33+
}
34+
35+
func fetchSubscribeState() -> RxSwift.Single<[Domain.SubscribeStateEntity]> {
36+
request(.fetchSubscribeState)
37+
.map(SubscribeStateListResponseDTO.self)
38+
.map { $0.toDomain() }
39+
}
2140
}

β€ŽProjects/Data/Sources/Repositories/NotificationsRepositoryImpl.swiftβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,16 @@ struct NotificationsRepositoryImpl: NotificationsRepository {
1717
func patchReadNotification(id: Int) -> Completable {
1818
remoteNotificationsDataSource.patchReadNotification(id: id)
1919
}
20+
21+
func subscribeNotification(token: String, notificationType: NotificationType) -> Completable {
22+
remoteNotificationsDataSource.subscribeNotification(token: token, notificationType: notificationType)
23+
}
24+
25+
func subscribeAllNotification() -> Completable {
26+
remoteNotificationsDataSource.subscribeAllNotification()
27+
}
28+
29+
func fetchSubscribeState() -> Single<[SubscribeStateEntity]> {
30+
remoteNotificationsDataSource.fetchSubscribeState()
31+
}
2032
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import Foundation
2+
3+
public struct SubscribeStateEntity: Equatable, Hashable {
4+
public let topic: NotificationType
5+
public let isSubscribed: Bool
6+
7+
public init(
8+
topic: NotificationType,
9+
isSubscribed: Bool
10+
) {
11+
self.topic = topic
12+
self.isSubscribed = isSubscribed
13+
}
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import Foundation
2+
3+
public enum NotificationType: String, Codable {
4+
case notice = "NEW_NOTICE"
5+
case recruitment = "RECRUITMENT_DONE"
6+
case application = "APPLICATION_STATUS_CHANGED"
7+
case interestRecruitment = "NEW_INTERESTED_RECRUITMENT"
8+
}

β€ŽProjects/Domain/Sources/Repositories/NotificationsRepository.swiftβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@ import RxSwift
33
public protocol NotificationsRepository {
44
func fetchNotificationsList() -> Single<[NotificationEntity]>
55
func patchReadNotification(id: Int) -> Completable
6+
func subscribeNotification(token: String, notificationType: NotificationType) -> Completable
7+
func subscribeAllNotification() -> Completable
8+
func fetchSubscribeState() -> Single<[SubscribeStateEntity]>
69
}

0 commit comments

Comments
Β (0)