Reorganized file structure, added featured endpoint.
This commit is contained in:
parent
dd39c19c84
commit
0b8ec19632
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
public class Achievements
|
||||
{
|
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
public class Category
|
||||
{
|
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
public class Genre
|
||||
{
|
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
public class Highlighted
|
||||
{
|
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
public class LinuxRequirements
|
||||
{
|
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
public class MacRequirements
|
||||
{
|
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
public class Movie
|
||||
{
|
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
|
||||
public class PackageGroup
|
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
public class PcRequirements
|
||||
{
|
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
public class Platforms
|
||||
{
|
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
public class PriceOverview
|
||||
{
|
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
public class Recommendations
|
||||
{
|
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
public class ReleaseDate
|
||||
{
|
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
|
||||
public class Screenshot
|
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
|
||||
public class Sub
|
@ -7,7 +7,7 @@ using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
public class SupportInfo
|
||||
{
|
65
SteamStorefrontAPI/Classes/featured/FeaturedApp.cs
Normal file
65
SteamStorefrontAPI/Classes/featured/FeaturedApp.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
public class FeaturedApp
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public long Id { get; set; }
|
||||
|
||||
[JsonProperty("type")]
|
||||
public long Type { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("discounted")]
|
||||
public bool Discounted { get; set; }
|
||||
|
||||
[JsonProperty("discount_percent")]
|
||||
public long DiscountPercent { get; set; }
|
||||
|
||||
[JsonProperty("original_price")]
|
||||
public long? OriginalPrice { get; set; }
|
||||
|
||||
[JsonProperty("final_price")]
|
||||
public long FinalPrice { get; set; }
|
||||
|
||||
[JsonProperty("currency")]
|
||||
public Currency Currency { get; set; }
|
||||
|
||||
[JsonProperty("large_capsule_image")]
|
||||
public string LargeCapsuleImage { get; set; }
|
||||
|
||||
[JsonProperty("small_capsule_image")]
|
||||
public string SmallCapsuleImage { get; set; }
|
||||
|
||||
[JsonProperty("windows_available")]
|
||||
public bool WindowsAvailable { get; set; }
|
||||
|
||||
[JsonProperty("mac_available")]
|
||||
public bool MacAvailable { get; set; }
|
||||
|
||||
[JsonProperty("linux_available")]
|
||||
public bool LinuxAvailable { get; set; }
|
||||
|
||||
[JsonProperty("streamingvideo_available")]
|
||||
public bool StreamingvideoAvailable { get; set; }
|
||||
|
||||
[JsonProperty("header_image")]
|
||||
public string HeaderImage { get; set; }
|
||||
|
||||
[JsonProperty("discount_expiration", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public long? DiscountExpiration { get; set; }
|
||||
|
||||
[JsonProperty("controller_support", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public ControllerSupport? ControllerSupport { get; set; }
|
||||
}
|
||||
}
|
110
SteamStorefrontAPI/Classes/featured/SteamFeatured.cs
Normal file
110
SteamStorefrontAPI/Classes/featured/SteamFeatured.cs
Normal file
@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Globalization;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SteamStorefrontAPI.Classes
|
||||
{
|
||||
public class SteamFeatured
|
||||
{
|
||||
[JsonProperty("large_capsules")]
|
||||
public List<object> LargeCapsules { get; set; }
|
||||
|
||||
[JsonProperty("featured_win")]
|
||||
public List<FeaturedApp> FeaturedWin { get; set; }
|
||||
|
||||
[JsonProperty("featured_mac")]
|
||||
public List<FeaturedApp> FeaturedMac { get; set; }
|
||||
|
||||
[JsonProperty("featured_linux")]
|
||||
public List<FeaturedApp> FeaturedLinux { get; set; }
|
||||
|
||||
[JsonProperty("layout")]
|
||||
public string Layout { get; set; }
|
||||
|
||||
[JsonProperty("status")]
|
||||
public long Status { get; set; }
|
||||
|
||||
public static SteamFeatured FromJson(string json) => JsonConvert.DeserializeObject<SteamFeatured>(json, Converter.Settings);
|
||||
}
|
||||
|
||||
|
||||
public enum ControllerSupport { Full };
|
||||
|
||||
public enum Currency { Eur };
|
||||
|
||||
public static class Serialize
|
||||
{
|
||||
public static string ToJson(this SteamFeatured self) => JsonConvert.SerializeObject(self, Converter.Settings);
|
||||
}
|
||||
|
||||
static class Converter
|
||||
{
|
||||
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
|
||||
{
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
|
||||
DateParseHandling = DateParseHandling.None,
|
||||
Converters = {
|
||||
new ControllerSupportConverter(),
|
||||
new CurrencyConverter(),
|
||||
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
internal class ControllerSupportConverter : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type t) => t == typeof(ControllerSupport) || t == typeof(ControllerSupport?);
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.TokenType == JsonToken.Null) return null;
|
||||
var value = serializer.Deserialize<string>(reader);
|
||||
if (value == "full")
|
||||
{
|
||||
return ControllerSupport.Full;
|
||||
}
|
||||
throw new Exception("Cannot unmarshal type ControllerSupport");
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
|
||||
{
|
||||
var value = (ControllerSupport)untypedValue;
|
||||
if (value == ControllerSupport.Full)
|
||||
{
|
||||
serializer.Serialize(writer, "full"); return;
|
||||
}
|
||||
throw new Exception("Cannot marshal type ControllerSupport");
|
||||
}
|
||||
}
|
||||
|
||||
internal class CurrencyConverter : JsonConverter
|
||||
{
|
||||
public override bool CanConvert(Type t) => t == typeof(Currency) || t == typeof(Currency?);
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type t, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.TokenType == JsonToken.Null) return null;
|
||||
var value = serializer.Deserialize<string>(reader);
|
||||
if (value == "EUR")
|
||||
{
|
||||
return Currency.Eur;
|
||||
}
|
||||
throw new Exception("Cannot unmarshal type Currency");
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object untypedValue, JsonSerializer serializer)
|
||||
{
|
||||
var value = (Currency)untypedValue;
|
||||
if (value == Currency.Eur)
|
||||
{
|
||||
serializer.Serialize(writer, "EUR"); return;
|
||||
}
|
||||
throw new Exception("Cannot marshal type Currency");
|
||||
}
|
||||
}
|
||||
}
|
@ -43,25 +43,27 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="appdetails\AppDetails.cs" />
|
||||
<Compile Include="appdetails\Classes\LinuxRequirements.cs" />
|
||||
<Compile Include="appdetails\Classes\MacRequirements.cs" />
|
||||
<Compile Include="appdetails\Classes\ReleaseDate.cs" />
|
||||
<Compile Include="appdetails\Classes\Recommendations.cs" />
|
||||
<Compile Include="appdetails\Classes\PriceOverview.cs" />
|
||||
<Compile Include="appdetails\Classes\Platforms.cs" />
|
||||
<Compile Include="appdetails\Classes\PcRequirements.cs" />
|
||||
<Compile Include="appdetails\Classes\PackageGroup.cs" />
|
||||
<Compile Include="appdetails\Classes\Movie.cs" />
|
||||
<Compile Include="appdetails\Classes\Genre.cs" />
|
||||
<Compile Include="appdetails\Classes\Category.cs" />
|
||||
<Compile Include="appdetails\Classes\Highlighted.cs" />
|
||||
<Compile Include="appdetails\Classes\Achievements.cs" />
|
||||
<Compile Include="appdetails\Classes\Sub.cs" />
|
||||
<Compile Include="appdetails\Classes\SupportInfo.cs" />
|
||||
<Compile Include="appdetails\Classes\Screenshot.cs" />
|
||||
<Compile Include="Endpoints\AppDetails.cs" />
|
||||
<Compile Include="Classes\appdetails\LinuxRequirements.cs" />
|
||||
<Compile Include="Classes\appdetails\MacRequirements.cs" />
|
||||
<Compile Include="Classes\appdetails\ReleaseDate.cs" />
|
||||
<Compile Include="Classes\appdetails\Recommendations.cs" />
|
||||
<Compile Include="Classes\appdetails\PriceOverview.cs" />
|
||||
<Compile Include="Classes\appdetails\Platforms.cs" />
|
||||
<Compile Include="Classes\appdetails\PcRequirements.cs" />
|
||||
<Compile Include="Classes\appdetails\PackageGroup.cs" />
|
||||
<Compile Include="Classes\appdetails\Movie.cs" />
|
||||
<Compile Include="Classes\appdetails\Genre.cs" />
|
||||
<Compile Include="Classes\appdetails\Category.cs" />
|
||||
<Compile Include="Classes\appdetails\Highlighted.cs" />
|
||||
<Compile Include="Classes\appdetails\Achievements.cs" />
|
||||
<Compile Include="Classes\featured\FeaturedApp.cs" />
|
||||
<Compile Include="Classes\featured\SteamFeatured.cs" />
|
||||
<Compile Include="Classes\appdetails\Sub.cs" />
|
||||
<Compile Include="Classes\appdetails\SupportInfo.cs" />
|
||||
<Compile Include="Classes\appdetails\Screenshot.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="appdetails\Classes\SteamApp.cs" />
|
||||
<Compile Include="Classes\appdetails\SteamApp.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
@ -19,9 +19,9 @@ namespace SteamStorefrontConsole
|
||||
|
||||
static async Task GetGame()
|
||||
{
|
||||
//var steamApp = Task.Run(async () => await AppDetails.GetAsync(637670)).Result;
|
||||
var steamApp = Task.Run(async () => await AppDetails.GetAsync(637670)).Result;
|
||||
//var steamApp = Task.Run(async () => await AppDetails.GetAsync(443790)).Result;
|
||||
var steamApp = await AppDetails.GetAsync(213670);
|
||||
//var steamApp = await AppDetails.GetAsync(460810, "JP");
|
||||
|
||||
Console.WriteLine(steamApp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user