diff --git a/src/Mindee/V2/Parsing/Search/ModelWebhook.cs b/src/Mindee/V2/Parsing/Search/ModelWebhook.cs
new file mode 100644
index 00000000..393b1c79
--- /dev/null
+++ b/src/Mindee/V2/Parsing/Search/ModelWebhook.cs
@@ -0,0 +1,37 @@
+using System.Text.Json.Serialization;
+
+namespace Mindee.V2.Parsing.Search
+{
+ ///
+ /// Information about a model's webhook.
+ ///
+ public class ModelWebhook
+ {
+ ///
+ /// ID of the webhook.
+ ///
+ [JsonPropertyName("id")]
+ public string Id { get; set; }
+
+ ///
+ /// Name of the webhook.
+ ///
+ [JsonPropertyName("name")]
+ public string Name { get; set; }
+
+ ///
+ /// URL of the webhook.
+ ///
+ [JsonPropertyName("url")]
+ public string Url { get; set; }
+
+ ///
+ /// String representation of the webhook.
+ ///
+ ///
+ public override string ToString()
+ {
+ return $":Name: {Name}\n:ID: {Id}\n:URL: {Url}";
+ }
+ }
+}
diff --git a/src/Mindee/V2/Parsing/Search/PaginationMetadata.cs b/src/Mindee/V2/Parsing/Search/PaginationMetadata.cs
index 7a35ad60..06179c2e 100644
--- a/src/Mindee/V2/Parsing/Search/PaginationMetadata.cs
+++ b/src/Mindee/V2/Parsing/Search/PaginationMetadata.cs
@@ -4,10 +4,11 @@
namespace Mindee.V2.Parsing.Search
{
///
- /// PaginationMetadata data associated with model search.
+ /// Pagination metadata associated with model search.
///
public class PaginationMetadata
{
+
///
/// Number of items per page.
///
diff --git a/src/Mindee/V2/Parsing/Search/SearchModel.cs b/src/Mindee/V2/Parsing/Search/SearchModel.cs
index 55312939..adf07556 100644
--- a/src/Mindee/V2/Parsing/Search/SearchModel.cs
+++ b/src/Mindee/V2/Parsing/Search/SearchModel.cs
@@ -1,3 +1,4 @@
+using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace Mindee.V2.Parsing.Search
@@ -25,6 +26,12 @@ public class SearchModel
[JsonPropertyName("model_type")]
public string ModelType { get; set; }
+ ///
+ /// List of webhooks associated with the model.
+ ///
+ [JsonPropertyName("webhooks")]
+ public List Webhooks { get; set; }
+
///
/// String representation of the model.
///
diff --git a/src/Mindee/V2/Parsing/Search/SearchResponse.cs b/src/Mindee/V2/Parsing/Search/SearchResponse.cs
index 0875511f..3a204307 100644
--- a/src/Mindee/V2/Parsing/Search/SearchResponse.cs
+++ b/src/Mindee/V2/Parsing/Search/SearchResponse.cs
@@ -1,3 +1,4 @@
+using System;
using System.Text;
using System.Text.Json.Serialization;
using Mindee.Parsing;
@@ -8,7 +9,7 @@ namespace Mindee.V2.Parsing.Search
///
/// Models search response.
///
- public class SearchResponse
+ public class SearchResponse : BaseResponse
{
///
/// List of all models matching the search query.
@@ -18,10 +19,21 @@ public class SearchResponse
public SearchModels Models { get; set; }
///
- /// PaginationMetadata metadata.
+ /// Pagination metadata (Obsolete).
+ ///
+ [JsonIgnore]
+ [Obsolete("Use Pagination instead.")]
+ public PaginationMetadata PaginationMetadata
+ {
+ get => Pagination;
+ set => Pagination = value;
+ }
+
+ ///
+ /// Pagination metadata.
///
[JsonPropertyName("pagination")]
- public PaginationMetadata PaginationMetadata { get; set; }
+ public PaginationMetadata Pagination { get; set; }
///
@@ -35,7 +47,7 @@ public override string ToString()
stringBuilder.Append('\n');
stringBuilder.Append("Pagination Metadata\n");
stringBuilder.Append("###################\n");
- stringBuilder.Append(PaginationMetadata);
+ stringBuilder.Append(Pagination);
stringBuilder.Append('\n');
return SummaryHelper.Clean(stringBuilder.ToString());
diff --git a/tests/Mindee.UnitTests/V2/Parsing/SearchTest.cs b/tests/Mindee.UnitTests/V2/Parsing/SearchTest.cs
new file mode 100644
index 00000000..ca813868
--- /dev/null
+++ b/tests/Mindee.UnitTests/V2/Parsing/SearchTest.cs
@@ -0,0 +1,39 @@
+using Mindee.V2.Parsing;
+using Mindee.V2.Parsing.Search;
+
+namespace Mindee.UnitTests.V2.Parsing
+{
+ [Trait("Category", "V2")]
+ [Trait("Category", "Search")]
+ public class SearchTest
+ {
+ [Fact]
+ public void SearchModels_LoadsLocally()
+ {
+ var localResponse = new LocalResponse(
+ new FileInfo(Constants.V2RootDir + "search/models.json"));
+ SearchResponse modelsResponse = localResponse.DeserializeResponse();
+
+ Assert.NotNull(modelsResponse);
+
+ Assert.Equal(5, modelsResponse.Models.Count);
+ Assert.Equal(5, modelsResponse.Pagination.TotalItems);
+ Assert.Equal(1, modelsResponse.Pagination.Page);
+ Assert.Equal(50, modelsResponse.Pagination.PerPage);
+ Assert.Equal(1, modelsResponse.Pagination.TotalPages);
+
+ var firstModel = modelsResponse.Models.First();
+ Assert.Equal("Extraction With Webhooks", firstModel.Name);
+ Assert.Equal("afde5151-aa11-aa11-9289-fa04e50ca3b9", firstModel.Id);
+ Assert.Equal("extraction", firstModel.ModelType);
+
+ Assert.Equal(2, firstModel.Webhooks.Count);
+ Assert.Equal("a2286ed9-aa11-aa11-bdc5-2f8496c5641a", firstModel.Webhooks[0].Id);
+ Assert.Equal("FAILURE", firstModel.Webhooks[0].Name);
+ Assert.Equal("https://failure.mindee.com", firstModel.Webhooks[0].Url);
+ var lastModel = modelsResponse.Models.Last();
+ Assert.Equal("Extraction Without Webhooks Key", lastModel.Name);
+ Assert.Equal("e14e0923-ee55-ee55-a335-8d2110917d7b", lastModel.Id);
+ }
+ }
+}