Skip to content

Commit

Permalink
feat(csharp) add support for widgets / banners in search for the csha…
Browse files Browse the repository at this point in the history
…rp client fix algolia#3869
  • Loading branch information
Jonas Kalmar Rønning committed Oct 2, 2024
1 parent 63200d1 commit 82b04e5
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Text.Json.Serialization;

namespace Algolia.Search.Models.Search;

/// <summary>
/// Represents a banner configured in the merchandising studio
/// </summary>
public class Banner
{
/// <summary>
/// Gets or sets image
/// </summary>
[JsonPropertyName("image")]
public BannerImage Image { get; set; }

/// <summary>
/// Gets or sets link
/// </summary>
[JsonPropertyName("link")]
public BannerLink Link { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace Algolia.Search.Models.Search;

/// <summary>
/// A banner image, contains urls for the images and a title
/// </summary>
public class BannerImage
{
/// <summary>
/// Gets or sets urls
/// </summary>
[JsonPropertyName("urls")]
public IReadOnlyCollection<BannerImageUrl> Urls { get; set; }

/// <summary>
/// Gets or sets title
/// </summary>
[JsonPropertyName("title")]
public string Title { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Text.Json.Serialization;

namespace Algolia.Search.Models.Search;

/// <summary>
/// Url specified for the banner image in the merchandising studio
/// </summary>
public class BannerImageUrl
{
/// <summary>
/// Gets or sets url
/// </summary>
[JsonPropertyName("url")]
public string Url { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Text.Json.Serialization;

namespace Algolia.Search.Models.Search;

/// <summary>
/// The url specified on the banner in the merchandising studio
/// </summary>
public class BannerLink
{
/// <summary>
/// Gets or sets url
/// </summary>
[JsonPropertyName("url")]
public string Url { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public RenderingContent()
[JsonPropertyName("redirect")]
public RedirectURL Redirect { get; set; }

/// <summary>
/// Gets or Sets Widgets
/// </summary>
[JsonPropertyName("widgets")]
public Widgets Widgets { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
Expand All @@ -45,6 +51,7 @@ public override string ToString()
sb.Append("class RenderingContent {\n");
sb.Append(" FacetOrdering: ").Append(FacetOrdering).Append("\n");
sb.Append(" Redirect: ").Append(Redirect).Append("\n");
sb.Append(" Widgets: ").Append(Widgets).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
Expand Down Expand Up @@ -72,7 +79,7 @@ public override bool Equals(object obj)

return
(FacetOrdering == input.FacetOrdering || (FacetOrdering != null && FacetOrdering.Equals(input.FacetOrdering))) &&
(Redirect == input.Redirect || (Redirect != null && Redirect.Equals(input.Redirect)));
(Redirect == input.Redirect || (Redirect != null && Redirect.Equals(input.Redirect))) && Widgets.Equals(input.Widgets);
}

/// <summary>
Expand All @@ -92,6 +99,10 @@ public override int GetHashCode()
{
hashCode = (hashCode * 59) + Redirect.GetHashCode();
}
if (Widgets != null)
{
hashCode = (hashCode * 59) + Widgets.GetHashCode();
}
return hashCode;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace Algolia.Search.Models.Search;

public class Widgets
{
/// <summary>
/// Gets or sets banners
/// </summary>
[JsonPropertyName("banners")]
public IReadOnlyCollection<Banner> Banners { get; set; }
}

0 comments on commit 82b04e5

Please sign in to comment.