feat(notification): 알림함 진입 및 딥링크 라우팅을 추가한다
This commit is contained in:
50
SodaLive/Sources/Notification/List/PushNotificationApi.swift
Normal file
50
SodaLive/Sources/Notification/List/PushNotificationApi.swift
Normal file
@@ -0,0 +1,50 @@
|
||||
import Foundation
|
||||
|
||||
import Moya
|
||||
|
||||
enum PushNotificationApi {
|
||||
case getPushNotificationCategories
|
||||
case getPushNotificationList(page: Int, size: Int, category: String?)
|
||||
}
|
||||
|
||||
extension PushNotificationApi: TargetType {
|
||||
var baseURL: URL {
|
||||
URL(string: BASE_URL)!
|
||||
}
|
||||
|
||||
var path: String {
|
||||
switch self {
|
||||
case .getPushNotificationCategories:
|
||||
return "/push/notification/categories"
|
||||
case .getPushNotificationList:
|
||||
return "/push/notification/list"
|
||||
}
|
||||
}
|
||||
|
||||
var method: Moya.Method {
|
||||
.get
|
||||
}
|
||||
|
||||
var task: Task {
|
||||
switch self {
|
||||
case .getPushNotificationCategories:
|
||||
return .requestPlain
|
||||
|
||||
case .getPushNotificationList(let page, let size, let category):
|
||||
var parameters: [String: Any] = [
|
||||
"page": max(0, page - 1),
|
||||
"size": size
|
||||
]
|
||||
|
||||
if let category = category?.trimmingCharacters(in: .whitespacesAndNewlines), !category.isEmpty {
|
||||
parameters["category"] = category
|
||||
}
|
||||
|
||||
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
|
||||
}
|
||||
}
|
||||
|
||||
var headers: [String: String]? {
|
||||
["Authorization": "Bearer \(UserDefaults.string(forKey: UserDefaultsKey.token))"]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user