2018-09-11 10:52:21 -04:00
|
|
|
//
|
|
|
|
// RequestRange.swift
|
|
|
|
// Pachyderm
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 9/9/18.
|
|
|
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
public enum RequestRange {
|
|
|
|
case `default`
|
|
|
|
case count(Int)
|
|
|
|
case before(id: String, count: Int?)
|
|
|
|
case after(id: String, count: Int?)
|
|
|
|
}
|
|
|
|
|
|
|
|
extension RequestRange {
|
|
|
|
var queryParameters: [Parameter] {
|
|
|
|
switch self {
|
|
|
|
case .default:
|
|
|
|
return []
|
|
|
|
case let .count(count):
|
|
|
|
return ["limit" => count]
|
|
|
|
case let .before(id, count):
|
|
|
|
return ["max_id" => id, "count" => count]
|
|
|
|
case let .after(id, count):
|
2019-07-31 17:33:48 -06:00
|
|
|
return ["min_id" => id, "count" => count]
|
2018-09-11 10:52:21 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|