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

38 lines
804 B
Swift
Raw Normal View History

2020-08-24 02:50:54 +00:00
// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
enum StatusEndpoint {
2020-08-24 04:34:19 +00:00
case status(id: String)
2020-08-24 02:50:54 +00:00
case favourite(id: String)
case unfavourite(id: String)
}
extension StatusEndpoint: MastodonEndpoint {
typealias ResultType = Status
var context: [String] {
defaultContext + ["statuses"]
}
var pathComponentsInContext: [String] {
switch self {
2020-08-24 04:34:19 +00:00
case let .status(id):
return [id]
2020-08-24 02:50:54 +00:00
case let .favourite(id):
return [id, "favourite"]
case let .unfavourite(id):
return [id, "unfavourite"]
}
}
var method: HTTPMethod {
switch self {
2020-08-24 04:34:19 +00:00
case .status:
return .get
2020-08-24 02:50:54 +00:00
case .favourite, .unfavourite:
return .post
}
}
}