49 lines
1.1 KiB
Swift
49 lines
1.1 KiB
Swift
|
//
|
||
|
// Notification.swift
|
||
|
// Pachyderm
|
||
|
//
|
||
|
// Created by Shadowfacts on 9/9/18.
|
||
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
||
|
//
|
||
|
|
||
|
import Foundation
|
||
|
|
||
|
public class Notification: Decodable, ClientModel {
|
||
|
var client: Client! {
|
||
|
didSet {
|
||
|
account.client = client
|
||
|
status?.client = client
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public let id: String
|
||
|
public let kind: Kind
|
||
|
public let createdAt: Date
|
||
|
public let account: Account
|
||
|
public let status: Status?
|
||
|
|
||
|
public func dismiss(completion: @escaping Client.Callback<Empty>) {
|
||
|
let request = Request<Empty>(method: .post, path: "/api/v1/notifications/dismiss", body: .parameters([
|
||
|
"id" => id
|
||
|
]))
|
||
|
client.run(request, completion: completion)
|
||
|
}
|
||
|
|
||
|
private enum CodingKeys: String, CodingKey {
|
||
|
case id
|
||
|
case kind = "type"
|
||
|
case createdAt = "created_at"
|
||
|
case account
|
||
|
case status
|
||
|
}
|
||
|
}
|
||
|
|
||
|
extension Notification {
|
||
|
public enum Kind: String, Decodable {
|
||
|
case mention
|
||
|
case reblog
|
||
|
case favourite
|
||
|
case follow
|
||
|
}
|
||
|
}
|