Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SP-13357: Add extra abstraction #57

Merged
merged 4 commits into from
Jan 30, 2024
Merged
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
23 changes: 19 additions & 4 deletions src/Regula.FaceSDK.IdentificationExample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,37 @@ public static void Main(string[] args)
var sdk = new FaceSdk(apiBasePath);

var person1Id = sdk.PersonApi.CreatePerson(
new PersonFields(name:"person1", metadata:new Dictionary<string, object>())).Id;
new PersonFields(name:"person1")).Id;
var person2Id = sdk.PersonApi.CreatePerson(
new PersonFields(name:"person1", metadata:new Dictionary<string, object>())).Id;
new PersonFields(name:"person1")).Id;

sdk.PersonApi.AddImageToPerson(person1Id, new ImageFields(image:new ImageFieldsImage(content: face1)));
sdk.PersonApi.AddImageToPerson(person2Id, new ImageFields(image:new ImageFieldsImage(content: face2)));

var person1 = sdk.PersonApi.GetPerson(person1Id);
var person2 = sdk.PersonApi.GetPerson(person2Id);

var group = sdk.GroupApi.CreateGroup(new GroupToCreate(name: "group1", metadata: new Dictionary<string, object>()));
var group = sdk.GroupApi.CreateGroup(new GroupToCreate(name: "group1"));

sdk.GroupApi.UpdatePersonsInGroup(
group.Id,
new UpdateGroup(addItems: new List<Guid>() {person1Id, person2Id})
);
// Authorization:
//var authHeaders = new Dictionary<string, string>()
//{
// { "Authorization", $"Basic {Convert.ToBase64String(Encoding.UTF8.GetBytes("USER:PASSWORD"))}" }
//};
//var response = sdk.SearchApi.Search(
// new SearchRequest(
// groupIds: new List<Guid>() { },
// image: new ImageFieldsImage(content: face1),
// limit: 10,
// threshold: 0.8f
// ),
// headers: authHeaders
// );

var searchResult = sdk.SearchApi.Search(
new SearchRequest(
groupIds: new List<Guid>() {},
Expand All @@ -44,7 +59,7 @@ public static void Main(string[] args)
threshold: 0.8f
)
);

Console.WriteLine($"Person #1 {person1.Id} {person1.Name}");
Console.WriteLine($"Person #2 {person2.Id} {person2.Name}");
Console.WriteLine($"Group {group.Id} {group.Name}");
Expand Down
8 changes: 4 additions & 4 deletions src/Regula.FaceSDK.WebClient/Api/FaceSdk.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Regula.FaceSDK.WebClient.Client;

using Regula.FaceSDK.WebClient.Ext;

namespace Regula.FaceSDK.WebClient.Api
{
Expand All @@ -18,9 +18,9 @@ public FaceSdk(string basePath)
Configuration config = new Configuration() {BasePath = basePath};
this.ApiClient = new ApiClient(){Configuration = config};
this.MatchingApi = new MatchingApi(config);
this.GroupApi = new GroupApi(config);
this.PersonApi = new PersonApi(config);
this.SearchApi = new SearchApi(config);
this.GroupApi = new GroupApiGateway(config);
this.PersonApi = new PersonApiGateway(config);
this.SearchApi = new SearchApiGateway(config);
}

public FaceSdk(ApiClient apiClient)
Expand Down
2 changes: 1 addition & 1 deletion src/Regula.FaceSDK.WebClient/Api/GroupApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ public void AddDefaultHeader(string key, string value)
/// <param name="groupToCreate">Request body for the group to create.</param>
/// <param name="xRequestID">Request header label. (optional)</param>
/// <returns>Group</returns>
public Group CreateGroup (GroupToCreate groupToCreate, string xRequestID = default(string))
public virtual Group CreateGroup (GroupToCreate groupToCreate, string xRequestID = default(string))
{
ApiResponse<Group> localVarResponse = CreateGroupWithHttpInfo(groupToCreate, xRequestID);
return localVarResponse.Data;
Expand Down
2 changes: 1 addition & 1 deletion src/Regula.FaceSDK.WebClient/Api/PersonApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ public void AddDefaultHeader(string key, string value)
/// <param name="personFields"></param>
/// <param name="xRequestID">Request header label. (optional)</param>
/// <returns>Person</returns>
public Person CreatePerson (PersonFields personFields, string xRequestID = default(string))
public virtual Person CreatePerson (PersonFields personFields, string xRequestID = default(string))
{
ApiResponse<Person> localVarResponse = CreatePersonWithHttpInfo(personFields, xRequestID);
return localVarResponse.Data;
Expand Down
20 changes: 20 additions & 0 deletions src/Regula.FaceSDK.WebClient/Ext/GroupApiGateway.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using Regula.FaceSDK.WebClient.Api;
using Regula.FaceSDK.WebClient.Model;

namespace Regula.FaceSDK.WebClient.Ext
{
public class GroupApiGateway: GroupApi
{
public GroupApiGateway() : base() { }
public GroupApiGateway(String basePath) : base(basePath) { }
public GroupApiGateway(Regula.FaceSDK.WebClient.Client.Configuration configuration = null) : base(configuration) { }

public override Group CreateGroup(GroupToCreate groupToCreate, string xRequestID = null)
{
groupToCreate.Metadata ??= new Dictionary<string, object>();
return base.CreateGroup(groupToCreate, xRequestID);
}
}
}
20 changes: 20 additions & 0 deletions src/Regula.FaceSDK.WebClient/Ext/PersonApiGateway.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using Regula.FaceSDK.WebClient.Api;
using Regula.FaceSDK.WebClient.Model;

namespace Regula.FaceSDK.WebClient.Ext
{
public class PersonApiGateway: PersonApi
{
public PersonApiGateway() : base() { }
public PersonApiGateway(String basePath) : base(basePath) { }
public PersonApiGateway(Regula.FaceSDK.WebClient.Client.Configuration configuration = null) : base(configuration) { }

public override Person CreatePerson(PersonFields personFields, string xRequestID = null)
{
personFields.Metadata ??= new Dictionary<string, object>();
return base.CreatePerson(personFields, xRequestID);
}
}
}
14 changes: 14 additions & 0 deletions src/Regula.FaceSDK.WebClient/Ext/SearchApiGateway.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using Regula.FaceSDK.WebClient.Api;
using Regula.FaceSDK.WebClient.Model;

namespace Regula.FaceSDK.WebClient.Ext
{
public class SearchApiGateway : SearchApi
{
public SearchApiGateway() : base() { }
public SearchApiGateway(String basePath) : base(basePath) { }
public SearchApiGateway(Regula.FaceSDK.WebClient.Client.Configuration configuration = null) : base(configuration) { }
}
}

Loading