From 845f413bd7bb48c4bed1650153a33bbaf184c941 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Fri, 19 Jan 2024 21:06:16 +0100 Subject: [PATCH] Make models public --- Sources/PentabarfKit/Models.swift | 82 ------------------- Sources/PentabarfKit/Models/Conference.swift | 27 ++++++ .../PentabarfKit/Models/ConferenceDay.swift | 17 ++++ Sources/PentabarfKit/Models/Event.swift | 26 ++++++ Sources/PentabarfKit/Models/Person.swift | 13 +++ Sources/PentabarfKit/Models/References.swift | 19 +++++ Sources/PentabarfKit/Models/Room.swift | 13 +++ Sources/PentabarfKit/Models/Track.swift | 15 ++++ Sources/PentabarfKit/PentabarfKit.swift | 2 +- 9 files changed, 131 insertions(+), 83 deletions(-) delete mode 100644 Sources/PentabarfKit/Models.swift create mode 100644 Sources/PentabarfKit/Models/Conference.swift create mode 100644 Sources/PentabarfKit/Models/ConferenceDay.swift create mode 100644 Sources/PentabarfKit/Models/Event.swift create mode 100644 Sources/PentabarfKit/Models/Person.swift create mode 100644 Sources/PentabarfKit/Models/References.swift create mode 100644 Sources/PentabarfKit/Models/Room.swift create mode 100644 Sources/PentabarfKit/Models/Track.swift diff --git a/Sources/PentabarfKit/Models.swift b/Sources/PentabarfKit/Models.swift deleted file mode 100644 index 955e307..0000000 --- a/Sources/PentabarfKit/Models.swift +++ /dev/null @@ -1,82 +0,0 @@ -// -// Models.swift -// -// -// Created by Sean Molenaar on 07/01/2024. -// - -import Foundation - -struct Conference { - static let elementname: String = "conference" - - let title: String - let subtitle: String? - - let venue: String - let city: String - - let start: Date - let end: Date - - let dayChange: String - let timeslotDuration: TimeInterval - - var tracks: [Track] = [] - var days: [ConferenceDay] = [] -} - -struct Track { - static let elementname: String = "tracks" - - let name: String - let metadata: [String: Any] -} - -struct ConferenceDay { - static let elementname: String = "day" - - let index: Int - let date: Date - let rooms: [Room] - -} - -struct Room { - let name: String - let events: [Event] -} - -struct Event { - let id: Int - let start: Date - let duration: TimeInterval - let room: String - let slug: String - let title: String - let subtitle: String? - let track: String - let type: String - let language: Locale - let abstract: String - let description: String - let authors: [Person] - let attachments: [Attachment] - let links: [Link] -} - -struct Person { - let id: Int - let name: String -} - -struct Attachment { - let title: String - let url: URL - let type: String -} - -struct Link { - let title: String - let url: URL -} diff --git a/Sources/PentabarfKit/Models/Conference.swift b/Sources/PentabarfKit/Models/Conference.swift new file mode 100644 index 0000000..703d7ca --- /dev/null +++ b/Sources/PentabarfKit/Models/Conference.swift @@ -0,0 +1,27 @@ +// +// Models.swift +// +// +// Created by Sean Molenaar on 07/01/2024. +// + +import Foundation + +public struct Conference { + static let elementname: String = "conference" + + public let title: String + public let subtitle: String? + + public let venue: String + public let city: String + + public let start: Date + public let end: Date + + public let dayChange: String + public let timeslotDuration: TimeInterval + + public var tracks: [Track] = [] + public var days: [ConferenceDay] = [] +} diff --git a/Sources/PentabarfKit/Models/ConferenceDay.swift b/Sources/PentabarfKit/Models/ConferenceDay.swift new file mode 100644 index 0000000..d15df0d --- /dev/null +++ b/Sources/PentabarfKit/Models/ConferenceDay.swift @@ -0,0 +1,17 @@ +// +// Models.swift +// +// +// Created by Sean Molenaar on 07/01/2024. +// + +import Foundation + +public struct ConferenceDay { + static let elementname: String = "day" + + public let index: Int + public let date: Date + public let rooms: [Room] + +} diff --git a/Sources/PentabarfKit/Models/Event.swift b/Sources/PentabarfKit/Models/Event.swift new file mode 100644 index 0000000..c2b651a --- /dev/null +++ b/Sources/PentabarfKit/Models/Event.swift @@ -0,0 +1,26 @@ +// +// Models.swift +// +// +// Created by Sean Molenaar on 07/01/2024. +// + +import Foundation + +public struct Event { + public let id: Int + public let start: Date + public let duration: TimeInterval + public let room: String + public let slug: String + public let title: String + public let subtitle: String? + public let track: String + public let type: String + public let language: Locale + public let abstract: String + public let description: String + public let authors: [Person] + public let attachments: [Attachment] + public let links: [Link] +} diff --git a/Sources/PentabarfKit/Models/Person.swift b/Sources/PentabarfKit/Models/Person.swift new file mode 100644 index 0000000..62cac08 --- /dev/null +++ b/Sources/PentabarfKit/Models/Person.swift @@ -0,0 +1,13 @@ +// +// Models.swift +// +// +// Created by Sean Molenaar on 07/01/2024. +// + +import Foundation + +public struct Person { + public let id: Int + public let name: String +} diff --git a/Sources/PentabarfKit/Models/References.swift b/Sources/PentabarfKit/Models/References.swift new file mode 100644 index 0000000..f20f84c --- /dev/null +++ b/Sources/PentabarfKit/Models/References.swift @@ -0,0 +1,19 @@ +// +// Models.swift +// +// +// Created by Sean Molenaar on 07/01/2024. +// + +import Foundation + +public struct Attachment { + public let title: String + public let url: URL + public let type: String +} + +public struct Link { + public let title: String + public let url: URL +} diff --git a/Sources/PentabarfKit/Models/Room.swift b/Sources/PentabarfKit/Models/Room.swift new file mode 100644 index 0000000..fc3f55b --- /dev/null +++ b/Sources/PentabarfKit/Models/Room.swift @@ -0,0 +1,13 @@ +// +// Models.swift +// +// +// Created by Sean Molenaar on 07/01/2024. +// + +import Foundation + +public struct Room { + public let name: String + public let events: [Event] +} diff --git a/Sources/PentabarfKit/Models/Track.swift b/Sources/PentabarfKit/Models/Track.swift new file mode 100644 index 0000000..9cfe126 --- /dev/null +++ b/Sources/PentabarfKit/Models/Track.swift @@ -0,0 +1,15 @@ +// +// Models.swift +// +// +// Created by Sean Molenaar on 07/01/2024. +// + +import Foundation + +public struct Track { + static let elementname: String = "tracks" + + public let name: String + public let metadata: [String: Any] +} diff --git a/Sources/PentabarfKit/PentabarfKit.swift b/Sources/PentabarfKit/PentabarfKit.swift index d79356b..a7b2bc4 100644 --- a/Sources/PentabarfKit/PentabarfKit.swift +++ b/Sources/PentabarfKit/PentabarfKit.swift @@ -8,7 +8,7 @@ import Foundation class PentabarfKit { - static func loadConference(_ url: URL) async throws -> Conference? { + public static func loadConference(_ url: URL) async throws -> Conference? { print("📲 Getting schedule: \(url)") let urlRequest = URLRequest(url: url) let (data, response) = try await URLSession.shared.data(for: urlRequest)