feat: Dokumenterstellungs-Methoden zu DocumentsRouteService hinzugefügt und Modelle aktualisiert

- Zwei `Create`-Methoden in `DocumentsRouteService` hinzugefügt, um die Dokumentenerstellung über HTTP-POST-Anfragen zu ermöglichen.
- `int`-Felder im `DocCreateBody`-Modell in `int?` umgewandelt, um mögliche Nullwerte vom Server zu berücksichtigen.
- Die neue Dokumenterstellungsfunktion in WindreamClientService integriert.
This commit is contained in:
Developer 02 2024-09-13 00:40:06 +02:00
parent 152b4f7cff
commit 39e78821cf
15 changed files with 41 additions and 21 deletions

View File

@ -6,6 +6,6 @@ namespace WindreamHub.Legacy.Client.Models.Authentication
{
public ErrorItem Item { get; set; }
public string Message { get; set; }
public int ErrorCode { get; set; }
public int? ErrorCode { get; set; }
}
}

View File

@ -4,7 +4,7 @@ namespace WindreamHub.Legacy.Client.Models.Authentication
{
public class ValidationResponse
{
public int UserID { get; set; }
public int? UserID { get; set; }
public string UserName { get; set; }
public string FullUserName { get; set; }
public bool IsValidUser { get; set; }

View File

@ -4,6 +4,6 @@
{
public Item Item { get; set; }
public bool CreateFolder { get; set; }
public int ResponseDetails { get; set; }
public int? ResponseDetails { get; set; }
}
}

View File

@ -2,7 +2,7 @@
{
public class ObjectType
{
public int Id { get; set; }
public int? Id { get; set; }
public string Name { get; set; }
}
}

View File

@ -5,17 +5,17 @@
public string Name { get; set; }
public string DisplayName { get; set; }
public object Value { get; set; }
public int Type { get; set; }
public int UnderlyingType { get; set; }
public int? Type { get; set; }
public int? UnderlyingType { get; set; }
public string Column { get; set; }
public bool IsSystem { get; set; }
public bool IsSortable { get; set; }
public VectorDetails VectorDetails { get; set; }
public TypeSpecificDetails TypeSpecificDetails { get; set; }
public int MaxSize { get; set; }
public int? MaxSize { get; set; }
public bool AlwaysModifiable { get; set; }
public int PreDigits { get; set; }
public int PostDigits { get; set; }
public int? PreDigits { get; set; }
public int? PostDigits { get; set; }
public bool IsFulltext { get; set; }
}
}

View File

@ -6,6 +6,6 @@ namespace WindreamHub.Legacy.Client.Models.Documents.Response
{
public ErrorItem Item { get; set; }
public string Message { get; set; }
public int ErrorCode { get; set; }
public int? ErrorCode { get; set; }
}
}

View File

@ -7,9 +7,9 @@ namespace WindreamHub.Legacy.Client.Models.Documents.Response
public List<Attribute> Attributes { get; set; }
public ObjectType ObjectType { get; set; }
public ParentWindreamObject ParentWindreamObject { get; set; }
public int Entity { get; set; }
public int? Entity { get; set; }
public string LocationComplete { get; set; }
public int Id { get; set; }
public int? Id { get; set; }
public string Location { get; set; }
public string Name { get; set; }
}

View File

@ -2,7 +2,7 @@
{
public class ObjectType
{
public int Id { get; set; }
public int? Id { get; set; }
public string Name { get; set; }
}
}

View File

@ -3,7 +3,7 @@
public class ParentWindreamObject
{
public string LocationComplete { get; set; }
public int Id { get; set; }
public int? Id { get; set; }
public string Location { get; set; }
public string Name { get; set; }
}

View File

@ -2,6 +2,6 @@
{
public class VectorDetails
{
public int EntriesLimit { get; set; }
public int? EntriesLimit { get; set; }
}
}

View File

@ -4,6 +4,7 @@ using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using System.Text;
namespace WindreamHub.Legacy.Client.Models
{
@ -91,6 +92,12 @@ namespace WindreamHub.Legacy.Client.Models
});
}
public static string Stringify(this object model) => JsonConvert.SerializeObject(model);
public static string Serialize(this object model) => JsonConvert.SerializeObject(model);
public static HttpContent ToContent(this string json, Encoding encoding = null, string mediaType = "application/json")
=> new StringContent(json, encoding ?? Encoding.UTF8, mediaType);
public static HttpContent Stringify(this object model, Encoding encoding = null, string mediaType = "application/json")
=> model.Serialize().ToContent(encoding ?? Encoding.UTF8, mediaType);
}
}

View File

@ -2,8 +2,8 @@
{
public class ErrorItem
{
public int Entity { get; set; }
public int Id { get; set; }
public int? Entity { get; set; }
public int? Id { get; set; }
public string Location { get; set; }
public string Name { get; set; }
}

View File

@ -8,6 +8,6 @@
public string DefaultDomain { get; set; }
public int AuthenticationModes { get; set; }
public int? AuthenticationModes { get; set; }
}
}

View File

@ -1,6 +1,11 @@
using Microsoft.Extensions.Options;
using System.Net;
using System.Net.Http;
using DigitalData.Core.Legacy.Client;
using System.Threading.Tasks;
using WindreamHub.Legacy.Client.Models;
using WindreamHub.Legacy.Client.Models.Documents.Response;
using WindreamHub.Legacy.Client.Models.Documents.Request;
namespace WindreamHub.Legacy.Client.Routes
{
@ -9,5 +14,13 @@ namespace WindreamHub.Legacy.Client.Routes
public DocumentsRouteService(HttpClient client, CookieContainer cookieContainer, IOptions<WindreamClientOptions> clientOptions) : base(client, cookieContainer, clientOptions)
{
}
public async Task<SimplifiedResponse<DocCreatResponse, object>> Create(HttpContent docCreateBody)
=> await FetchAsync(route: "/Create", method: HttpMethod.Post, body: docCreateBody)
.ThenAsync(res => res.Simplify<DocCreatResponse, object>());
public async Task<SimplifiedResponse<DocCreatResponse, object>> Create(DocCreateBody docCreateBody)
=> await FetchAsync(route: "/Create", method: HttpMethod.Post, body: docCreateBody.Stringify())
.ThenAsync(res => res.Simplify<DocCreatResponse, object>());
}
}

View File

@ -13,13 +13,13 @@ namespace WindreamHub.Legacy.Client
{
public class WindreamClientService : HttpClientService<WindreamClientOptions>
{
public WindreamClientService(SubscriptionsRouteService subscriptions, SystemDetailsRouteService systemDetails, AuthenticationRouteService authentication,
HttpClient client, CookieContainer cookieContainer, IOptions<WindreamClientOptions> clientOptions) :
public WindreamClientService(SubscriptionsRouteService subscriptions, SystemDetailsRouteService systemDetails, AuthenticationRouteService authentication, DocumentsRouteService documents, HttpClient client, CookieContainer cookieContainer, IOptions<WindreamClientOptions> clientOptions) :
base(client, cookieContainer, clientOptions)
{
Subscriptions = subscriptions;
SystemDetails = systemDetails;
Authentication = authentication;
Documents = documents;
}
public SubscriptionsRouteService Subscriptions { get; }