2020-08-24 04:50:54 +02:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
|
|
|
import Foundation
|
2020-08-31 03:40:58 +02:00
|
|
|
import HTTP
|
2020-09-04 03:55:46 +02:00
|
|
|
import Mastodon
|
2020-08-24 04:50:54 +02:00
|
|
|
|
2020-08-31 01:33:11 +02:00
|
|
|
public enum StatusEndpoint {
|
2020-08-24 06:34:19 +02:00
|
|
|
case status(id: String)
|
2020-08-24 04:50:54 +02:00
|
|
|
case favourite(id: String)
|
|
|
|
case unfavourite(id: String)
|
|
|
|
}
|
|
|
|
|
2020-08-31 01:59:49 +02:00
|
|
|
extension StatusEndpoint: Endpoint {
|
2020-08-31 01:33:11 +02:00
|
|
|
public typealias ResultType = Status
|
2020-08-24 04:50:54 +02:00
|
|
|
|
2020-08-31 01:33:11 +02:00
|
|
|
public var context: [String] {
|
2020-08-24 04:50:54 +02:00
|
|
|
defaultContext + ["statuses"]
|
|
|
|
}
|
|
|
|
|
2020-08-31 01:33:11 +02:00
|
|
|
public var pathComponentsInContext: [String] {
|
2020-08-24 04:50:54 +02:00
|
|
|
switch self {
|
2020-08-24 06:34:19 +02:00
|
|
|
case let .status(id):
|
|
|
|
return [id]
|
2020-08-24 04:50:54 +02:00
|
|
|
case let .favourite(id):
|
|
|
|
return [id, "favourite"]
|
|
|
|
case let .unfavourite(id):
|
|
|
|
return [id, "unfavourite"]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-31 01:33:11 +02:00
|
|
|
public var method: HTTPMethod {
|
2020-08-24 04:50:54 +02:00
|
|
|
switch self {
|
2020-08-24 06:34:19 +02:00
|
|
|
case .status:
|
|
|
|
return .get
|
2020-08-24 04:50:54 +02:00
|
|
|
case .favourite, .unfavourite:
|
|
|
|
return .post
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|