32 lines
712 B
Swift
32 lines
712 B
Swift
|
//
|
||
|
// 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):
|
||
|
return ["since_id" => id, "count" => count]
|
||
|
}
|
||
|
}
|
||
|
}
|