Skip to content

Commit

Permalink
CarAssetDetail URL Improvements & Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianJSClark committed Aug 4, 2024
1 parent 0e8b1b2 commit c1261f8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
32 changes: 30 additions & 2 deletions src/Aydsko.iRacingData/Cars/CarAssetDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,57 @@ public class CarAssetDetail
[JsonPropertyName("group_name")]
public object? GroupName { get; set; }

/// <summary>File name for the larger image of the vehicle.</summary>
/// <remarks>Must be combined with <see cref="ImagePathBase"/> and <see cref="Folder"/> to be useful.</remarks>
[JsonPropertyName("large_image")]
public string LargeImage { get; set; } = default!;

/// <summary>The full URL to the vehicle's large image.</summary>
/// <seealso cref="LargeImage"/>
[JsonIgnore]
public Uri LargeImageUri => new(string.Join("/", [ImagePathBase.Trim('/'), Folder.Trim('/'), LargeImage.Trim('/')]));

/// <summary>File name for the logo image of the vehicle's manufacturer.</summary>
/// <remarks>Must be combined with <see cref="ImagePathBase"/> to be useful.</remarks>
[JsonPropertyName("logo")]
public string Logo { get; set; } = default!;

/// <summary>The full URL to the image containing the manufacturer logo.</summary>
/// <seealso cref="Logo"/>
[JsonIgnore]
public Uri LogoUri => new(string.Join("/", [ImagePathBase.Trim('/'), Logo.Trim('/')]));

/// <summary>File name for the smaller image of the vehicle.</summary>
/// <remarks>Must be combined with <see cref="ImagePathBase"/> and <see cref="Folder"/> to be useful.</remarks>
[JsonPropertyName("small_image")]
public string SmallImage { get; set; } = default!;

/// <summary>The full URL to the vehicle's small image.</summary>
/// <seealso cref="SmallImage"/>
[JsonIgnore]
public Uri SmallImageUri => new(string.Join("/", [ImagePathBase.Trim('/'), Folder.Trim('/'), SmallImage.Trim('/')]));

/// <summary>File name for the logo image of the vehicle's series sponsor, if available.</summary>
/// <remarks>Must be combined with <see cref="ImagePathBase"/> to be useful.</remarks>
[JsonPropertyName("sponsor_logo")]
public object? SponsorLogo { get; set; }
public string? SponsorLogo { get; set; }

/// <summary>The full URL for the logo image of the vehicle's series sponsor, if available.</summary>
/// <seealso cref="SponsorLogo"/>
[JsonIgnore]
public Uri? SponsorLogoUri => SponsorLogo is string { Length: > 0 }
? new(string.Join("/", [ImagePathBase.Trim('/'), SponsorLogo.Trim('/')]))
: null;

/// <summary>Relative path of the vehicle paint template, if available.</summary>
[JsonPropertyName("template_path")]
public string TemplatePath { get; set; } = default!;
public string? TemplatePath { get; set; } = default!;

/// <summary>The full URL to the vehicle's paint template, if available.</summary>
[JsonIgnore]
public Uri? TemplateUri => TemplatePath is string { Length: > 0 }
? new($"https://ir-core-sites.iracing.com/members/member_images/cars/{TemplatePath.Trim('/')}")
: null;
}

[JsonSerializable(typeof(IReadOnlyDictionary<string, CarAssetDetail>)), JsonSourceGenerationOptions(WriteIndented = true)]
Expand Down
2 changes: 1 addition & 1 deletion src/Aydsko.iRacingData/Package Release Notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,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
- Include pre-built URL values on the "CarAssetDetail" class

0 comments on commit c1261f8

Please sign in to comment.