diff --git a/Package.swift b/Package.swift index 97fe625..a1b7694 100644 --- a/Package.swift +++ b/Package.swift @@ -5,7 +5,7 @@ import PackageDescription let package = Package( name: "ScryfallKit", - platforms: [.macOS(.v10_13), .iOS(.v12)], + platforms: [.macOS(.v10_13), .iOS(.v12), .watchOS(.v11)], products: [ .library( name: "ScryfallKit", diff --git a/Sources/ScryfallKit/Logger.swift b/Sources/ScryfallKit/Logger.swift index d070490..f065328 100644 --- a/Sources/ScryfallKit/Logger.swift +++ b/Sources/ScryfallKit/Logger.swift @@ -7,6 +7,8 @@ import OSLog @available(macOS 11.0, *) @available(iOS 14.0, *) +@available(watchOS 11.0, *) + extension Logger { static let subsystem = "dev.hearst.scryfallkit" static let main = Logger(subsystem: subsystem, category: "ScryfallKit") diff --git a/Sources/ScryfallKit/Models/Card/Card.swift b/Sources/ScryfallKit/Models/Card/Card.swift index 306c1e1..916ddbc 100644 --- a/Sources/ScryfallKit/Models/Card/Card.swift +++ b/Sources/ScryfallKit/Models/Card/Card.swift @@ -33,7 +33,7 @@ public struct Card: Codable, Identifiable, Hashable, Sendable { /// The language that this specific printing was printed in public var lang: String /// A link to where you can begin paginating all re/prints for this card on Scryfall’s API. - public var printsSearchUri: String + public var printsSearchUri: String? /// A link to this card’s rulings list on Scryfall’s API. public var rulingsUri: String /// A link to this card’s permapage on Scryfall’s website. @@ -100,6 +100,8 @@ public struct Card: Codable, Identifiable, Hashable, Sendable { // MARK: Print fields /// The name of the artist who illustrated this card public var artist: String? + /// An array of IDs that map to the artists who illustrated the card + public var artistIds: [String]? /// True if this card was printed in booster packs public var booster: Bool /// The color of this card's border @@ -127,6 +129,8 @@ public struct Card: Codable, Identifiable, Hashable, Sendable { public var frame: Frame /// True if this card's art is larger than normal public var fullArt: Bool + /// A description of what security stamp the card has - for Unfinity cards, will be "acorn", for normal rares, "oval" + public var securityStamp: SecurityStamp? /// An array of the games this card has been released in public var games: [Game] /// True if Scryfall has a high-res image of this card @@ -156,7 +160,7 @@ public struct Card: Codable, Identifiable, Hashable, Sendable { /// A dictionary of links to other MTG resources public var relatedUris: [String: String] /// This card's release date - public var releasedAt: String + public var releasedAt: String? /// True if this card has been printed before public var reprint: Bool /// Link to this card's set on Scryfall @@ -169,6 +173,8 @@ public struct Card: Codable, Identifiable, Hashable, Sendable { public var setType: MTGSet.`Type` /// A link to this card's set object on the Scryfall API public var setUri: String + /// A unique ID that identifies what set the card came from. + public var setId: String /// This card's set code public var set: String /// True if this was a story spotlight card @@ -196,7 +202,7 @@ public struct Card: Codable, Identifiable, Hashable, Sendable { id: UUID, oracleId: String, lang: String, - printsSearchUri: String, + printsSearchUri: String? = nil, rulingsUri: String, scryfallUri: String, uri: String, @@ -223,6 +229,7 @@ public struct Card: Codable, Identifiable, Hashable, Sendable { toughness: String? = nil, typeLine: String? = nil, artist: String? = nil, + artistIds: [String]? = nil, booster: Bool, borderColor: BorderColor, cardBackId: UUID? = nil, @@ -235,6 +242,7 @@ public struct Card: Codable, Identifiable, Hashable, Sendable { frameEffects: [FrameEffect]? = nil, frame: Frame, fullArt: Bool, + securityStamp: SecurityStamp? = nil, games: [Game], highresImage: Bool, illustrationId: UUID? = nil, @@ -249,13 +257,14 @@ public struct Card: Codable, Identifiable, Hashable, Sendable { purchaseUris: [String: String]? = nil, rarity: Card.Rarity, relatedUris: [String: String], - releasedAt: String, + releasedAt: String? = nil, reprint: Bool, scryfallSetUri: String, setName: String, setSearchUri: URL, setType: MTGSet.`Type`, setUri: String, + setId: String, set: String, storySpotlight: Bool, textless: Bool, @@ -301,6 +310,7 @@ public struct Card: Codable, Identifiable, Hashable, Sendable { self.toughness = toughness self.typeLine = typeLine self.artist = artist + self.artistIds = artistIds self.booster = booster self.borderColor = borderColor self.cardBackId = cardBackId @@ -313,6 +323,7 @@ public struct Card: Codable, Identifiable, Hashable, Sendable { self.frameEffects = frameEffects self.frame = frame self.fullArt = fullArt + self.securityStamp = securityStamp self.games = games self.highresImage = highresImage self.illustrationId = illustrationId @@ -334,6 +345,7 @@ public struct Card: Codable, Identifiable, Hashable, Sendable { self.setSearchUri = setSearchUri self.setType = setType self.setUri = setUri + self.setId = setId self.set = set self.storySpotlight = storySpotlight self.textless = textless diff --git a/Sources/ScryfallKit/Models/Enums.swift b/Sources/ScryfallKit/Models/Enums.swift index b2b09c1..6604228 100644 --- a/Sources/ScryfallKit/Models/Enums.swift +++ b/Sources/ScryfallKit/Models/Enums.swift @@ -39,3 +39,7 @@ public enum Format: String, CaseIterable, Sendable { public enum Currency: String, CaseIterable, Sendable { case usd, eur, tix, usdFoil, usdEtched } + +public enum SecurityStamp: String, Codable, Sendable { + case oval, triangle, acorn, circle, arena, heart +} diff --git a/Sources/ScryfallKit/Networking/NetworkService.swift b/Sources/ScryfallKit/Networking/NetworkService.swift index 892fec0..3639eaf 100644 --- a/Sources/ScryfallKit/Networking/NetworkService.swift +++ b/Sources/ScryfallKit/Networking/NetworkService.swift @@ -19,7 +19,7 @@ protocol NetworkServiceProtocol: Sendable { as type: T.Type, completion: @Sendable @escaping (Result) -> Void ) - @available(macOS 10.15.0, *, iOS 13.0.0, *) + @available(macOS 10.15.0, *, iOS 13.0.0, *, watchOS 11.0, *) func request(_ request: EndpointRequest, as type: T.Type) async throws -> T } @@ -104,7 +104,7 @@ struct NetworkService: NetworkServiceProtocol, Sendable { } } - @available(macOS 10.15.0, *, iOS 13.0.0, *) + @available(macOS 10.15.0, *, iOS 13.0.0, *, watchOS 11.0, *) func request(_ request: EndpointRequest, as type: T.Type) async throws -> T where T: Sendable { try await withCheckedThrowingContinuation { continuation in diff --git a/Sources/ScryfallKit/ScryfallClient+Async.swift b/Sources/ScryfallKit/ScryfallClient+Async.swift index 6b69232..8e50fce 100644 --- a/Sources/ScryfallKit/ScryfallClient+Async.swift +++ b/Sources/ScryfallKit/ScryfallClient+Async.swift @@ -4,7 +4,7 @@ import Foundation -@available(macOS 10.15.0, *, iOS 13.0.0, *) +@available(macOS 10.15.0, *, iOS 13.0.0, *, watchOS 11.0, *) extension ScryfallClient { /// Equivalent to ``searchCards(filters:unique:order:sortDirection:includeExtras:includeMultilingual:includeVariations:page:completion:)`` but with async/await syntax public func searchCards(