Skip to content

Commit

Permalink
Implement Club Image Path Method
Browse files Browse the repository at this point in the history
Add a method to properly build the Club or Region log image path.

Fixes #189
  • Loading branch information
AdrianJSClark committed Nov 20, 2023
1 parent f5e4063 commit 72b6f41
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Aydsko.iRacingData/Member/MemberProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ public class MemberProfile

[JsonPropertyName("cust_id")]
public int CustomerId { get; set; }

/// <summary>Get the Club or Region logo image.</summary>
/// <remarks>If the <c>CLUB_REGION_IMG</c> value is available in the <see cref="ProfileFields"/> collection it will be properly formatted into an absolute URL.</remarks>
/// <returns>An absolute URL to the image.</returns>
public Uri? GetClubRegionImageUrl()
{
if (ProfileFields.FirstOrDefault(pf => pf.Name == "CLUB_REGION_IMG") is not ProfileField clubRegionImageField || string.IsNullOrWhiteSpace(clubRegionImageField.Value))
{
return null;
}

return new Uri("https://ir-core-sites.iracing.com/members/" + clubRegionImageField.Value.TrimStart('/'), UriKind.Absolute);
}
}

[JsonSerializable(typeof(MemberProfile)), JsonSourceGenerationOptions(WriteIndented = true)]
Expand Down

0 comments on commit 72b6f41

Please sign in to comment.