Skip to content

Commit 9d725ab

Browse files
author
Justin Skiles
authored
Add currency parameter to store app details method (#117)
1 parent 9a71baf commit 9d725ab

File tree

5 files changed

+47
-9
lines changed

5 files changed

+47
-9
lines changed

src/Steam.Models/SteamStore/StoreAppDetailsDataModel.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
6-
7-
namespace Steam.Models.SteamStore
1+
namespace Steam.Models.SteamStore
82
{
93
public class StoreAppDetailsDataModel
104
{

src/Steam.UnitTests/Steam.UnitTests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<UserSecretsId>46a53f4e-b4d4-4fad-b7c9-b777001cfe42</UserSecretsId>
77
</PropertyGroup>
88
<ItemGroup>
9+
<PackageReference Include="automapper" Version="10.1.1" />
910
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
1011
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
1112
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using AutoMapper;
2+
using SteamWebAPI2.Interfaces;
3+
using SteamWebAPI2.Mappings;
4+
using System.Threading.Tasks;
5+
using Xunit;
6+
7+
namespace Steam.UnitTests
8+
{
9+
public class SteamStoreTests
10+
{
11+
private readonly SteamStore steamStore;
12+
13+
public SteamStoreTests()
14+
{
15+
var mapperConfig = new MapperConfiguration(config =>
16+
{
17+
config.AddProfile<SteamStoreProfile>();
18+
});
19+
20+
var mapper = mapperConfig.CreateMapper();
21+
22+
steamStore = new SteamStore(mapper);
23+
}
24+
25+
[Fact]
26+
public async Task GetStoreAppDetailsAsync_Should_Succeed()
27+
{
28+
var response = await steamStore.GetStoreAppDetailsAsync(1086940);
29+
Assert.NotNull(response);
30+
Assert.NotNull(response.Name);
31+
}
32+
33+
[Fact]
34+
public async Task GetStoreAppDetailsAsync_WithCurrency_Should_Succeed()
35+
{
36+
var response = await steamStore.GetStoreAppDetailsAsync(1086940, "mx");
37+
Assert.NotNull(response);
38+
Assert.NotNull(response.PriceOverview?.Currency);
39+
Assert.Equal("MXN", response.PriceOverview.Currency);
40+
}
41+
}
42+
}

src/SteamWebAPI2/Interfaces/ISteamStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace SteamWebAPI2.Interfaces
55
{
66
internal interface ISteamStore
77
{
8-
Task<StoreAppDetailsDataModel> GetStoreAppDetailsAsync(uint appId);
8+
Task<StoreAppDetailsDataModel> GetStoreAppDetailsAsync(uint appId, string cc = "");
99

1010
Task<StoreFeaturedCategoriesModel> GetStoreFeaturedCategoriesAsync();
1111

src/SteamWebAPI2/Interfaces/SteamStore.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ public SteamStore(IMapper mapper, HttpClient httpClient) : base(mapper, httpClie
2323
/// </summary>
2424
/// <param name="appId"></param>
2525
/// <returns></returns>
26-
public async Task<StoreAppDetailsDataModel> GetStoreAppDetailsAsync(uint appId)
26+
public async Task<StoreAppDetailsDataModel> GetStoreAppDetailsAsync(uint appId, string cc = "")
2727
{
2828
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();
2929

3030
parameters.AddIfHasValue(appId, "appids");
31+
parameters.AddIfHasValue(cc, "cc");
3132

3233
var appDetails = await CallMethodAsync<AppDetailsContainer>("appdetails", parameters);
3334

0 commit comments

Comments
 (0)