metatext/MastodonAPI/Sources/MastodonAPI/Endpoints/TimelinesEndpoint.swift

45 lines
941 B
Swift
Raw Normal View History

2020-08-18 05:13:37 +00:00
// Copyright © 2020 Metabolist. All rights reserved.
import Foundation
2020-08-31 01:40:58 +00:00
import HTTP
import Mastodon
2020-08-18 05:13:37 +00:00
2020-08-30 23:33:11 +00:00
public enum TimelinesEndpoint {
2020-08-18 05:13:37 +00:00
case `public`(local: Bool)
case tag(String)
case home
case list(id: String)
}
2020-08-30 23:59:49 +00:00
extension TimelinesEndpoint: Endpoint {
2020-08-30 23:33:11 +00:00
public typealias ResultType = [Status]
2020-08-18 05:13:37 +00:00
2020-08-30 23:33:11 +00:00
public var context: [String] {
2020-08-18 05:13:37 +00:00
defaultContext + ["timelines"]
}
2020-08-30 23:33:11 +00:00
public var pathComponentsInContext: [String] {
2020-08-18 05:13:37 +00:00
switch self {
case .public:
return ["public"]
case let .tag(tag):
return ["tag", tag]
case .home:
return ["home"]
case let .list(id):
return ["list", id]
}
}
2020-08-30 23:33:11 +00:00
public var parameters: [String: Any]? {
2020-08-18 05:13:37 +00:00
switch self {
case let .public(local):
return ["local": local]
default:
return nil
}
}
2020-08-30 23:33:11 +00:00
public var method: HTTPMethod { .get }
2020-08-18 05:13:37 +00:00
}