Added checking for the correct type

This commit is contained in:
2025-08-14 23:44:08 +01:00
parent 906aaa1e59
commit 6d21f5e496

View File

@@ -1,5 +1,5 @@
use chrono::NaiveDate;
use serde::Deserialize;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::fs;
use std::io::{Read, Seek, SeekFrom, Write};
@@ -30,7 +30,7 @@ struct ScryfallBulk {
pub data: Vec<ScryfallBulkData>,
}
#[derive(Deserialize, PartialEq, Debug)]
#[derive(Deserialize, Serialize, PartialEq, Debug)]
pub enum ScryfallBulkType {
#[serde(rename = "oracle_cards")]
OracleCards,
@@ -47,7 +47,7 @@ pub enum ScryfallBulkType {
const SCRYFALL_BULK_API: &str = "https://api.scryfall.com/bulk-data";
pub fn download_latest(
_stype: ScryfallBulkType,
stype: ScryfallBulkType,
mut dest_file: &NamedTempFile,
) -> Result<(), Box<dyn std::error::Error>> {
let bulk_body: ScryfallBulk = ureq::get(SCRYFALL_BULK_API)
@@ -59,13 +59,11 @@ pub fn download_latest(
let mut download_uri = String::new();
for scryfall_bulk in bulk_body.data {
// TODO: Actually implement getting different types
if scryfall_bulk.stype == "oracle_cards" {
if serde_json::to_string(&stype).unwrap() == scryfall_bulk.stype {
download_uri = scryfall_bulk.download_uri;
}
}
assert!(!download_uri.is_empty());
let cards_response = ureq::get(download_uri)
.header("User-Agent", "Arthur's Card Finger Testing v0.1")
.header("Accept", "application/json")