Skip to content

Commit 82b04e5

Browse files
author
Jonas Kalmar Rønning
committed
feat(csharp) add support for widgets / banners in search for the csharp client fix #3869
1 parent 63200d1 commit 82b04e5

File tree

6 files changed

+98
-1
lines changed

6 files changed

+98
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace Algolia.Search.Models.Search;
4+
5+
/// <summary>
6+
/// Represents a banner configured in the merchandising studio
7+
/// </summary>
8+
public class Banner
9+
{
10+
/// <summary>
11+
/// Gets or sets image
12+
/// </summary>
13+
[JsonPropertyName("image")]
14+
public BannerImage Image { get; set; }
15+
16+
/// <summary>
17+
/// Gets or sets link
18+
/// </summary>
19+
[JsonPropertyName("link")]
20+
public BannerLink Link { get; set; }
21+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System.Collections.Generic;
2+
using System.Text.Json.Serialization;
3+
4+
namespace Algolia.Search.Models.Search;
5+
6+
/// <summary>
7+
/// A banner image, contains urls for the images and a title
8+
/// </summary>
9+
public class BannerImage
10+
{
11+
/// <summary>
12+
/// Gets or sets urls
13+
/// </summary>
14+
[JsonPropertyName("urls")]
15+
public IReadOnlyCollection<BannerImageUrl> Urls { get; set; }
16+
17+
/// <summary>
18+
/// Gets or sets title
19+
/// </summary>
20+
[JsonPropertyName("title")]
21+
public string Title { get; set; }
22+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace Algolia.Search.Models.Search;
4+
5+
/// <summary>
6+
/// Url specified for the banner image in the merchandising studio
7+
/// </summary>
8+
public class BannerImageUrl
9+
{
10+
/// <summary>
11+
/// Gets or sets url
12+
/// </summary>
13+
[JsonPropertyName("url")]
14+
public string Url { get; set; }
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Text.Json.Serialization;
2+
3+
namespace Algolia.Search.Models.Search;
4+
5+
/// <summary>
6+
/// The url specified on the banner in the merchandising studio
7+
/// </summary>
8+
public class BannerLink
9+
{
10+
/// <summary>
11+
/// Gets or sets url
12+
/// </summary>
13+
[JsonPropertyName("url")]
14+
public string Url { get; set; }
15+
}

clients/algoliasearch-client-csharp/algoliasearch/Models/Search/RenderingContent.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public RenderingContent()
3535
[JsonPropertyName("redirect")]
3636
public RedirectURL Redirect { get; set; }
3737

38+
/// <summary>
39+
/// Gets or Sets Widgets
40+
/// </summary>
41+
[JsonPropertyName("widgets")]
42+
public Widgets Widgets { get; set; }
43+
3844
/// <summary>
3945
/// Returns the string presentation of the object
4046
/// </summary>
@@ -45,6 +51,7 @@ public override string ToString()
4551
sb.Append("class RenderingContent {\n");
4652
sb.Append(" FacetOrdering: ").Append(FacetOrdering).Append("\n");
4753
sb.Append(" Redirect: ").Append(Redirect).Append("\n");
54+
sb.Append(" Widgets: ").Append(Widgets).Append("\n");
4855
sb.Append("}\n");
4956
return sb.ToString();
5057
}
@@ -72,7 +79,7 @@ public override bool Equals(object obj)
7279

7380
return
7481
(FacetOrdering == input.FacetOrdering || (FacetOrdering != null && FacetOrdering.Equals(input.FacetOrdering))) &&
75-
(Redirect == input.Redirect || (Redirect != null && Redirect.Equals(input.Redirect)));
82+
(Redirect == input.Redirect || (Redirect != null && Redirect.Equals(input.Redirect))) && Widgets.Equals(input.Widgets);
7683
}
7784

7885
/// <summary>
@@ -92,6 +99,10 @@ public override int GetHashCode()
9299
{
93100
hashCode = (hashCode * 59) + Redirect.GetHashCode();
94101
}
102+
if (Widgets != null)
103+
{
104+
hashCode = (hashCode * 59) + Widgets.GetHashCode();
105+
}
95106
return hashCode;
96107
}
97108
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Collections.Generic;
2+
using System.Text.Json.Serialization;
3+
4+
namespace Algolia.Search.Models.Search;
5+
6+
public class Widgets
7+
{
8+
/// <summary>
9+
/// Gets or sets banners
10+
/// </summary>
11+
[JsonPropertyName("banners")]
12+
public IReadOnlyCollection<Banner> Banners { get; set; }
13+
}

0 commit comments

Comments
 (0)