From b9296e6024479160384aa9f96f80201c57209f9d Mon Sep 17 00:00:00 2001 From: isaced Date: Sat, 13 Aug 2022 17:39:32 +0800 Subject: [PATCH] fix object type --- Sources/V2exAPI/Models/V2Token.swift | 22 +++++++++++----------- Sources/V2exAPI/Models/V2Topic.swift | 22 ++++++++++++++++------ 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Sources/V2exAPI/Models/V2Token.swift b/Sources/V2exAPI/Models/V2Token.swift index 01f72f1..5e21970 100644 --- a/Sources/V2exAPI/Models/V2Token.swift +++ b/Sources/V2exAPI/Models/V2Token.swift @@ -11,15 +11,15 @@ import Foundation Token */ public struct V2Token: Decodable { - let token, scope: String - let expiration, goodForDays, totalUsed, lastUsed: Int - let created: Int - - enum CodingKeys: String, CodingKey { - case token, scope, expiration - case goodForDays = "good_for_days" - case totalUsed = "total_used" - case lastUsed = "last_used" - case created - } + public let token, scope: String? + public let expiration, goodForDays, totalUsed, lastUsed: Int? + public let created: Int? + + enum CodingKeys: String, CodingKey { + case token, scope, expiration + case goodForDays = "good_for_days" + case totalUsed = "total_used" + case lastUsed = "last_used" + case created + } } diff --git a/Sources/V2exAPI/Models/V2Topic.swift b/Sources/V2exAPI/Models/V2Topic.swift index 466c548..887ed51 100644 --- a/Sources/V2exAPI/Models/V2Topic.swift +++ b/Sources/V2exAPI/Models/V2Topic.swift @@ -9,7 +9,7 @@ import Foundation /// 话题 public struct V2Topic: Identifiable, Decodable { - + public let id: Int public let node: V2Node? public let member: V2Member? @@ -23,11 +23,21 @@ public struct V2Topic: Identifiable, Decodable { public let contentRendered: String? public let lastModified: Int? public let replies: Int? - + public init( - id: Int, node: V2Node? = nil, member: V2Member? = nil, lastReplyBy: String?, lastTouched: Int?, - title: String?, url: String?, created: Int?, deleted: Int?, content: String?, - contentRendered: String?, lastModified: Int?, replies: Int? + id: Int, + node: V2Node? = nil, + member: V2Member? = nil, + lastReplyBy: String? = nil, + lastTouched: Int? = nil, + title: String? = nil, + url: String? = nil, + created: Int? = nil, + deleted: Int? = nil, + content: String? = nil, + contentRendered: String? = nil, + lastModified: Int? = nil, + replies: Int? = nil ) { self.id = id self.node = node @@ -43,7 +53,7 @@ public struct V2Topic: Identifiable, Decodable { self.lastModified = lastModified self.replies = replies } - + enum CodingKeys: String, CodingKey { case node, member case lastReplyBy = "last_reply_by"