IceCubesApp/Packages/Network/Sources/Network/Endpoint/Notifications.swift

33 lines
752 B
Swift
Raw Normal View History

2022-12-19 11:28:55 +00:00
import Foundation
public enum Notifications: Endpoint {
case notifications(sinceId: String?,
maxId: String?,
types: [String]?)
case clear
2023-01-17 10:36:01 +00:00
2022-12-19 11:28:55 +00:00
public func path() -> String {
switch self {
case .notifications:
return "notifications"
case .clear:
return "notifications/clear"
2022-12-19 11:28:55 +00:00
}
}
2023-01-17 10:36:01 +00:00
2022-12-19 11:28:55 +00:00
public func queryItems() -> [URLQueryItem]? {
switch self {
2023-01-17 10:36:01 +00:00
case let .notifications(sinceId, maxId, types):
var params = makePaginationParam(sinceId: sinceId, maxId: maxId, mindId: nil) ?? []
if let types {
for type in types {
params.append(.init(name: "types[]", value: type))
}
2022-12-22 06:00:44 +00:00
}
return params
default:
return nil
2022-12-19 11:28:55 +00:00
}
}
}