// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using Newtonsoft.Json; namespace osu.Game.Online.API.Requests.Responses { public class APIMenuImage : IEquatable { /// /// A URL pointing to the image which should be displayed. Generally should be an @2x image filename. /// [JsonProperty(@"image")] public string Image { get; init; } = string.Empty; /// /// A URL that should be opened on clicking the image. /// [JsonProperty(@"url")] public string Url { get; init; } = string.Empty; public bool IsCurrent => (Begins == null || Begins < DateTimeOffset.UtcNow) && (Expires == null || Expires > DateTimeOffset.UtcNow); /// /// The time at which this item should begin displaying. If null, will display immediately. /// [JsonProperty(@"begins")] public DateTimeOffset? Begins { get; init; } /// /// The time at which this item should stop displaying. If null, will display indefinitely. /// [JsonProperty(@"expires")] public DateTimeOffset? Expires { get; init; } public bool Equals(APIMenuImage? other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return Image == other.Image && Url == other.Url && Begins == other.Begins && Expires == other.Expires; } public override bool Equals(object? other) => other is APIMenuImage content && Equals(content); public override int GetHashCode() { return HashCode.Combine(Image, Url, Begins, Expires); } } }