41 lines
1.1 KiB
Swift
41 lines
1.1 KiB
Swift
//
|
|
// TimelineMarkers.swift
|
|
// Pachyderm
|
|
//
|
|
// Created by Shadowfacts on 2/14/23.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
public struct TimelineMarkers: Decodable, Sendable {
|
|
public let home: Marker?
|
|
public let notifications: Marker?
|
|
|
|
public static func request(timelines: [Timeline]) -> Request<TimelineMarkers> {
|
|
return Request(method: .get, path: "/api/v1/markers", queryParameters: "timeline[]" => timelines.map(\.rawValue))
|
|
}
|
|
|
|
public static func update(timeline: Timeline, lastReadID: String) -> Request<Empty> {
|
|
return Request(method: .post, path: "/api/v1/markers", body: ParametersBody([
|
|
"\(timeline.rawValue)[last_read_id]" => lastReadID,
|
|
]))
|
|
}
|
|
|
|
public enum Timeline: String {
|
|
case home
|
|
case notifications
|
|
}
|
|
|
|
public struct Marker: Decodable, Sendable {
|
|
public let lastReadID: String
|
|
public let version: Int
|
|
public let updatedAt: Date
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
case lastReadID = "last_read_id"
|
|
case version
|
|
case updatedAt = "updated_at"
|
|
}
|
|
}
|
|
}
|