Skip to content

Commit 4e0d7dc

Browse files
algolia-boteric-zahariaDmytro Sarzhandmytrosarzhan-mono
committed
feat(specs): query categorization (generated)
algolia/api-clients-automation#6258 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Eric Zaharia <94015633+eric-zaharia@users.noreply.github.com> Co-authored-by: Dmytro Sarzhan <dima@MacBook-Pro-Dmytro.local> Co-authored-by: dmytrosarzhan-mono <dmytro.sarzhan@monobank.ua>
1 parent 9071bcb commit 4e0d7dc

13 files changed

Lines changed: 1101 additions & 1 deletion
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
//
2+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
//
4+
using System;
5+
using System.Collections.Generic;
6+
using System.IO;
7+
using System.Linq;
8+
using System.Reflection;
9+
using System.Text;
10+
using System.Text.Json;
11+
using System.Text.Json.Serialization;
12+
using Algolia.Search.Models.Common;
13+
using Algolia.Search.Serializer;
14+
15+
namespace Algolia.Search.Models.Search;
16+
17+
/// <summary>
18+
/// AutoFilteringFilterEntry
19+
/// </summary>
20+
[JsonConverter(typeof(AutoFilteringFilterEntryJsonConverter))]
21+
public partial class AutoFilteringFilterEntry : AbstractSchema
22+
{
23+
/// <summary>
24+
/// Initializes a new instance of the AutoFilteringFilterEntry class
25+
/// with a string
26+
/// </summary>
27+
/// <param name="actualInstance">An instance of string.</param>
28+
public AutoFilteringFilterEntry(string actualInstance)
29+
{
30+
ActualInstance =
31+
actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
32+
}
33+
34+
/// <summary>
35+
/// Initializes a new instance of the AutoFilteringFilterEntry class
36+
/// with a List{String}
37+
/// </summary>
38+
/// <param name="actualInstance">An instance of List<string>.</param>
39+
public AutoFilteringFilterEntry(List<string> actualInstance)
40+
{
41+
ActualInstance =
42+
actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null.");
43+
}
44+
45+
/// <summary>
46+
/// Gets or Sets ActualInstance
47+
/// </summary>
48+
public sealed override object ActualInstance { get; set; }
49+
50+
/// <summary>
51+
/// Get the actual instance of `string`. If the actual instance is not `string`,
52+
/// the InvalidClassException will be thrown
53+
/// </summary>
54+
/// <returns>An instance of string</returns>
55+
public string AsString()
56+
{
57+
return (string)ActualInstance;
58+
}
59+
60+
/// <summary>
61+
/// Get the actual instance of `List{string}`. If the actual instance is not `List{string}`,
62+
/// the InvalidClassException will be thrown
63+
/// </summary>
64+
/// <returns>An instance of List&lt;string&gt;</returns>
65+
public List<string> AsListString()
66+
{
67+
return (List<string>)ActualInstance;
68+
}
69+
70+
/// <summary>
71+
/// Check if the actual instance is of `string` type.
72+
/// </summary>
73+
/// <returns>Whether or not the instance is the type</returns>
74+
public bool IsString()
75+
{
76+
return ActualInstance.GetType() == typeof(string);
77+
}
78+
79+
/// <summary>
80+
/// Check if the actual instance is of `List{string}` type.
81+
/// </summary>
82+
/// <returns>Whether or not the instance is the type</returns>
83+
public bool IsListString()
84+
{
85+
return ActualInstance.GetType() == typeof(List<string>);
86+
}
87+
88+
/// <summary>
89+
/// Returns the string presentation of the object
90+
/// </summary>
91+
/// <returns>String presentation of the object</returns>
92+
public override string ToString()
93+
{
94+
var sb = new StringBuilder();
95+
sb.Append("class AutoFilteringFilterEntry {\n");
96+
sb.Append(" ActualInstance: ").Append(ActualInstance).Append("\n");
97+
sb.Append("}\n");
98+
return sb.ToString();
99+
}
100+
101+
/// <summary>
102+
/// Returns the JSON string presentation of the object
103+
/// </summary>
104+
/// <returns>JSON string presentation of the object</returns>
105+
public override string ToJson()
106+
{
107+
return JsonSerializer.Serialize(ActualInstance, JsonConfig.Options);
108+
}
109+
110+
/// <summary>
111+
/// Returns true if objects are equal
112+
/// </summary>
113+
/// <param name="obj">Object to be compared</param>
114+
/// <returns>Boolean</returns>
115+
public override bool Equals(object obj)
116+
{
117+
if (obj is not AutoFilteringFilterEntry input)
118+
{
119+
return false;
120+
}
121+
122+
return ActualInstance.Equals(input.ActualInstance);
123+
}
124+
125+
/// <summary>
126+
/// Gets the hash code
127+
/// </summary>
128+
/// <returns>Hash code</returns>
129+
public override int GetHashCode()
130+
{
131+
unchecked // Overflow is fine, just wrap
132+
{
133+
int hashCode = 41;
134+
if (ActualInstance != null)
135+
hashCode = hashCode * 59 + ActualInstance.GetHashCode();
136+
return hashCode;
137+
}
138+
}
139+
}
140+
141+
/// <summary>
142+
/// Custom JSON converter for AutoFilteringFilterEntry
143+
/// </summary>
144+
public class AutoFilteringFilterEntryJsonConverter : JsonConverter<AutoFilteringFilterEntry>
145+
{
146+
/// <summary>
147+
/// Check if the object can be converted
148+
/// </summary>
149+
/// <param name="objectType">Object type</param>
150+
/// <returns>True if the object can be converted</returns>
151+
public override bool CanConvert(Type objectType)
152+
{
153+
return objectType == typeof(AutoFilteringFilterEntry);
154+
}
155+
156+
/// <summary>
157+
/// To convert a JSON string into an object
158+
/// </summary>
159+
/// <param name="reader">JSON reader</param>
160+
/// <param name="typeToConvert">Object type</param>
161+
/// <param name="options">Serializer options</param>
162+
/// <returns>The object converted from the JSON string</returns>
163+
public override AutoFilteringFilterEntry Read(
164+
ref Utf8JsonReader reader,
165+
Type typeToConvert,
166+
JsonSerializerOptions options
167+
)
168+
{
169+
var jsonDocument = JsonDocument.ParseValue(ref reader);
170+
var root = jsonDocument.RootElement;
171+
if (root.ValueKind == JsonValueKind.String)
172+
{
173+
try
174+
{
175+
return new AutoFilteringFilterEntry(jsonDocument.Deserialize<string>(JsonConfig.Options));
176+
}
177+
catch (Exception exception)
178+
{
179+
// deserialization failed, try the next one
180+
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into string: {exception}");
181+
}
182+
}
183+
if (root.ValueKind == JsonValueKind.Array)
184+
{
185+
try
186+
{
187+
return new AutoFilteringFilterEntry(
188+
jsonDocument.Deserialize<List<string>>(JsonConfig.Options)
189+
);
190+
}
191+
catch (Exception exception)
192+
{
193+
// deserialization failed, try the next one
194+
System.Diagnostics.Debug.WriteLine($"Failed to deserialize into List<string>: {exception}");
195+
}
196+
}
197+
throw new InvalidDataException(
198+
$"The JSON string cannot be deserialized into any schema defined."
199+
);
200+
}
201+
202+
/// <summary>
203+
/// To write the JSON string
204+
/// </summary>
205+
/// <param name="writer">JSON writer</param>
206+
/// <param name="value">AutoFilteringFilterEntry to be converted into a JSON string</param>
207+
/// <param name="options">JSON Serializer options</param>
208+
public override void Write(
209+
Utf8JsonWriter writer,
210+
AutoFilteringFilterEntry value,
211+
JsonSerializerOptions options
212+
)
213+
{
214+
writer.WriteRawValue(value.ToJson());
215+
}
216+
}
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
//
2+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
//
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Text.Json;
9+
using System.Text.Json.Serialization;
10+
using Algolia.Search.Serializer;
11+
12+
namespace Algolia.Search.Models.Search;
13+
14+
/// <summary>
15+
/// Result of automatic filtering applied by Query Categorization.
16+
/// </summary>
17+
public partial class AutoFilteringResult
18+
{
19+
/// <summary>
20+
/// Initializes a new instance of the AutoFilteringResult class.
21+
/// </summary>
22+
public AutoFilteringResult() { }
23+
24+
/// <summary>
25+
/// Whether automatic filtering was applied to this query.
26+
/// </summary>
27+
/// <value>Whether automatic filtering was applied to this query.</value>
28+
[JsonPropertyName("enabled")]
29+
public bool? Enabled { get; set; }
30+
31+
/// <summary>
32+
/// Maximum category hierarchy depth used for filtering.
33+
/// </summary>
34+
/// <value>Maximum category hierarchy depth used for filtering.</value>
35+
[JsonPropertyName("maxDepth")]
36+
public int? MaxDepth { get; set; }
37+
38+
/// <summary>
39+
/// Facet filters automatically applied to the query.
40+
/// </summary>
41+
/// <value>Facet filters automatically applied to the query.</value>
42+
[JsonPropertyName("facetFilters")]
43+
public List<AutoFilteringFilterEntry> FacetFilters { get; set; }
44+
45+
/// <summary>
46+
/// Optional filters automatically applied to boost relevant categories.
47+
/// </summary>
48+
/// <value>Optional filters automatically applied to boost relevant categories.</value>
49+
[JsonPropertyName("optionalFilters")]
50+
public List<AutoFilteringFilterEntry> OptionalFilters { get; set; }
51+
52+
/// <summary>
53+
/// Returns the string presentation of the object
54+
/// </summary>
55+
/// <returns>String presentation of the object</returns>
56+
public override string ToString()
57+
{
58+
StringBuilder sb = new StringBuilder();
59+
sb.Append("class AutoFilteringResult {\n");
60+
sb.Append(" Enabled: ").Append(Enabled).Append("\n");
61+
sb.Append(" MaxDepth: ").Append(MaxDepth).Append("\n");
62+
sb.Append(" FacetFilters: ").Append(FacetFilters).Append("\n");
63+
sb.Append(" OptionalFilters: ").Append(OptionalFilters).Append("\n");
64+
sb.Append("}\n");
65+
return sb.ToString();
66+
}
67+
68+
/// <summary>
69+
/// Returns the JSON string presentation of the object
70+
/// </summary>
71+
/// <returns>JSON string presentation of the object</returns>
72+
public virtual string ToJson()
73+
{
74+
return JsonSerializer.Serialize(this, JsonConfig.Options);
75+
}
76+
77+
/// <summary>
78+
/// Returns true if objects are equal
79+
/// </summary>
80+
/// <param name="obj">Object to be compared</param>
81+
/// <returns>Boolean</returns>
82+
public override bool Equals(object obj)
83+
{
84+
if (obj is not AutoFilteringResult input)
85+
{
86+
return false;
87+
}
88+
89+
return (Enabled == input.Enabled || Enabled.Equals(input.Enabled))
90+
&& (MaxDepth == input.MaxDepth || MaxDepth.Equals(input.MaxDepth))
91+
&& (
92+
FacetFilters == input.FacetFilters
93+
|| FacetFilters != null
94+
&& input.FacetFilters != null
95+
&& FacetFilters.SequenceEqual(input.FacetFilters)
96+
)
97+
&& (
98+
OptionalFilters == input.OptionalFilters
99+
|| OptionalFilters != null
100+
&& input.OptionalFilters != null
101+
&& OptionalFilters.SequenceEqual(input.OptionalFilters)
102+
);
103+
}
104+
105+
/// <summary>
106+
/// Gets the hash code
107+
/// </summary>
108+
/// <returns>Hash code</returns>
109+
public override int GetHashCode()
110+
{
111+
unchecked // Overflow is fine, just wrap
112+
{
113+
int hashCode = 41;
114+
hashCode = (hashCode * 59) + Enabled.GetHashCode();
115+
hashCode = (hashCode * 59) + MaxDepth.GetHashCode();
116+
if (FacetFilters != null)
117+
{
118+
hashCode = (hashCode * 59) + FacetFilters.GetHashCode();
119+
}
120+
if (OptionalFilters != null)
121+
{
122+
hashCode = (hashCode * 59) + OptionalFilters.GetHashCode();
123+
}
124+
return hashCode;
125+
}
126+
}
127+
}

algoliasearch/Models/Search/BrowseResponse.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,12 @@ public BrowseResponse(List<T> hits)
262262
[JsonPropertyName("params")]
263263
public string Params { get; set; }
264264

265+
/// <summary>
266+
/// Gets or Sets Extensions
267+
/// </summary>
268+
[JsonPropertyName("extensions")]
269+
public ResponseExtensions Extensions { get; set; }
270+
265271
/// <summary>
266272
/// Cursor to get the next page of the response. The parameter must match the value returned in the response of a previous request. The last page of the response does not return a `cursor` attribute.
267273
/// </summary>
@@ -310,6 +316,7 @@ public override string ToString()
310316
sb.Append(" Hits: ").Append(Hits).Append("\n");
311317
sb.Append(" Query: ").Append(Query).Append("\n");
312318
sb.Append(" Params: ").Append(Params).Append("\n");
319+
sb.Append(" Extensions: ").Append(Extensions).Append("\n");
313320
sb.Append(" Cursor: ").Append(Cursor).Append("\n");
314321
sb.Append("}\n");
315322
return sb.ToString();
@@ -420,6 +427,10 @@ public override bool Equals(object obj)
420427
)
421428
&& (Query == input.Query || (Query != null && Query.Equals(input.Query)))
422429
&& (Params == input.Params || (Params != null && Params.Equals(input.Params)))
430+
&& (
431+
Extensions == input.Extensions
432+
|| (Extensions != null && Extensions.Equals(input.Extensions))
433+
)
423434
&& (Cursor == input.Cursor || (Cursor != null && Cursor.Equals(input.Cursor)));
424435
}
425436

@@ -525,6 +536,10 @@ public override int GetHashCode()
525536
{
526537
hashCode = (hashCode * 59) + Params.GetHashCode();
527538
}
539+
if (Extensions != null)
540+
{
541+
hashCode = (hashCode * 59) + Extensions.GetHashCode();
542+
}
528543
if (Cursor != null)
529544
{
530545
hashCode = (hashCode * 59) + Cursor.GetHashCode();

0 commit comments

Comments
 (0)