Skip to content

Commit

Permalink
URI Properties for Large, Small, and Logo Images on CarAssetDetail
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianJSClark committed Jul 14, 2024
1 parent e14ebf3 commit f3a0bbf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,25 @@ public async Task GetCarAssetDetailsSuccessfulAsync()

var carAssets = await sut.GetCarAssetDetailsAsync().ConfigureAwait(false);

Assert.That(carAssets, Is.Not.Null);
Assert.That(carAssets!.Data, Is.Not.Null);

Assert.That(carAssets.Data, Has.Count.EqualTo(159));
Assert.That(carAssets.RateLimitRemaining, Is.EqualTo(99));
Assert.That(carAssets.TotalRateLimit, Is.EqualTo(100));
Assert.That(carAssets.RateLimitReset, Is.EqualTo(new DateTimeOffset(2022, 2, 10, 0, 0, 0, TimeSpan.Zero)));
Assert.That(carAssets.DataExpires, Is.EqualTo(new DateTimeOffset(2022, 8, 27, 11, 23, 19, 507, TimeSpan.Zero)));
Assert.Multiple(() =>
{
Assert.That(carAssets, Is.Not.Null);
Assert.That(carAssets!.Data, Is.Not.Null);

Assert.That(carAssets.Data, Has.Count.EqualTo(159));

Assert.That(carAssets.Data, Contains.Key("161"));
var mercedesAmgW13 = carAssets.Data["161"];
Assert.That(mercedesAmgW13.CarId, Is.EqualTo(161));
Assert.That(mercedesAmgW13.LogoUri, Is.EqualTo(new Uri("https://images-static.iracing.com/img/logos/partners/mercedes-logo.png")));
Assert.That(mercedesAmgW13.LargeImageUri, Is.EqualTo(new Uri("https://images-static.iracing.com/img/cars/mercedesw13/mercedesw13-large.jpg")));
Assert.That(mercedesAmgW13.SmallImageUri, Is.EqualTo(new Uri("https://images-static.iracing.com/img/cars/mercedesw13/mercedesw13-small.jpg")));

Assert.That(carAssets.RateLimitRemaining, Is.EqualTo(99));
Assert.That(carAssets.TotalRateLimit, Is.EqualTo(100));
Assert.That(carAssets.RateLimitReset, Is.EqualTo(new DateTimeOffset(2022, 2, 10, 0, 0, 0, TimeSpan.Zero)));
Assert.That(carAssets.DataExpires, Is.EqualTo(new DateTimeOffset(2022, 8, 27, 11, 23, 19, 507, TimeSpan.Zero)));
});
}

[Test(TestOf = typeof(DataClient))]
Expand Down
11 changes: 10 additions & 1 deletion src/Aydsko.iRacingData/Cars/CarAssetDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Aydsko.iRacingData.Cars;

public class CarAssetDetail
{
public const string ImagePathBase = "https://images-static.iracing.com/";
public const string ImagePathBase = "https://images-static.iracing.com";

[JsonPropertyName("car_id")]
public int CarId { get; set; }
Expand Down Expand Up @@ -42,12 +42,21 @@ public class CarAssetDetail
[JsonPropertyName("large_image")]
public string LargeImage { get; set; } = default!;

[JsonIgnore]
public Uri LargeImageUri => new(string.Join("/", [ImagePathBase.Trim('/'), Folder.Trim('/'), LargeImage.Trim('/')]));

[JsonPropertyName("logo")]
public string Logo { get; set; } = default!;

[JsonIgnore]
public Uri LogoUri => new(string.Join("/", [ImagePathBase.Trim('/'), Logo.Trim('/')]));

[JsonPropertyName("small_image")]
public string SmallImage { get; set; } = default!;

[JsonIgnore]
public Uri SmallImageUri => new(string.Join("/", [ImagePathBase.Trim('/'), Folder.Trim('/'), SmallImage.Trim('/')]));

[JsonPropertyName("sponsor_logo")]
public object? SponsorLogo { get; set; }

Expand Down
1 change: 1 addition & 0 deletions src/Aydsko.iRacingData/Package Release Notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
Fixes / Changes:

- 504 response can't be deserialized to ErrorResponse (Issue #214)
- Include pre-built URL values for logo and images on the "CarAssetDetail" class

0 comments on commit f3a0bbf

Please sign in to comment.