metatext-app-ios-iphone-ipad/MastodonAPI/Sources/MastodonAPI/Endpoints/NotificationsEndpoint.swift

32 lines
777 B
Swift

// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
import HTTP
import Mastodon
public enum NotificationsEndpoint {
case notifications(excludeTypes: Set<MastodonNotification.NotificationType>)
}
extension NotificationsEndpoint: Endpoint {
public typealias ResultType = [MastodonNotification]
public var pathComponentsInContext: [String] {
["notifications"]
}
public var queryParameters: [URLQueryItem] {
switch self {
case let .notifications(excludeTypes):
return Array(excludeTypes).map { URLQueryItem(name: "exclude_types[]", value: $0.rawValue) }
}
}
public var method: HTTPMethod {
switch self {
case .notifications:
return .get
}
}
}