2022-12-19 11:28:55 +00:00
|
|
|
import Foundation
|
|
|
|
|
|
|
|
public enum Notifications: Endpoint {
|
2022-12-24 11:20:42 +00:00
|
|
|
case notifications(sinceId: String?,
|
|
|
|
maxId: String?,
|
|
|
|
types: [String]?)
|
2022-12-29 08:10:49 +00:00
|
|
|
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"
|
2022-12-29 08:10:49 +00:00
|
|
|
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):
|
2022-12-28 18:10:13 +00:00
|
|
|
var params = makePaginationParam(sinceId: sinceId, maxId: maxId, mindId: nil) ?? []
|
2022-12-24 11:20:42 +00:00
|
|
|
if let types {
|
|
|
|
for type in types {
|
|
|
|
params.append(.init(name: "types[]", value: type))
|
|
|
|
}
|
2022-12-22 06:00:44 +00:00
|
|
|
}
|
|
|
|
return params
|
2022-12-29 08:10:49 +00:00
|
|
|
default:
|
|
|
|
return nil
|
2022-12-19 11:28:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|