Skip to content

Commit

Permalink
Fix Prices (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmbowdish authored Jul 2, 2019
1 parent a6656f7 commit f5dd752
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
40 changes: 31 additions & 9 deletions Sources/Swiftfall/Swiftfall.swift
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,37 @@ public class Swiftfall {
}
}

public struct Prices: Codable, CustomStringConvertible {

public let usd: String?

public let usd_foil: String?

public let eur: String?

public let tix: String?

public var description: String {
var text = ""
if self.usd != nil {
text += "usd: \(usd)"
}
if self.usd_foil != nil {
text += "usd_foil: \(usd_foil)"
}
if self.eur != nil {
text += "usd: \(eur)"
}
if self.tix != nil {
text += "usd: \(tix)"
}
return text
}

}

public let prices: Prices?

// A unique ID for this card in Scryfall’s database.
public let id: String

Expand Down Expand Up @@ -412,15 +443,6 @@ public class Swiftfall {
// A URL to this cards’s story article, if any.
public let story_spotlight_uri: String?

// Cost of the card in USD
public let usd: String?

// Cost of the card in tickets
public let tix: String?

// Cost of the card in euros
public let eur: String?

// return string when self is used as a parameter for print
public var description: String {
var text = ""
Expand Down
9 changes: 9 additions & 0 deletions Tests/Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,15 @@ class Tests: XCTestCase {
}
}

func testPrices() throws {
do {
_ = try Swiftfall.getCard(fuzzy: "Brainstorm")
} catch {
print(error)
XCTFail()
}
}

func testPerformanceExample() throws {
// This is an example of a performance test case.
self.measure {
Expand Down

0 comments on commit f5dd752

Please sign in to comment.