Skip to content

Commit

Permalink
Add currency parameter to store app details method (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
babelshift authored Mar 30, 2021
1 parent 9a71baf commit 9d725ab
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 9 deletions.
8 changes: 1 addition & 7 deletions src/Steam.Models/SteamStore/StoreAppDetailsDataModel.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Steam.Models.SteamStore
namespace Steam.Models.SteamStore
{
public class StoreAppDetailsDataModel
{
Expand Down
1 change: 1 addition & 0 deletions src/Steam.UnitTests/Steam.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<UserSecretsId>46a53f4e-b4d4-4fad-b7c9-b777001cfe42</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="automapper" Version="10.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="5.0.0" />
Expand Down
42 changes: 42 additions & 0 deletions src/Steam.UnitTests/SteamStoreTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using AutoMapper;
using SteamWebAPI2.Interfaces;
using SteamWebAPI2.Mappings;
using System.Threading.Tasks;
using Xunit;

namespace Steam.UnitTests
{
public class SteamStoreTests
{
private readonly SteamStore steamStore;

public SteamStoreTests()
{
var mapperConfig = new MapperConfiguration(config =>
{
config.AddProfile<SteamStoreProfile>();
});

var mapper = mapperConfig.CreateMapper();

steamStore = new SteamStore(mapper);
}

[Fact]
public async Task GetStoreAppDetailsAsync_Should_Succeed()
{
var response = await steamStore.GetStoreAppDetailsAsync(1086940);
Assert.NotNull(response);
Assert.NotNull(response.Name);
}

[Fact]
public async Task GetStoreAppDetailsAsync_WithCurrency_Should_Succeed()
{
var response = await steamStore.GetStoreAppDetailsAsync(1086940, "mx");
Assert.NotNull(response);
Assert.NotNull(response.PriceOverview?.Currency);
Assert.Equal("MXN", response.PriceOverview.Currency);
}
}
}
2 changes: 1 addition & 1 deletion src/SteamWebAPI2/Interfaces/ISteamStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace SteamWebAPI2.Interfaces
{
internal interface ISteamStore
{
Task<StoreAppDetailsDataModel> GetStoreAppDetailsAsync(uint appId);
Task<StoreAppDetailsDataModel> GetStoreAppDetailsAsync(uint appId, string cc = "");

Task<StoreFeaturedCategoriesModel> GetStoreFeaturedCategoriesAsync();

Expand Down
3 changes: 2 additions & 1 deletion src/SteamWebAPI2/Interfaces/SteamStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ public SteamStore(IMapper mapper, HttpClient httpClient) : base(mapper, httpClie
/// </summary>
/// <param name="appId"></param>
/// <returns></returns>
public async Task<StoreAppDetailsDataModel> GetStoreAppDetailsAsync(uint appId)
public async Task<StoreAppDetailsDataModel> GetStoreAppDetailsAsync(uint appId, string cc = "")
{
List<SteamWebRequestParameter> parameters = new List<SteamWebRequestParameter>();

parameters.AddIfHasValue(appId, "appids");
parameters.AddIfHasValue(cc, "cc");

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

Expand Down

0 comments on commit 9d725ab

Please sign in to comment.