mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-29 03:21:02 +00:00
37 lines
804 B
Swift
37 lines
804 B
Swift
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
import Foundation
|
|
|
|
enum StatusEndpoint {
|
|
case status(id: String)
|
|
case favourite(id: String)
|
|
case unfavourite(id: String)
|
|
}
|
|
|
|
extension StatusEndpoint: MastodonEndpoint {
|
|
typealias ResultType = Status
|
|
|
|
var context: [String] {
|
|
defaultContext + ["statuses"]
|
|
}
|
|
|
|
var pathComponentsInContext: [String] {
|
|
switch self {
|
|
case let .status(id):
|
|
return [id]
|
|
case let .favourite(id):
|
|
return [id, "favourite"]
|
|
case let .unfavourite(id):
|
|
return [id, "unfavourite"]
|
|
}
|
|
}
|
|
|
|
var method: HTTPMethod {
|
|
switch self {
|
|
case .status:
|
|
return .get
|
|
case .favourite, .unfavourite:
|
|
return .post
|
|
}
|
|
}
|
|
}
|