Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions Sources/ScryfallKit/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
20 changes: 16 additions & 4 deletions Sources/ScryfallKit/Models/Card/Card.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scryfall's API docs don't list this as an optional field, have you seen cards where this property is nil?

/// 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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scryfall's API docs don't list this as an optional, have you seen cards where this property is nil?

/// True if this card has been printed before
public var reprint: Bool
/// Link to this card's set on Scryfall
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Sources/ScryfallKit/Models/Enums.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a header doc for this type

case oval, triangle, acorn, circle, arena, heart
}
4 changes: 2 additions & 2 deletions Sources/ScryfallKit/Networking/NetworkService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protocol NetworkServiceProtocol: Sendable {
as type: T.Type,
completion: @Sendable @escaping (Result<T, Error>) -> Void
)
@available(macOS 10.15.0, *, iOS 13.0.0, *)
@available(macOS 10.15.0, *, iOS 13.0.0, *, watchOS 11.0, *)
func request<T: Decodable>(_ request: EndpointRequest, as type: T.Type) async throws -> T
}

Expand Down Expand Up @@ -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<T: Decodable>(_ request: EndpointRequest, as type: T.Type) async throws -> T
where T: Sendable {
try await withCheckedThrowingContinuation { continuation in
Expand Down
2 changes: 1 addition & 1 deletion Sources/ScryfallKit/ScryfallClient+Async.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down