2018-09-11 14:52:21 +00:00
|
|
|
//
|
|
|
|
// 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 {
|
2018-09-14 15:35:00 +00:00
|
|
|
var endpoint: String {
|
2018-09-11 14:52:21 +00:00
|
|
|
switch self {
|
|
|
|
case .home:
|
2018-09-14 15:35:00 +00:00
|
|
|
return "/api/v1/timelines/home"
|
|
|
|
case .public:
|
|
|
|
return "/api/v1/timelines/public"
|
2018-09-11 14:52:21 +00:00
|
|
|
case let .tag(hashtag):
|
2018-09-14 15:35:00 +00:00
|
|
|
return "/api/v1/timelines/tag/\(hashtag)"
|
2018-09-11 14:52:21 +00:00
|
|
|
case let .list(id):
|
2018-09-14 15:35:00 +00:00
|
|
|
return "/api/v1/timelines/list/\(id)"
|
2018-09-11 14:52:21 +00:00
|
|
|
case .direct:
|
2018-09-14 15:35:00 +00:00
|
|
|
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)
|
2018-09-11 14:52:21 +00:00
|
|
|
}
|
|
|
|
request.range = range
|
|
|
|
return request
|
|
|
|
}
|
|
|
|
}
|