-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserAPI.swift
More file actions
66 lines (58 loc) · 1.69 KB
/
UserAPI.swift
File metadata and controls
66 lines (58 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright © 2025 Booket. All rights reserved
import Foundation
enum UserAPI {
case me
case termsAgreement(termsAgreed: Bool)
case upsertFCMToken(fcmToken: String)
case upsertNotificationSettings(notificationEnabled: Bool)
}
extension UserAPI: RequestTarget {
var baseURL: String {
return "\(APIConfig.baseURL)/users/me"
}
var path: String {
switch self {
case .me:
return ""
case .termsAgreement:
return "/terms-agreement"
case .upsertFCMToken:
return "/fcm-token"
case .upsertNotificationSettings:
return "/notification-settings"
}
}
var method: HTTPMethod {
switch self {
case .me:
return .get
case .termsAgreement, .upsertFCMToken, .upsertNotificationSettings:
return .put
}
}
var headers: [String: String] {
switch self {
case .termsAgreement, .upsertFCMToken, .upsertNotificationSettings:
return [
"Content-Type": "application/json"
]
case .me:
return [:]
}
}
var body: Encodable? {
switch self {
case .termsAgreement(let termsAgreed):
return TermsAgreementRequestDTO(termsAgreed: termsAgreed)
case .upsertFCMToken(let fcmToken):
return UpsertFCMTokenRequestDTO(fcmToken: fcmToken)
case .upsertNotificationSettings(let notificationEnabled):
return NotificationStatusRequestDTO(notificationEnabled: notificationEnabled)
case .me:
return nil
}
}
var query: [String: Any] {
return [:]
}
}