Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
419 changes: 419 additions & 0 deletions src/Constructorio_NET.Tests/client/modules/FacetTestsV2.cs

Large diffs are not rendered by default.

460 changes: 460 additions & 0 deletions src/Constructorio_NET.Tests/client/modules/SearchabilityTestsV2.cs

Large diffs are not rendered by default.

631 changes: 631 additions & 0 deletions src/constructor.io/client/modules/Catalog.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using System;
using System.Collections;
using System.Collections.Generic;

namespace Constructorio_NET.Models
{
/// <summary>
/// Constructor.io v2 Delete Searchabilities Request Class.
/// </summary>
public class DeleteSearchabilitiesV2Request
{
/// <summary>
/// Gets or sets the list of searchability names to delete.
/// </summary>
public List<string> SearchabilityNames { get; set; }

/// <summary>
/// Gets or sets the name of the section. If not set, the API defaults to "Products".
/// </summary>
public string Section { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to skip index rebuild.
/// </summary>
public bool? SkipRebuild { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="DeleteSearchabilitiesV2Request"/> class.
/// </summary>
/// <param name="searchabilityNames">List of searchability names to delete.</param>
public DeleteSearchabilitiesV2Request(List<string> searchabilityNames)
{
if (searchabilityNames == null || searchabilityNames.Count == 0)
{
throw new ArgumentException("searchabilityNames cannot be null or empty", nameof(searchabilityNames));
}

this.SearchabilityNames = searchabilityNames;
}

/// <summary>
/// Get request parameters.
/// </summary>
/// <returns>Hashtable of request parameters.</returns>
public Hashtable GetRequestParameters()
{
Hashtable parameters = new Hashtable();

if (this.SkipRebuild.HasValue)
{
parameters.Add("skip_rebuild", this.SkipRebuild.Value.ToString().ToLower());
}

return parameters;
}

/// <summary>
/// Get request headers.
/// </summary>
/// <returns>Dictionary of request headers.</returns>
public Dictionary<string, string> GetRequestHeaders()
{
Dictionary<string, string> requestHeaders = new Dictionary<string, string>();

return requestHeaders;
}

/// <summary>
/// Get the request body for the delete operation.
/// </summary>
/// <returns>Hashtable containing the searchabilities to delete.</returns>
public Hashtable GetRequestBody()
{
var searchabilities = new List<Hashtable>();
foreach (var name in this.SearchabilityNames)
{
searchabilities.Add(new Hashtable { { "name", name } });
}

return new Hashtable
{
{ "searchabilities", searchabilities }
};
}
}
}
25 changes: 25 additions & 0 deletions src/constructor.io/models/Catalog/FacetV2GetAllResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

namespace Constructorio_NET.Models
{
/// <summary>
/// Response object for retrieving all v2 facet configurations.
/// </summary>
[JsonObject(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
public class FacetV2GetAllResponse
{
/// <summary>
/// Gets or sets the list of facet configurations.
/// </summary>
[JsonProperty("facets")]
public List<FacetV2> Facets { get; set; } = new List<FacetV2>();

/// <summary>
/// Gets or sets the total count of facet configurations.
/// </summary>
[JsonProperty("total_count")]
public int TotalCount { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System;
using System.Collections;
using System.Collections.Generic;

namespace Constructorio_NET.Models
{
/// <summary>
/// Constructor.io v2 Patch Searchabilities Request Class.
/// </summary>
public class PatchSearchabilitiesV2Request
{
/// <summary>
/// Gets or sets searchabilities to be created or updated.
/// </summary>
public List<SearchabilityV2> Searchabilities { get; set; }

/// <summary>
/// Gets or sets the name of the section. If not set, the API defaults to "Products".
/// </summary>
public string Section { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to skip index rebuild.
/// </summary>
public bool? SkipRebuild { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="PatchSearchabilitiesV2Request"/> class.
/// </summary>
/// <param name="searchabilities">List of searchabilities to create or update.</param>
public PatchSearchabilitiesV2Request(List<SearchabilityV2> searchabilities)
{
if (searchabilities == null || searchabilities.Count == 0)
{
throw new ArgumentException("searchabilities cannot be null or empty", nameof(searchabilities));
}

this.Searchabilities = searchabilities;
}

/// <summary>
/// Get request parameters.
/// </summary>
/// <returns>Hashtable of request parameters.</returns>
public Hashtable GetRequestParameters()
{
Hashtable parameters = new Hashtable();

if (this.SkipRebuild.HasValue)
{
parameters.Add("skip_rebuild", this.SkipRebuild.Value.ToString().ToLower());
}

return parameters;
}

/// <summary>
/// Get request headers.
/// </summary>
/// <returns>Dictionary of request headers.</returns>
public Dictionary<string, string> GetRequestHeaders()
{
Dictionary<string, string> requestHeaders = new Dictionary<string, string>();

return requestHeaders;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Constructorio_NET.Utils;

namespace Constructorio_NET.Models
{
/// <summary>
/// Constructor.io v2 Retrieve Searchabilities Request Class.
/// </summary>
public class RetrieveSearchabilitiesV2Request
{
/// <summary>
/// Gets or sets name of searchability field to filter for.
/// Supports exact matching (name=value) and substring matching (name=*value, value* or *value*).
/// </summary>
public string Name { get; set; }

/// <summary>
/// Gets or sets the page of searchability results to retrieve. Can't be used with Offset.
/// </summary>
public int Page { get; set; }

/// <summary>
/// Gets or sets the offset of results to skip. Can't be used with Page.
/// </summary>
public int Offset { get; set; }

/// <summary>
/// Gets or sets the name of the section. If not set, the API defaults to "Products".
/// </summary>
public string Section { get; set; }

/// <summary>
/// Gets or sets the number of results per page to retrieve. Default: 20, Max: 1000.
/// </summary>
public int NumResultsPerPage { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to filter by fuzzy_searchable.
/// </summary>
public bool? FuzzySearchable { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to filter by exact_searchable.
/// </summary>
public bool? ExactSearchable { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to filter by displayable.
/// </summary>
public bool? Displayable { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to filter by hidden.
/// </summary>
public bool? Hidden { get; set; }

/// <summary>
/// Gets or sets the match type for filters. Valid values are "and" or "or". Default is "and".
/// </summary>
public string MatchType { get; set; }

/// <summary>
/// Gets or sets the criteria by which searchability results should be sorted. Valid value is "name".
/// </summary>
public string SortBy { get; set; }

/// <summary>
/// Gets or sets the order by which searchability results should be sorted. Valid values are "descending" or "ascending". Default is "ascending".
/// </summary>
public string SortOrder { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="RetrieveSearchabilitiesV2Request"/> class.
/// </summary>
public RetrieveSearchabilitiesV2Request()
{
}

/// <summary>
/// Get request parameters.
/// </summary>
/// <returns>Hashtable of request parameters.</returns>
public Hashtable GetRequestParameters()
{
if (this.Page > 0 && this.Offset > 0)
{
throw new InvalidOperationException("Page and Offset are mutually exclusive — set only one.");
}

Hashtable parameters = new Hashtable();

if (!string.IsNullOrEmpty(this.Name))
{
parameters.Add("name", this.Name);
}

if (this.Page > 0)
{
parameters.Add(Constants.PAGE, this.Page);
}

if (this.Offset > 0)
{
parameters.Add(Constants.OFFSET, this.Offset);
}

if (this.NumResultsPerPage > 0)
{
parameters.Add(Constants.RESULTS_PER_PAGE, this.NumResultsPerPage);
}

if (this.FuzzySearchable.HasValue)
{
parameters.Add("fuzzy_searchable", this.FuzzySearchable.Value.ToString().ToLower());
}

if (this.ExactSearchable.HasValue)
{
parameters.Add("exact_searchable", this.ExactSearchable.Value.ToString().ToLower());
}

if (this.Displayable.HasValue)
{
parameters.Add("displayable", this.Displayable.Value.ToString().ToLower());
}

if (this.Hidden.HasValue)
{
parameters.Add("hidden", this.Hidden.Value.ToString().ToLower());
}

if (!string.IsNullOrEmpty(this.MatchType))
{
parameters.Add("match_type", this.MatchType);
}

if (!string.IsNullOrEmpty(this.SortBy))
{
parameters.Add(Constants.SORT_BY, this.SortBy);
}

if (!string.IsNullOrEmpty(this.SortOrder))
{
parameters.Add(Constants.SORT_ORDER, this.SortOrder);
}

return parameters;
}

/// <summary>
/// Get request headers.
/// </summary>
/// <returns>Dictionary of request headers.</returns>
public Dictionary<string, string> GetRequestHeaders()
{
Dictionary<string, string> requestHeaders = new Dictionary<string, string>();

return requestHeaders;
}
}
}
25 changes: 25 additions & 0 deletions src/constructor.io/models/Catalog/SearchabilitiesV2Response.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

namespace Constructorio_NET.Models
{
/// <summary>
/// Response object for v2 searchabilities operations (GET, PATCH, DELETE).
/// </summary>
[JsonObject(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
public class SearchabilitiesV2Response
{
/// <summary>
/// Gets or sets the list of searchability configurations.
/// </summary>
[JsonProperty("searchabilities")]
public List<SearchabilityV2> Searchabilities { get; set; } = new List<SearchabilityV2>();

/// <summary>
/// Gets or sets the total count of searchability configurations.
/// </summary>
[JsonProperty("total_count")]
public int TotalCount { get; set; }
}
}
Loading
Loading