From 7a9c81db49ea425fcf2933f3dffd9f14ad5a6fb8 Mon Sep 17 00:00:00 2001 From: Leontev Daniil Date: Thu, 5 Dec 2024 10:52:21 +0500 Subject: [PATCH 1/3] add method --- .../ClusterClientAdapters/HttpRequestFactory.cs | 2 ++ .../HttpRequestFactoryRecipesExtension.cs | 9 +++++++++ .../IHttpRequestFactory.cs | 1 + .../ApiLevel/Clients/Docflows/DocflowsClient.cs | 4 ++++ .../ApiLevel/Clients/Docflows/IDocflowsClient.cs | 13 +++++++++++++ .../Client/DocumentPathExtension.cs | 7 +++++++ .../Kontur.Extern.Api.Client.csproj | 1 + 7 files changed, 37 insertions(+) diff --git a/src/Kontur.Extern.Api.Client.Http/ClusterClientAdapters/HttpRequestFactory.cs b/src/Kontur.Extern.Api.Client.Http/ClusterClientAdapters/HttpRequestFactory.cs index c54bab10..8afd8410 100644 --- a/src/Kontur.Extern.Api.Client.Http/ClusterClientAdapters/HttpRequestFactory.cs +++ b/src/Kontur.Extern.Api.Client.Http/ClusterClientAdapters/HttpRequestFactory.cs @@ -43,6 +43,8 @@ public HttpRequestFactory( public IPayloadHttpRequest Put(Uri url) => CreateHttpRequest(Request.Put(url)); + public IPayloadHttpRequest Patch(Uri url) => CreateHttpRequest(Request.Patch(url)); + public IPayloadHttpRequest Post(Uri url) => CreateHttpRequest(Request.Post(url)); public IHttpRequest Delete(Uri url) => CreateHttpRequest(Request.Delete(url)); diff --git a/src/Kontur.Extern.Api.Client.Http/HttpRequestFactoryRecipesExtension.cs b/src/Kontur.Extern.Api.Client.Http/HttpRequestFactoryRecipesExtension.cs index f0972e39..d3c6742a 100644 --- a/src/Kontur.Extern.Api.Client.Http/HttpRequestFactoryRecipesExtension.cs +++ b/src/Kontur.Extern.Api.Client.Http/HttpRequestFactoryRecipesExtension.cs @@ -108,6 +108,15 @@ public static async Task PostAsync(this IHttpRequest return await response.GetMessageAsync().ConfigureAwait(false); } + public static async Task PatchAsync(this IHttpRequestFactory httpRequestFactory, string url, TimeoutSpecification timeout = default) + { + if (url == null) + throw new ArgumentNullException(nameof(url)); + + var response = await httpRequestFactory.Patch(url.ToUrl()).SendAsync(timeout).ConfigureAwait(false); + return await response.GetMessageAsync().ConfigureAwait(false); + } + public static async Task RawPostAsync( this IHttpRequestFactory httpRequestFactory, Uri url, diff --git a/src/Kontur.Extern.Api.Client.Http/IHttpRequestFactory.cs b/src/Kontur.Extern.Api.Client.Http/IHttpRequestFactory.cs index 712dbdf6..c6b6dbf8 100644 --- a/src/Kontur.Extern.Api.Client.Http/IHttpRequestFactory.cs +++ b/src/Kontur.Extern.Api.Client.Http/IHttpRequestFactory.cs @@ -9,6 +9,7 @@ public interface IHttpRequestFactory IHttpRequest Get(Uri url); IPayloadHttpRequest Put(Uri url); IPayloadHttpRequest Post(Uri url); + IPayloadHttpRequest Patch (Uri url); IHttpRequest Delete(Uri url); IPayloadHttpRequest Verb(string method, Uri url); } diff --git a/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/DocflowsClient.cs b/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/DocflowsClient.cs index 2a08c5c7..73cc7a24 100644 --- a/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/DocflowsClient.cs +++ b/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/DocflowsClient.cs @@ -10,6 +10,7 @@ using Kontur.Extern.Api.Client.Models.Docflows.Documents; using Kontur.Extern.Api.Client.Http; using Kontur.Extern.Api.Client.Models.Docflows.DocumentsRequests; +using Microsoft.AspNetCore.JsonPatch; using Vostok.Clusterclient.Core.Model; // ReSharper disable CommentTypo @@ -85,6 +86,9 @@ public Task GetDocumentAsync(Guid accountId, Guid docflowId, Guid docu public Task TryGetDocumentAsync(Guid accountId, Guid docflowId, Guid documentId, TimeSpan? timeout = null) => http.TryGetAsync($"/v1/{accountId}/docflows/{docflowId}/documents/{documentId}", timeout); + public Task PatchDocumentAsync(Guid accountId, Guid docflowId, Guid documentId, JsonPatchDocument patch, TimeSpan? timeout = null) => + http.PatchAsync($"/v1/{accountId}/docflows/{docflowId}/documents/{documentId}", timeout); + public Task GetDocumentDescriptionAsync( Guid accountId, Guid docflowId, diff --git a/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/IDocflowsClient.cs b/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/IDocflowsClient.cs index aa2bb1d0..eec7bce8 100644 --- a/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/IDocflowsClient.cs +++ b/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/IDocflowsClient.cs @@ -10,6 +10,7 @@ using Kontur.Extern.Api.Client.Models.Docflows; using Kontur.Extern.Api.Client.Models.Docflows.Documents; using Kontur.Extern.Api.Client.Models.Docflows.DocumentsRequests; +using Microsoft.AspNetCore.JsonPatch; namespace Kontur.Extern.Api.Client.ApiLevel.Clients.Docflows { @@ -137,6 +138,18 @@ Task GetInventoryDocflowAsync( /// Документ из документооборота или null Task TryGetDocumentAsync(Guid accountId, Guid docflowId, Guid documentId, TimeSpan? timeout = null); + + /// + /// Изменение реквизитов документа требования + /// + /// Идентификатор учетной записи + /// Идентификатор документооборота + /// Идентификатор документа + /// Список операций для изменения реквизитов + /// + /// Документ из документооборота + Task PatchDocumentAsync(Guid accountId, Guid docflowId, Guid documentId, JsonPatchDocument patch, TimeSpan? timeout = null); + /// /// Получение описания документа /// diff --git a/src/Kontur.Extern.Api.Client/Client/DocumentPathExtension.cs b/src/Kontur.Extern.Api.Client/Client/DocumentPathExtension.cs index 952da32f..5bc7f5b3 100644 --- a/src/Kontur.Extern.Api.Client/Client/DocumentPathExtension.cs +++ b/src/Kontur.Extern.Api.Client/Client/DocumentPathExtension.cs @@ -13,6 +13,7 @@ using Kontur.Extern.Api.Client.Models.Docflows.Documents.Replies; using Kontur.Extern.Api.Client.Paths; using Kontur.Extern.Api.Client.Primitives; +using Microsoft.AspNetCore.JsonPatch; namespace Kontur.Extern.Api.Client { @@ -30,6 +31,12 @@ public static Task GetAsync(this in DocumentPath path, TimeSpan? timeo var apiClient = path.Services.Api; return apiClient.Docflows.GetDocumentAsync(path.AccountId, path.DocflowId, path.DocumentId, timeout); } + + public static Task PatchAsync(this in DocumentPath path, JsonPatchDocument patch, TimeSpan? timeout = null) + { + var apiClient = path.Services.Api; + return apiClient.Docflows.PatchDocumentAsync(path.AccountId, path.DocflowId, path.DocumentId, patch, timeout); + } public static IEntityList RelatedDocflowsList(this in DocumentPath path, DocflowFilterBuilder? filterBuilder = null) { diff --git a/src/Kontur.Extern.Api.Client/Kontur.Extern.Api.Client.csproj b/src/Kontur.Extern.Api.Client/Kontur.Extern.Api.Client.csproj index 98ef3234..0d6c3e43 100644 --- a/src/Kontur.Extern.Api.Client/Kontur.Extern.Api.Client.csproj +++ b/src/Kontur.Extern.Api.Client/Kontur.Extern.Api.Client.csproj @@ -15,6 +15,7 @@ + From 93a615ff62380317cd715976a2cf0ef2ae25db61 Mon Sep 17 00:00:00 2001 From: Leontev Daniil Date: Thu, 5 Dec 2024 17:34:53 +0500 Subject: [PATCH 2/3] =?UTF-8?q?=D0=9F=D0=B0=D1=82=D1=87=20=D0=B4=D0=BE,=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D1=80=D0=B5=D0=B2=D1=8C?= =?UTF-8?q?=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HttpRequestFactoryRecipesExtension.cs | 20 +++- .../Kontur.Extern.Api.Client.Http.csproj | 1 + .../Clients/Docflows/DocflowsClient.cs | 5 +- .../Clients/Docflows/IDocflowsClient.cs | 10 ++ .../Client/DocflowPathExtension.cs | 7 ++ .../Descriptions/DocflowDescription.cs | 5 + .../Descriptions/DocflowRequisites.cs | 37 ++++++ .../Requisites/DemandAttachmentRequisites.cs | 107 +++++++++++++++++- 8 files changed, 186 insertions(+), 6 deletions(-) create mode 100644 src/Kontur.Extern.Api.Client/Models/Docflows/Descriptions/DocflowRequisites.cs diff --git a/src/Kontur.Extern.Api.Client.Http/HttpRequestFactoryRecipesExtension.cs b/src/Kontur.Extern.Api.Client.Http/HttpRequestFactoryRecipesExtension.cs index d3c6742a..50b7ccdb 100644 --- a/src/Kontur.Extern.Api.Client.Http/HttpRequestFactoryRecipesExtension.cs +++ b/src/Kontur.Extern.Api.Client.Http/HttpRequestFactoryRecipesExtension.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using Microsoft.AspNetCore.JsonPatch; namespace Kontur.Extern.Api.Client.Http { @@ -108,15 +109,26 @@ public static async Task PostAsync(this IHttpRequest return await response.GetMessageAsync().ConfigureAwait(false); } - public static async Task PatchAsync(this IHttpRequestFactory httpRequestFactory, string url, TimeoutSpecification timeout = default) + public static async Task PatchAsync(this IHttpRequestFactory httpRequestFactory, string url, TRequestDto requestDto, TimeoutSpecification timeout = default) { if (url == null) throw new ArgumentNullException(nameof(url)); - - var response = await httpRequestFactory.Patch(url.ToUrl()).SendAsync(timeout).ConfigureAwait(false); + + return await PatchAsync(httpRequestFactory, url.ToUrl(), requestDto, timeout).ConfigureAwait(false); + } + + public static async Task PatchAsync(this IHttpRequestFactory httpRequestFactory, Uri url, TRequestDto requestDto, TimeoutSpecification timeout = default) + { + if (requestDto is null) + throw new ArgumentNullException(nameof(requestDto)); + + var response = await httpRequestFactory.Patch(url) + .WithObject(requestDto) + .SendAsync(timeout).ConfigureAwait(false); + return await response.GetMessageAsync().ConfigureAwait(false); } - + public static async Task RawPostAsync( this IHttpRequestFactory httpRequestFactory, Uri url, diff --git a/src/Kontur.Extern.Api.Client.Http/Kontur.Extern.Api.Client.Http.csproj b/src/Kontur.Extern.Api.Client.Http/Kontur.Extern.Api.Client.Http.csproj index 1e850269..a1cb768b 100644 --- a/src/Kontur.Extern.Api.Client.Http/Kontur.Extern.Api.Client.Http.csproj +++ b/src/Kontur.Extern.Api.Client.Http/Kontur.Extern.Api.Client.Http.csproj @@ -10,6 +10,7 @@ + diff --git a/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/DocflowsClient.cs b/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/DocflowsClient.cs index 73cc7a24..bb42e742 100644 --- a/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/DocflowsClient.cs +++ b/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/DocflowsClient.cs @@ -87,7 +87,10 @@ public Task GetDocumentAsync(Guid accountId, Guid docflowId, Guid docu http.TryGetAsync($"/v1/{accountId}/docflows/{docflowId}/documents/{documentId}", timeout); public Task PatchDocumentAsync(Guid accountId, Guid docflowId, Guid documentId, JsonPatchDocument patch, TimeSpan? timeout = null) => - http.PatchAsync($"/v1/{accountId}/docflows/{docflowId}/documents/{documentId}", timeout); + http.PatchAsync, Document>($"/v1/{accountId}/docflows/{docflowId}/documents/{documentId}", patch, timeout); + + public Task PatchDocflowAsync(Guid accountId, Guid docflowId, JsonPatchDocument patch, TimeSpan? timeout = null) => + http.PatchAsync, IDocflowWithDocuments>($"/v1/{accountId}/docflows/{docflowId}", patch, timeout); public Task GetDocumentDescriptionAsync( Guid accountId, diff --git a/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/IDocflowsClient.cs b/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/IDocflowsClient.cs index eec7bce8..aad548cd 100644 --- a/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/IDocflowsClient.cs +++ b/src/Kontur.Extern.Api.Client/ApiLevel/Clients/Docflows/IDocflowsClient.cs @@ -150,6 +150,16 @@ Task GetInventoryDocflowAsync( /// Документ из документооборота Task PatchDocumentAsync(Guid accountId, Guid docflowId, Guid documentId, JsonPatchDocument patch, TimeSpan? timeout = null); + /// + /// Изменение реквизитов документооборота + /// + /// Идентификатор учетной записи + /// Идентификатор документооборота + /// Список операций для изменения реквизитов + /// + /// Документооборот + Task PatchDocflowAsync(Guid accountId, Guid docflowId, JsonPatchDocument patch, TimeSpan? timeout = null); + /// /// Получение описания документа /// diff --git a/src/Kontur.Extern.Api.Client/Client/DocflowPathExtension.cs b/src/Kontur.Extern.Api.Client/Client/DocflowPathExtension.cs index f5cd3d30..323fa248 100644 --- a/src/Kontur.Extern.Api.Client/Client/DocflowPathExtension.cs +++ b/src/Kontur.Extern.Api.Client/Client/DocflowPathExtension.cs @@ -5,6 +5,7 @@ using Kontur.Extern.Api.Client.Models.Docflows; using Kontur.Extern.Api.Client.Models.Docflows.DocumentsRequests; using Kontur.Extern.Api.Client.Paths; +using Microsoft.AspNetCore.JsonPatch; namespace Kontur.Extern.Api.Client { @@ -23,6 +24,12 @@ public static Task GetAsync(this in DocflowPath path, Tim return apiClient.Docflows.TryGetDocflowAsync(path.AccountId, path.DocflowId, timeout); } + public static Task PatchAsync(this in DocflowPath path, JsonPatchDocument patch, TimeSpan? timeout = null) + { + var apiClient = path.Services.Api; + return apiClient.Docflows.PatchDocflowAsync(path.AccountId, path.DocflowId, patch, timeout); + } + public static Task GenerateDocumentsRequestAsync(this in DocflowPath path, CertificateContent certificate, TimeSpan? timeout = null) { var apiClient = path.Services.Api; diff --git a/src/Kontur.Extern.Api.Client/Models/Docflows/Descriptions/DocflowDescription.cs b/src/Kontur.Extern.Api.Client/Models/Docflows/Descriptions/DocflowDescription.cs index dfaf86e7..c26bdf16 100644 --- a/src/Kontur.Extern.Api.Client/Models/Docflows/Descriptions/DocflowDescription.cs +++ b/src/Kontur.Extern.Api.Client/Models/Docflows/Descriptions/DocflowDescription.cs @@ -12,5 +12,10 @@ public abstract class DocflowDescription /// Идентификатор черновика документооборота, если он был создан через API /// public Guid? OriginalDraftId { get; set; } + + /// + /// Реквизиты документооборота + /// + public DocflowRequisites? Requisites { get; set; } } } \ No newline at end of file diff --git a/src/Kontur.Extern.Api.Client/Models/Docflows/Descriptions/DocflowRequisites.cs b/src/Kontur.Extern.Api.Client/Models/Docflows/Descriptions/DocflowRequisites.cs new file mode 100644 index 00000000..031e75e8 --- /dev/null +++ b/src/Kontur.Extern.Api.Client/Models/Docflows/Descriptions/DocflowRequisites.cs @@ -0,0 +1,37 @@ +using JetBrains.Annotations; + +namespace Kontur.Extern.Api.Client.Models.Docflows.Descriptions; + +[PublicAPI] +public class DocflowRequisites +{ + /// + /// Комментарий к документообороту + /// + public Comment? Comment { get; set; } +} + +[PublicAPI] +public class Comment +{ + /// + /// Текст комментария + /// + public string Text { get; set; } = null!; + + /// + /// Цвет комментария для веб-интерфейса Контур.Экстерна + /// + public CommentColor Color { get; set; } +} + +public enum CommentColor +{ + None, + Red, + Violet, + Gray, + Yellow, + Green, + Blue +} \ No newline at end of file diff --git a/src/Kontur.Extern.Api.Client/Models/Docflows/Documents/Requisites/DemandAttachmentRequisites.cs b/src/Kontur.Extern.Api.Client/Models/Docflows/Documents/Requisites/DemandAttachmentRequisites.cs index ebdb0652..f4eb410d 100644 --- a/src/Kontur.Extern.Api.Client/Models/Docflows/Documents/Requisites/DemandAttachmentRequisites.cs +++ b/src/Kontur.Extern.Api.Client/Models/Docflows/Documents/Requisites/DemandAttachmentRequisites.cs @@ -1,4 +1,6 @@ -using System.Diagnostics.CodeAnalysis; +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using JetBrains.Annotations; using Kontur.Extern.Api.Client.Common.Time; using Kontur.Extern.Api.Client.Models.Numbers; @@ -39,5 +41,108 @@ public class DemandAttachmentRequisites : DocflowDocumentRequisites /// Список ИНН, содержащихся в требовании /// public string[] DemandInnList { get; set; } = null!; + + /// + /// Наименование налогового органа + /// + public string? TaxDepartmentName { get; set; } + + /// + /// Наименование мероприятия налогового контроля + /// + public string? TaxEventName { get; set; } + + /// + /// Комментарий + /// + public Comment? Comment { get; set; } + + /// + /// Метки + /// + public List