metatext/MastodonAPI/Sources/MastodonAPI/Endpoints/ListEndpoint.swift

39 lines
730 B
Swift
Raw Normal View History

2020-08-29 03:50:58 +00:00
// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
2020-08-31 01:40:58 +00:00
import HTTP
import Mastodon
2020-08-29 03:50:58 +00:00
2020-08-30 23:33:11 +00:00
public enum ListEndpoint {
2020-08-29 03:50:58 +00:00
case create(title: String)
}
2020-08-30 23:59:49 +00:00
extension ListEndpoint: Endpoint {
2020-08-30 23:33:11 +00:00
public typealias ResultType = MastodonList
2020-08-29 03:50:58 +00:00
2020-08-30 23:33:11 +00:00
public var context: [String] {
2020-08-29 03:50:58 +00:00
defaultContext + ["lists"]
}
2020-08-30 23:33:11 +00:00
public var pathComponentsInContext: [String] {
2020-08-29 03:50:58 +00:00
switch self {
case .create:
return []
}
}
2020-09-23 07:04:37 +00:00
public var jsonBody: [String: Any]? {
2020-08-29 03:50:58 +00:00
switch self {
case let .create(title):
return ["title": title]
}
}
2020-08-30 23:33:11 +00:00
public var method: HTTPMethod {
2020-08-29 03:50:58 +00:00
switch self {
case .create:
return .post
}
}
}