ScryfallKit

4.0.0

A Swift SDK for the Scryfall API
JacobHearst/ScryfallKit

What's New

v4.0.0: Namespace update + Documentation

2022-10-21T17:56:48Z

The largest change coming in this update is the new namespacing. All structs and enums related to the cards have been moved into extensions of the Card struct.

Breaking Changes

Renamed structs:

  • CardFace -> Card.Face
  • ImageURIs -> Card.ImageURIs
  • CardLegality -> Card.Legalities
  • ManaCost -> Card.ManaCost
  • Preview -> Card.Preview
  • CardPrices -> Card.Prices
  • RelatedCard -> Card.RelatedCard
  • Ruling -> Card.Ruling
  • CardSymbol -> Card.Symbol

Renamed enums:

  • CardColor -> Card.Color
  • Layout -> Card.Layout
  • Legality -> Card.Legality
  • BorderColor -> Card.BorderColor
  • Frame -> Card.Frame
  • FrameEffect -> Card.FrameEffect

Modified method signatures:

  • All method signatures using snake_case parameters have been updated to use camelCase. These functions are:
    • searchCards (both the query and filters variants)
    • getCardNameAutocomplete
  • Method signatures using backFace: Bool and version: Card.ImageType or similar have been modified to remove those parameters. These parameters are only relevant when requesting an image instead of a json object for a card which is not supported as of now. These functions are:
    • getRandomCard
    • getCard
    • Both variants of getCardByName

Documentation

Also included in this release is DocC style documentation for all public symbols! A web version of these will hopefully be available within the week

ScryfallKit

Build and test Swift Version Compatibility Platform Support

A Swift Package for accessing Scryfall's REST API

Getting Started

Add ScryfallKit to your project either through the Xcode UI, or through the process below for Swift Packages

let package = Package(
    // ... Other Package.swift stuff goes here
    dependencies: [
        .package(url: "https://github.com/JacobHearst/ScryfallKit", from: "4.0.0"), // Add the library to your manifest
    ],
    targets: [
        .target(name: "MyPackage", dependencies: ["ScryfallKit"]), // Add it to your target's dependencies
    ]
)

Example

import ScryfallKit

let client = ScryfallClient()

// Retrieve the Strixhaven Mystical Archive printing of Doom Blade
client.getCardByName(exact: "Doom Blade", set: "STA") { result in
    switch result {
    case .success(let doomBlade):
        print(doomBlade.cmc)
    case .failure(let error):
        print("Received error: \(error)")
    }
}

// Or using async
do {
    let doomBlade = try await client.getCardByName(exact: "Doom Blade", set: "STA")
    print(doomBlade.cmc)
} catch {
    print("Received error: \(error)")
}

Network Logging

The ScryfallClient has a configurable level of network logging with two options: minimal and verbose. Enabling verbose logging will print the HTTP body of each request and response. Minimal logging will log that a request was made (and the URL it's made to) as well as that a response was received.

Contributing

Contributions are always welcome, simply fork this repo, make and test your changes, and then open a pull request. I will try and review it within a reasonable amount of time.

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

Last updated: Wed Jan 25 2023 18:32:51 GMT-0500 (GMT-05:00)