Add V2 Facets and Searchabilities API Support#88
Conversation
There was a problem hiding this comment.
Pull request overview
Adds parallel support for Constructor.io Catalog V2 Facets (/v2/facets) and Searchabilities (/v2/searchabilities) APIs to the .NET client, while keeping V1 APIs intact (and marking relevant V1 methods as obsolete).
Changes:
- Added V2 Facets and V2 Searchabilities client methods in
Catalog(CRUD + batch operations). - Introduced new V2 models and request/response wrappers for facets/searchabilities.
- Added NUnit integration tests covering V2 facet/searchability operations and cleanup.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/constructor.io/client/modules/Catalog.cs | Adds V2 endpoints + marks V1 facet/searchability methods as obsolete. |
| src/constructor.io/models/common/FacetV2.cs | Introduces FacetV2 + FacetTypeV2 (incl. hierarchical) and v2-specific fields. |
| src/constructor.io/models/Catalog/FacetV2GetAllResponse.cs | Adds response wrapper for listing v2 facets. |
| src/constructor.io/models/Catalog/SearchabilityV2.cs | Introduces v2 searchability model with new fields. |
| src/constructor.io/models/Catalog/SearchabilitiesV2Response.cs | Adds response wrapper for v2 searchabilities operations. |
| src/constructor.io/models/Catalog/RetrieveSearchabilitiesV2Request.cs | Adds query/filter/sort request builder for v2 searchabilities retrieval. |
| src/constructor.io/models/Catalog/PatchSearchabilitiesV2Request.cs | Adds request wrapper for batch create/update of v2 searchabilities. |
| src/constructor.io/models/Catalog/DeleteSearchabilitiesV2Request.cs | Adds request wrapper (incl. request body) for batch delete of v2 searchabilities. |
| src/Constructorio_NET.Tests/client/modules/FacetTestsV2.cs | Adds integration tests for all V2 facet operations. |
| src/Constructorio_NET.Tests/client/modules/SearchabilityTestsV2.cs | Adds integration tests for all V2 searchability operations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| [JsonProperty("created_at")] | ||
| public string CreatedAt { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the last updated date and time in ISO 8601 format. | ||
| /// Read-only field returned by the API. Null if never updated. | ||
| /// </summary> | ||
| [JsonProperty("updated_at")] |
| [JsonProperty("created_at")] | ||
| public string CreatedAt { get; private set; } | ||
|
|
||
| /// <summary> | ||
| /// Last facet update date and time in ISO 8601 format. | ||
| /// Read-only field returned by the API. | ||
| /// </summary> | ||
| [JsonProperty("updated_at")] |
| private readonly string ApiKey = Environment.GetEnvironmentVariable("TEST_CATALOG_FACETS_V2_API_KEY"); | ||
| private ConstructorioConfig Config; | ||
| private static List<string> CreatedSearchabilities = new List<string>(); | ||
|
|
||
| [OneTimeSetUp] | ||
| public void Setup() | ||
| { | ||
| JObject json = JObject.Parse(File.ReadAllText("./../../../../../.config/local.json")); | ||
| string testApiToken = json.SelectToken("TEST_API_TOKEN").Value<string>(); | ||
| this.Config = new ConstructorioConfig(this.ApiKey, testApiToken); | ||
| } |
| private readonly string ApiKey = Environment.GetEnvironmentVariable("TEST_CATALOG_FACETS_V2_API_KEY"); | ||
| private ConstructorioConfig Config; | ||
| private static List<FacetV2> CreatedFacets = new List<FacetV2>(); | ||
|
|
||
| [OneTimeSetUp] | ||
| public void Setup() | ||
| { | ||
| JObject json = JObject.Parse(File.ReadAllText("./../../../../../.config/local.json")); | ||
| string testApiToken = json.SelectToken("TEST_API_TOKEN").Value<string>(); | ||
| this.Config = new ConstructorioConfig(this.ApiKey, testApiToken); | ||
| } |
|
|
||
| /// <summary> | ||
| /// Format of range facets. Determines whether the facet is configured to display as a slider (in which case the search endpoint will return only min & max values) or as a list of buckets. | ||
| /// Required if FaceType = `range`. |
There was a problem hiding this comment.
Pull request overview
Adds parallel V2 support for Catalog Facets and Searchabilities endpoints (/v2/facets, /v2/searchabilities) alongside existing V1 methods, including new models, request/response wrappers, client methods, and integration tests.
Changes:
- Introduces V2 facet and searchability models + request/response DTOs.
- Adds V2 Catalog client methods for facet CRUD/batch operations and searchabilities retrieve/patch/delete operations.
- Marks V1 facet/searchability methods as obsolete and adds integration tests for V2 flows.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/constructor.io/models/common/FacetV2.cs | Adds FacetV2 and FacetTypeV2, including V2-only fields and serialization behavior. |
| src/constructor.io/models/Catalog/SearchabilityV2.cs | Adds V2 searchability model with new/removed fields vs V1. |
| src/constructor.io/models/Catalog/SearchabilitiesV2Response.cs | Adds V2 response wrapper for searchabilities operations. |
| src/constructor.io/models/Catalog/RetrieveSearchabilitiesV2Request.cs | Adds V2 retrieve request builder supporting new query params and validation. |
| src/constructor.io/models/Catalog/PatchSearchabilitiesV2Request.cs | Adds V2 batch PATCH request model (incl. skip-rebuild). |
| src/constructor.io/models/Catalog/DeleteSearchabilitiesV2Request.cs | Adds V2 batch DELETE request model + request body builder. |
| src/constructor.io/models/Catalog/FacetV2GetAllResponse.cs | Adds V2 facets list response wrapper. |
| src/constructor.io/client/modules/Catalog.cs | Adds V2 endpoints/methods; deprecates related V1 methods with [Obsolete]. |
| src/Constructorio_NET.Tests/client/modules/SearchabilityTestsV2.cs | Adds integration coverage for V2 searchabilities operations and cleanup. |
| src/Constructorio_NET.Tests/client/modules/FacetTestsV2.cs | Adds integration coverage for V2 facets operations and cleanup. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| [TestFixture] | ||
| public class SearchabilityTestsV2 | ||
| { | ||
| private readonly string ApiKey = Environment.GetEnvironmentVariable("TEST_CATALOG_FACETS_V2_API_KEY"); |
TarekAlQaddy
left a comment
There was a problem hiding this comment.
LGTM!
@esezen I added a test for the Hidden query param in RetrieveSearchabilitiesV2Request but it failed (extra fields not permitted error), it doesn't seem to exist in the API spec, could you confirm please? 👀
Add V2 Facets and Searchabilities API Support
Summary
This PR adds support for the V2 versions of the
/v2/facetsand/v2/searchabilitiesendpoints, running in parallel with the existing V1 implementations.Changes
New Facets V2 Methods
CreateFacetConfigV2- Create a single facet configurationGetAllFacetConfigsV2- Retrieve all facet configurations with paginationGetFacetConfigV2- Get a specific facet by nameCreateOrReplaceFacetConfigsV2- Batch create or replace facets (PUT)BatchPartiallyUpdateFacetConfigsV2- Batch partial update facets (PATCH)ReplaceFacetConfigV2- Replace a single facet configurationPartiallyUpdateFacetConfigV2- Partially update a single facetDeleteFacetConfigV2- Delete a facet configurationNew Searchabilities V2 Methods
RetrieveSearchabilitiesV2- Retrieve searchabilities with filtering/paginationGetSearchabilityV2- Get a specific searchability by namePatchSearchabilitiesV2- Batch create or update searchabilitiesPatchSearchabilityV2- Update a single searchabilityDeleteSearchabilitiesV2- Batch delete searchabilitiesDeleteSearchabilityV2- Delete a single searchabilityNew Models
FacetV2- V2 facet model with new fields (Countable,OptionsLimit,Hierarchicaltype,CreatedAt,UpdatedAt)FacetTypeV2- Enum addingHierarchicaltypeFacetV2GetAllResponse- Response wrapper for listing facetsSearchabilityV2- V2 searchability model with new fields (Displayable,Hidden,CreatedAt,UpdatedAt)SearchabilitiesV2Response- Response wrapper for searchabilities operationsRetrieveSearchabilitiesV2Request- Request object with filtering/sorting optionsPatchSearchabilitiesV2Request- Request object for batch create/updateDeleteSearchabilitiesV2Request- Request object for batch deleteV2 API Differences from V1
Facets:
Hierarchicalfacet typeCountablefield (skip counting for high-cardinality facets)OptionsLimitfield (limit options returned in search)CreatedAt/UpdatedAttimestampspath_in_metadatainstead of inferring from nameSearchabilities:
percentage_presence,example_items, andtypefieldsDisplayableandHiddenfieldsCreatedAt/UpdatedAttimestampsTest Plan
FacetTestsV2.cswith 15 test cases covering all facet operationsSearchabilityTestsV2.cswith 12 test cases covering all searchability operationsOneTimeTearDownBreaking Changes
None. V2 methods are additive and V1 methods remain unchanged.