Tusker/Pachyderm/Model/Timeline.swift

44 lines
1.0 KiB
Swift

//
// Timeline.swift
// Pachyderm
//
// Created by Shadowfacts on 9/9/18.
// Copyright © 2018 Shadowfacts. All rights reserved.
//
import Foundation
public enum Timeline {
case home
case `public`(local: Bool)
case tag(hashtag: String)
case list(id: String)
case direct
}
extension Timeline {
var endpoint: String {
switch self {
case .home:
return "/api/v1/timelines/home"
case .public:
return "/api/v1/timelines/public"
case let .tag(hashtag):
return "/api/v1/timelines/tag/\(hashtag)"
case let .list(id):
return "/api/v1/timelines/list/\(id)"
case .direct:
return "/api/v1/timelines/direct"
}
}
func request(range: RequestRange) -> Request<[Status]> {
var request = Request<[Status]>(method: .get, path: endpoint)
if case .public(true) = self {
request.queryParameters.append("local" => true)
}
request.range = range
return request
}
}