diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Activity.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Activity.swift new file mode 100644 index 000000000..e7bdb0b1c --- /dev/null +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Activity.swift @@ -0,0 +1,25 @@ +// +// Mastodon+Entity+Activity.swift +// +// +// Created by MainasuK Cirno on 2021/1/28. +// + +import Foundation + +extension Mastodon.Entity { + /// Activity + /// + /// - Since: 2.1.2 + /// - Version: 3.3.0 + /// # Last Update + /// 2021/1/28 + /// # Reference + /// [Document](https://docs.joinmastodon.org/entities/activity/) + public struct Activity: Codable { + public let week: Date + public let statuses: Int + public let logins: Int + public let registrations: Int + } +} diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Announcement.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Announcement.swift new file mode 100644 index 000000000..cc9b48a3d --- /dev/null +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Announcement.swift @@ -0,0 +1,52 @@ +// +// Mastodon+Entity+Announcement.swift +// +// +// Created by MainasuK Cirno on 2021/1/28. +// + +import Foundation + +extension Mastodon.Entity { + /// Announcement + /// + /// - Since: 3.1.0 + /// - Version: 3.3.0 + /// # Last Update + /// 2021/1/28 + /// # Reference + /// [Document](https://docs.joinmastodon.org/entities/announcement/) + public struct Announcement: Codable { + + public typealias ID = String + + // Base + public let id: ID + public let text: String + public let published: Bool? + public let allDay: Bool + public let createdAt: Date + public let updatedAt: Date + public let read: Bool + public let reactions: [AnnouncementReaction] + + public let scheduledAt: Date? + public let startsAt: Date? + public let endsAt: Date? + + enum CodingKeys: String, CodingKey { + case id + case text + case published + case allDay + case createdAt = "created_at" + case updatedAt = "updated_at" + case read + case reactions + + case scheduledAt = "scheduled_at" + case startsAt = "starts_at" + case endsAt + } + } +} diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+AnnouncementReaction.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+AnnouncementReaction.swift new file mode 100644 index 000000000..0261165fb --- /dev/null +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+AnnouncementReaction.swift @@ -0,0 +1,37 @@ +// +// Mastodon+Entity+AnnouncementReaction.swift +// +// +// Created by MainasuK Cirno on 2021/1/28. +// + +import Foundation + +extension Mastodon.Entity { + /// AnnouncementReaction + /// + /// - Since: 3.1.0 + /// - Version: 3.3.0 + /// # Last Update + /// 2021/1/28 + /// # Reference + /// [Document](https://docs.joinmastodon.org/entities/announcementreaction/) + public struct AnnouncementReaction: Codable { + // Base + public let name: String + public let count: Int + public let me: Bool + + // Custom Emoji + public let url: String? + public let staticURL: String? + + enum CodingKeys: String, CodingKey { + case name + case count + case me + case url + case staticURL = "static_url" + } + } +} diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Attachment.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Attachment.swift new file mode 100644 index 000000000..aad48fef4 --- /dev/null +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Attachment.swift @@ -0,0 +1,124 @@ +// +// Mastodon+Entity+Attachment.swift +// +// +// Created by MainasuK Cirno on 2021/1/28. +// + +import Foundation + +extension Mastodon.Entity { + /// Attachment + /// + /// - Since: 0.6.0 + /// - Version: 3.3.0 + /// # Last Update + /// 2021/1/28 + /// # Reference + /// [Document](https://docs.joinmastodon.org/entities/attachment/) + public struct Attachment: Codable { + + public typealias ID = String + + public let id: ID + public let type: Type? + public let url: String + public let previewURL: String + + public let remoteURL: String? + public let textURL: String? + public let meta: Meta? + public let description: String? + public let blurhash: String? + + enum CodingKeys: String, CodingKey { + case id + case type + case url + case previewURL = "preview_url" + + case remoteURL = "remote_url" + case textURL = "text_url" + case meta + case description + case blurhash + } + } +} + +extension Mastodon.Entity.Attachment { + public enum `Type`: String, Codable { + case unknown + case image + case gifv + case video + case audio + } +} + + +extension Mastodon.Entity.Attachment { + /// # Reference + /// https://github.com/tootsuite/mastodon/blob/v3.3.0/app/models/media_attachment.rb + public struct Meta: Codable { + public let original: Format? + public let small: Format? + public let focus: Focus? + + public let length: String? + public let duration: Double? + public let fps: Int? + public let size: String? + public let width: Int? + public let height: Int? + public let aspect: Double? + public let audioEncode: String? + public let audioBitrate: String? + public let audioChannels: String? + + enum CodingKeys: String, CodingKey { + case original + case small + case focus + + case length + case duration + case fps + case size + case width + case height + case aspect + case audioEncode = "audio_encode" + case audioBitrate = "audio_bitrate" + case audioChannels = "audio_channels" + } + + } +} + +extension Mastodon.Entity.Attachment.Meta { + public struct Format: Codable { + public let width: Int? + public let height: Int? + public let size: String? + public let aspect: Double? + public let frameRate: String? + public let duration: Double? + public let bitrate: Int? + + enum CodingKeys: String, CodingKey { + case width + case height + case size + case aspect + case frameRate = "frame_rate" + case duration + case bitrate + } + } + + public struct Focus: Codable { + public let x: Double + public let y: Double + } +} diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Context.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Context.swift new file mode 100644 index 000000000..ce996ab3f --- /dev/null +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Context.swift @@ -0,0 +1,23 @@ +// +// Mastodon+Entity+Context.swift +// +// +// Created by MainasuK Cirno on 2021/1/28. +// + +import Foundation + +extension Mastodon.Entity { + /// Context + /// + /// - Since: 0.6.0 + /// - Version: 3.3.0 + /// # Last Update + /// 2021/1/28 + /// # Reference + /// [Document](https://docs.joinmastodon.org/entities/context/) + public struct Context: Codable { + public let ancestors: [Status] + public let descendants: [Status] + } +} diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Conversation.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Conversation.swift new file mode 100644 index 000000000..51662f91c --- /dev/null +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Conversation.swift @@ -0,0 +1,36 @@ +// +// Mastodon+Entity+Conversation.swift +// +// +// Created by MainasuK Cirno on 2021/1/28. +// + +import Foundation + +extension Mastodon.Entity { + /// Conversation + /// + /// - Since: 2.6.0 + /// - Version: 3.3.0 + /// # Last Update + /// 2021/1/28 + /// # Reference + /// [Document](https://docs.joinmastodon.org/entities/conversation/) + public struct Conversation: Codable { + public typealias ID = String + + public let id: ID + public let accounts: [Account] + public let unread: Bool + + public let lastStatus: Status? + + enum CodingKeys: String, CodingKey { + case id + case accounts + case unread + + case lastStatus = "last_status" + } + } +} diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+FeaturedTag.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+FeaturedTag.swift new file mode 100644 index 000000000..cdc592121 --- /dev/null +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+FeaturedTag.swift @@ -0,0 +1,36 @@ +// +// Mastodon+Entity+FeaturedTag.swift +// +// +// Created by MainasuK Cirno on 2021/1/28. +// + +import Foundation + +extension Mastodon.Entity { + /// FeaturedTag + /// + /// - Since: 3.0.0 + /// - Version: 3.3.0 + /// # Last Update + /// 2021/1/28 + /// # Reference + /// [Document](https://docs.joinmastodon.org/entities/featuredtag/) + public struct FeaturedTag: Codable { + public typealias ID = String + + public let id: ID + public let name: String + public let url: String? + public let statusesCount: Int + public let lastStatusAt: Date + + enum CodingKeys: String, CodingKey { + case id + case name + case url + case statusesCount = "statuses_count" + case lastStatusAt = "last_status_at" + } + } +} diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Filter.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Filter.swift new file mode 100644 index 000000000..36cee2c15 --- /dev/null +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Filter.swift @@ -0,0 +1,47 @@ +// +// Mastodon+Entity+Filter.swift +// +// +// Created by MainasuK Cirno on 2021/1/28. +// + +import Foundation + +extension Mastodon.Entity { + /// Field + /// + /// - Since: 2.4.3 + /// - Version: 3.3.0 + /// # Last Update + /// 2021/1/28 + /// # Reference + /// [Document](https://docs.joinmastodon.org/entities/filter/) + public struct Filter: Codable { + public typealias ID = String + + public let id: ID + public let phrase: String + public let context: [Context?] + public let expiresAt: Date + public let irreversible: Bool + public let wholeWord: Bool + + enum CodingKeys: String, CodingKey { + case id + case phrase + case context + case expiresAt = "expires_at" + case irreversible + case wholeWord = "whole_word" + } + } +} + +extension Mastodon.Entity.Filter { + public enum Context: String, Codable { + case home + case notifications + case `public` + case thread + } +} diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+IdentityProof.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+IdentityProof.swift new file mode 100644 index 000000000..cc2046ee6 --- /dev/null +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+IdentityProof.swift @@ -0,0 +1,34 @@ +// +// Mastodon+Entity+IdentityProof.swift +// +// +// Created by MainasuK Cirno on 2021/1/28. +// + +import Foundation + +extension Mastodon.Entity { + /// IdentityProof + /// + /// - Since: 2.8.0 + /// - Version: 3.3.0 + /// # Last Update + /// 2021/1/28 + /// # Reference + /// [Document](https://docs.joinmastodon.org/entities/identityproof/) + public struct IdentityProof: Codable { + public let provider: String + public let providerUsername: String + public let profileURL: String + public let proofURL: String + public let updatedAt: Date + + enum CodingKeys: String, CodingKey { + case provider = "provider" + case providerUsername = "provider_username" + case profileURL = "profile_url" + case proofURL = "proof_url" + case updatedAt = "updated_at" + } + } +} diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+List.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+List.swift new file mode 100644 index 000000000..b9e3ba3b8 --- /dev/null +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+List.swift @@ -0,0 +1,40 @@ +// +// Mastodon+Entity+List.swift +// +// +// Created by MainasuK Cirno on 2021/1/28. +// + +import Foundation + +extension Mastodon.Entity { + /// List + /// + /// - Since: 2.1.0 + /// - Version: 3.3.0 + /// # Last Update + /// 2021/1/28 + /// # Reference + /// [Document](https://docs.joinmastodon.org/entities/list/) + public struct List: Codable { + public typealias ID = String + + public let id: ID + public let title: String + public let repliesPolicy: ReplyPolicy? + + enum CodingKeys: String, CodingKey { + case id + case title + case repliesPolicy = "replies_policy" + } + } +} + +extension Mastodon.Entity { + public enum ReplyPolicy: String, Codable { + case followed + case list + case none + } +} diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Media.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Media.swift new file mode 100644 index 000000000..5257f078a --- /dev/null +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Media.swift @@ -0,0 +1,12 @@ +// +// Mastodon+Entity+Media.swift +// +// +// Created by MainasuK Cirno on 2021/1/28. +// + +import Foundation + +extension Mastodon.Entity { + +} diff --git a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Status.swift b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Status.swift index 7fa3f0cb4..9479f20a1 100644 --- a/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Status.swift +++ b/MastodonSDK/Sources/MastodonSDK/Entity/Mastodon+Entity+Status.swift @@ -31,9 +31,10 @@ extension Mastodon.Entity { public let account: Account public let content: String - public let visibility: String? + public let visibility: Visibility? public let sensitive: Bool? public let spoilerText: String? + public let mediaAttachments: [Attachment] public let application: Application? // Rendering @@ -73,6 +74,7 @@ extension Mastodon.Entity { case visibility case sensitive case spoilerText = "spoiler_text" + case mediaAttachments = "media_attachments" case application case mentions