Tusker/Pachyderm/Model/Timeline.swift

41 lines
1.1 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 {
func request(range: RequestRange) -> Request<[Status]> {
var request: Request<[Status]>
switch self {
case .home:
request = Request(method: .get, path: "/api/v1/timelines/home")
case let .public(local):
request = Request(method: .get, path: "/api/v1/timelines/public")
if local {
request.queryParameters.append("local" => true)
}
case let .tag(hashtag):
request = Request(method: .get, path: "/api/v1/timeliens/tag/\(hashtag)")
case let .list(id):
request = Request(method: .get, path: "/api/v1/timelines/list/\(id)")
case .direct:
request = Request(method: .get, path: "/api/v1/timelines/direct")
}
request.range = range
return request
}
}