metatext/Networking/Mastodon API/Endpoints/DeletionEndpoint.swift

49 lines
1.1 KiB
Swift
Raw Normal View History

// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
enum DeletionEndpoint {
case oauthRevoke(token: String, clientID: String, clientSecret: String)
2020-08-29 03:50:58 +00:00
case list(id: String)
}
extension DeletionEndpoint: MastodonEndpoint {
typealias ResultType = [String: String]
var context: [String] {
switch self {
case .oauthRevoke:
2020-08-29 03:50:58 +00:00
return ["oauth"]
case .list:
return defaultContext + ["lists"]
}
}
var pathComponentsInContext: [String] {
switch self {
case .oauthRevoke:
2020-08-29 03:50:58 +00:00
return ["revoke"]
case let .list(id):
return [id]
}
}
var method: HTTPMethod {
switch self {
case .oauthRevoke:
return .post
2020-08-29 03:50:58 +00:00
case .list:
return .delete
}
}
var parameters: [String: Any]? {
switch self {
case let .oauthRevoke(token, clientID, clientSecret):
return ["token": token, "client_id": clientID, "client_secret": clientSecret]
2020-08-29 03:50:58 +00:00
case .list:
return nil
}
}
}