Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.NET 8 Upgrade, Tests, API Updates
Browse files Browse the repository at this point in the history
Gonkers committed Feb 29, 2024
1 parent 4973130 commit cd60539
Showing 22 changed files with 792 additions and 353 deletions.
10 changes: 10 additions & 0 deletions ScryfallApi.sln
Original file line number Diff line number Diff line change
@@ -12,9 +12,14 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F938EC12-7230-41F9-A93F-44E9D4DCAF02}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B74CFA8C-2018-4BB0-BA22-5FE277A1E430}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScryfallApi.Client.Tests", "tests\ScryfallApi.Client.Tests\ScryfallApi.Client.Tests.csproj", "{8B9E4443-4432-4DE6-B1A4-D27967D04CDA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -29,12 +34,17 @@ Global
{383BF6C1-47B7-47E8-8428-B3A114EFC3B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{383BF6C1-47B7-47E8-8428-B3A114EFC3B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{383BF6C1-47B7-47E8-8428-B3A114EFC3B0}.Release|Any CPU.Build.0 = Release|Any CPU
{8B9E4443-4432-4DE6-B1A4-D27967D04CDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8B9E4443-4432-4DE6-B1A4-D27967D04CDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B9E4443-4432-4DE6-B1A4-D27967D04CDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B9E4443-4432-4DE6-B1A4-D27967D04CDA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{383BF6C1-47B7-47E8-8428-B3A114EFC3B0} = {C470746D-B24E-4759-B7A3-6C8EDD801544}
{8B9E4443-4432-4DE6-B1A4-D27967D04CDA} = {B74CFA8C-2018-4BB0-BA22-5FE277A1E430}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4C1168D1-1DC7-410F-9D8C-E23492A1FD2F}
8 changes: 2 additions & 6 deletions samples/ScryfallApi.WebSample/Pages/Cards.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -14,7 +10,7 @@ public class CardsModel : PageModel
{
private readonly ScryfallApiClient _scryfallApi;
public List<SelectListItem> SetList { get; set; }
public ICollection<Card> CardList { get; set; }
public IReadOnlyCollection<Card> CardList { get; set; }

public CardsModel(ScryfallApiClient scryfallApi)
{
@@ -33,7 +29,7 @@ public async Task<IActionResult> OnGet([FromQuery] string set)
CardList = (await _scryfallApi.Cards.Search($"e:{selectedItem.Value}", 1, SearchOptions.CardSort.Name)).Data;
}
else
CardList = new List<Card>();
CardList = [];

return Page();
}
2 changes: 1 addition & 1 deletion samples/ScryfallApi.WebSample/ScryfallApi.WebSample.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
2 changes: 1 addition & 1 deletion src/ScryfallApi.Client/Apis/Cards.cs
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ internal Cards(BaseRestService restService)
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public Task<ResultList<Card>> Get(int page) => _restService.GetAsync<ResultList<Card>>($"/cards?page={page}");

public Task<Card> GetRandom() => _restService.GetAsync<Card>($"/cards/random", false);
public Task<Card> GetRandom() => _restService.GetAsync<Card>("/cards/random", false);

public Task<ResultList<Card>> Search(string query, int page, CardSort sort) =>
Search(query, page, new SearchOptions { Sort = sort });
2 changes: 1 addition & 1 deletion src/ScryfallApi.Client/Apis/ISymbology.cs
Original file line number Diff line number Diff line change
@@ -18,5 +18,5 @@ public interface ISymbology
/// Parses the given mana cost parameter and returns Scryfall’s interpretation.
/// </summary>
/// <returns></returns>
Task<ManaCost> ParseMana(string cost);
Task<ParsedManaCost> ParseMana(string cost);
}
2 changes: 1 addition & 1 deletion src/ScryfallApi.Client/Apis/Symbology.cs
Original file line number Diff line number Diff line change
@@ -22,5 +22,5 @@ internal Symbology(BaseRestService restService)
/// Parses the given mana cost parameter and returns Scryfall’s interpretation.
/// </summary>
/// <returns></returns>
public Task<ManaCost> ParseMana(string cost) => _restService.GetAsync<ManaCost>("/symbology/parse-mana");
public Task<ParsedManaCost> ParseMana(string cost) => _restService.GetAsync<ParsedManaCost>("/symbology/parse-mana");
}
2 changes: 1 addition & 1 deletion src/ScryfallApi.Client/Models/BaseItem.cs
Original file line number Diff line number Diff line change
@@ -5,5 +5,5 @@ namespace ScryfallApi.Client.Models;
public abstract class BaseItem
{
[JsonPropertyName("object")]
public string ObjectType { get; set; }
public string ObjectType { get; init; }
}
64 changes: 41 additions & 23 deletions src/ScryfallApi.Client/Models/BulkDataItem.cs
Original file line number Diff line number Diff line change
@@ -2,15 +2,41 @@

namespace ScryfallApi.Client.Models;

/// <summary>
/// <para>Scryfall provides daily exports of our card data in bulk files. Each of these files is
/// represented as a bulk_data object via the API. URLs for files change their timestamp each day,
/// and can be fetched programmatically.</para>
/// <para>Please note:</para>
/// <para>Card objects in bulk data include price information, but prices should be considered
/// dangerously stale after 24 hours.Only use bulk price information to track trends or provide a
/// general estimate of card value.Prices are not updated frequently enough to power a storefront
/// or sales system. You consume price information at your own risk.</para>
/// <para>Updates to gameplay data (such as card names, Oracle text, mana costs, etc) are much less
/// frequent.If you only need gameplay information, downloading card data once per week or right
/// after set releases would most likely be sufficient.</para>
/// <para>Every card type in every product is included, including planar cards, schemes, Vanguard
/// cards, tokens, emblems, and funny cards.Make sure you’ve reviewed documentation for the Card
/// type.</para>
/// <para>Bulk data is only collected once every 12 hours.You can use the card API methods to
/// retrieve fresh objects instead.</para>
/// </summary>
public class BulkDataItem : BaseItem
{
/// <summary>The Content-Encoding encoding that will be used to transmit this file when you download it.</summary>
[JsonPropertyName("content_encoding")]
public string ContentEncoding { get; set; }
/// <summary>A unique ID for this bulk item.</summary>
[JsonPropertyName("id")]
public Guid Id { get; set; }

/// <summary>The MIME type of this file.</summary>
[JsonPropertyName("content_type")]
public string ContentType { get; set; }
/// <summary>The Scryfall API URI for this file.</summary>
[JsonPropertyName("uri")]
public Uri Uri { get; set; }

/// <summary>A computer-readable string for the kind of bulk item.</summary>
[JsonPropertyName("type")]
public string Type { get; set; }

/// <summary>A human-readable name for this file.</summary>
[JsonPropertyName("name")]
public string Name { get; set; }

/// <summary>A human-readable description for this file.</summary>
[JsonPropertyName("description")]
@@ -20,27 +46,19 @@ public class BulkDataItem : BaseItem
[JsonPropertyName("download_uri")]
public Uri DownloadUri { get; set; }

/// <summary>The size of this file in integer bytes.</summary>
[JsonPropertyName("compressed_size")]
public long FileSizeInBytes { get; set; }

/// <summary>A unique ID for this bulk item.</summary>
[JsonPropertyName("id")]
public Guid Id { get; set; }

/// <summary>The time when this file was last updated.</summary>
[JsonPropertyName("updated_at")]
public DateTimeOffset LastUpdated { get; set; }

/// <summary>A human-readable name for this file.</summary>
[JsonPropertyName("name")]
public string Name { get; set; }
/// <summary>The size of this file in integer bytes.</summary>
[JsonPropertyName("size")]
public long FileSizeInBytes { get; set; }

/// <summary>A computer-readable string for the kind of bulk item.</summary>
[JsonPropertyName("type")]
public string Type { get; set; }
/// <summary>The MIME type of this file.</summary>
[JsonPropertyName("content_type")]
public string ContentType { get; set; }

/// <summary>The Scryfall API URI for this file.</summary>
[JsonPropertyName("uri")]
public Uri Uri { get; set; }
/// <summary>The Content-Encoding encoding that will be used to transmit this file when you download it.</summary>
[JsonPropertyName("content_encoding")]
public string ContentEncoding { get; set; }
}
Loading

0 comments on commit cd60539

Please sign in to comment.