BeginPackage["DeckOfCardsLink`"];ShuffleNewDeck[count_Integer : 1] := Enclose Replace Confirm@URLExecute "https://deckofcardsapi.com/api/deck/new/shuffle/", {"deck_count" -> count}, "RawJSON" , data : KeyValuePattern["success" -> True] :> data["deck_id"], data : KeyValuePattern["success" -> False] :> Failure["APIError", data["error"]] , "Expression"DrawCardsFromDeck[deck_String, count_Integer : 1] := Replace URLExecute "https://deckofcardsapi.com/api/deck/" <> deck <> "/draw/", {"count" -> count}, "RawJSON" , data : KeyValuePattern["success" -> True] :> Map <|"Value" -> #value, "Suit" -> #suit, "Image" -> Import[#image]|> &, data["cards"] , data : KeyValuePattern["success" -> False] :> Failure["APIError", data["error"]] ReturnCardsToDeck[deck_String, cards : {__String}] := Replace ImportByteArray URLRead HTTPRequest"https://deckofcardsapi.com/api/deck/" <> deck <> "/return/", <| "Query" -> {"cards" -> StringRiffle[cards, ","]} |> ["BodyByteArray"], "RawJSON" , data : KeyValuePattern["success" -> True] :> Success["ReturnedCards", <||>], data : KeyValuePattern["success" -> False] :> Failure["APIError", data["error"]] EndPackage[]