diff --git a/algoliasearch/Models/Recommend/RecommendationsHit.cs b/algoliasearch/Models/Recommend/RecommendationsHit.cs index af85facd9..9e8054b43 100644 --- a/algoliasearch/Models/Recommend/RecommendationsHit.cs +++ b/algoliasearch/Models/Recommend/RecommendationsHit.cs @@ -22,20 +22,20 @@ public partial class RecommendationsHit : AbstractSchema { /// /// Initializes a new instance of the RecommendationsHit class - /// with a RecommendHit + /// with a TrendingFacetHit /// - /// An instance of RecommendHit. - public RecommendationsHit(RecommendHit actualInstance) + /// An instance of TrendingFacetHit. + public RecommendationsHit(TrendingFacetHit actualInstance) { ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); } /// /// Initializes a new instance of the RecommendationsHit class - /// with a TrendingFacetHit + /// with a RecommendHit /// - /// An instance of TrendingFacetHit. - public RecommendationsHit(TrendingFacetHit actualInstance) + /// An instance of RecommendHit. + public RecommendationsHit(RecommendHit actualInstance) { ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); } @@ -47,42 +47,42 @@ public RecommendationsHit(TrendingFacetHit actualInstance) public sealed override object ActualInstance { get; set; } /// - /// Get the actual instance of `RecommendHit`. If the actual instance is not `RecommendHit`, + /// Get the actual instance of `TrendingFacetHit`. If the actual instance is not `TrendingFacetHit`, /// the InvalidClassException will be thrown /// - /// An instance of RecommendHit - public RecommendHit AsRecommendHit() + /// An instance of TrendingFacetHit + public TrendingFacetHit AsTrendingFacetHit() { - return (RecommendHit)ActualInstance; + return (TrendingFacetHit)ActualInstance; } /// - /// Get the actual instance of `TrendingFacetHit`. If the actual instance is not `TrendingFacetHit`, + /// Get the actual instance of `RecommendHit`. If the actual instance is not `RecommendHit`, /// the InvalidClassException will be thrown /// - /// An instance of TrendingFacetHit - public TrendingFacetHit AsTrendingFacetHit() + /// An instance of RecommendHit + public RecommendHit AsRecommendHit() { - return (TrendingFacetHit)ActualInstance; + return (RecommendHit)ActualInstance; } /// - /// Check if the actual instance is of `RecommendHit` type. + /// Check if the actual instance is of `TrendingFacetHit` type. /// /// Whether or not the instance is the type - public bool IsRecommendHit() + public bool IsTrendingFacetHit() { - return ActualInstance.GetType() == typeof(RecommendHit); + return ActualInstance.GetType() == typeof(TrendingFacetHit); } /// - /// Check if the actual instance is of `TrendingFacetHit` type. + /// Check if the actual instance is of `RecommendHit` type. /// /// Whether or not the instance is the type - public bool IsTrendingFacetHit() + public bool IsRecommendHit() { - return ActualInstance.GetType() == typeof(TrendingFacetHit); + return ActualInstance.GetType() == typeof(RecommendHit); } /// @@ -169,28 +169,28 @@ public override RecommendationsHit Read(ref Utf8JsonReader reader, Type typeToCo { var jsonDocument = JsonDocument.ParseValue(ref reader); var root = jsonDocument.RootElement; - if (root.ValueKind == JsonValueKind.Object) + if (root.ValueKind == JsonValueKind.Object && root.TryGetProperty("facetName", out _) && root.TryGetProperty("facetValue", out _)) { try { - return new RecommendationsHit(jsonDocument.Deserialize(JsonConfig.Options)); + return new RecommendationsHit(jsonDocument.Deserialize(JsonConfig.Options)); } catch (Exception exception) { // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine($"Failed to deserialize into RecommendHit: {exception}"); + System.Diagnostics.Debug.WriteLine($"Failed to deserialize into TrendingFacetHit: {exception}"); } } if (root.ValueKind == JsonValueKind.Object) { try { - return new RecommendationsHit(jsonDocument.Deserialize(JsonConfig.Options)); + return new RecommendationsHit(jsonDocument.Deserialize(JsonConfig.Options)); } catch (Exception exception) { // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine($"Failed to deserialize into TrendingFacetHit: {exception}"); + System.Diagnostics.Debug.WriteLine($"Failed to deserialize into RecommendHit: {exception}"); } } throw new InvalidDataException($"The JSON string cannot be deserialized into any schema defined.");