Skip to content

Commit

Permalink
Merge pull request #598 from diadoc/detect-document-titles
Browse files Browse the repository at this point in the history
Add DetectDocumentTitles method.
  • Loading branch information
Vladislav Skukov authored Dec 13, 2019
2 parents e7cb8cc + 4fd17fb commit e449205
Show file tree
Hide file tree
Showing 9 changed files with 239 additions and 4 deletions.
15 changes: 15 additions & 0 deletions proto/Documents/DetectTitleResponse.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import "Events/DiadocMessage-PostApi.proto";

package Diadoc.Api.Proto.Documents;

message DetectTitleResponse {
repeated DetectedDocumentTitle DocumentTitles = 1;
}

message DetectedDocumentTitle {
required string TypeNamedId = 1;
required string Function = 2;
required string Version = 3;
required int32 TitleIndex = 4;
repeated Events.MetadataItem Metadata = 5;
}
14 changes: 14 additions & 0 deletions src/ComDiadocApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ PrepareDocumentsToSignResponse PrepareDocumentsToSign(
GetDocumentTypesResponse GetDocumentTypes(string token, string boxId);
DetectDocumentTypesResponse DetectDocumentTypes(string token, string boxId, string nameOnShelf);
DetectDocumentTypesResponse DetectDocumentTypes(string token, string boxId, byte[] content);
DetectTitleResponse DetectDocumentTitles(string token, string boxId, string nameOnShelf);
DetectTitleResponse DetectDocumentTitles(string token, string boxId, byte[] content);

[Obsolete("In order to download XSD schema use the link provided in DocumentTitle.XsdUrl")]
FileContent GetContent(
Expand Down Expand Up @@ -1376,16 +1378,28 @@ public GetDocumentTypesResponse GetDocumentTypes(string token, string boxId)
return diadoc.GetDocumentTypes(token, boxId);
}

[Obsolete("Use DetectDocumentTitles")]
public DetectDocumentTypesResponse DetectDocumentTypes(string token, string boxId, string nameOnShelf)
{
return diadoc.DetectDocumentTypes(token, boxId, nameOnShelf);
}

[Obsolete("Use DetectDocumentTitles")]
public DetectDocumentTypesResponse DetectDocumentTypes(string token, string boxId, byte[] content)
{
return diadoc.DetectDocumentTypes(token, boxId, content);
}

public DetectTitleResponse DetectDocumentTitles(string token, string boxId, string nameOnShelf)
{
return diadoc.DetectDocumentTitles(token, boxId, nameOnShelf);
}

public DetectTitleResponse DetectDocumentTitles(string token, string boxId, byte[] content)
{
return diadoc.DetectDocumentTitles(token, boxId, content);
}

public FileContent GetContent(
string token,
string typeNamedId,
Expand Down
22 changes: 22 additions & 0 deletions src/DiadocApi.Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ public Task<GetDocumentTypesResponse> GetDocumentTypesAsync(string authToken, st
return diadocHttpApi.GetDocumentTypesAsync(authToken, boxId);
}

[Obsolete("Use DetectDocumentTitlesAsync")]
public Task<DetectDocumentTypesResponse> DetectDocumentTypesAsync(string authToken, string boxId, string nameOnShelf)
{
if (string.IsNullOrEmpty(authToken))
Expand All @@ -1071,6 +1072,7 @@ public Task<DetectDocumentTypesResponse> DetectDocumentTypesAsync(string authTok
return diadocHttpApi.DetectDocumentTypesAsync(authToken, boxId, nameOnShelf);
}

[Obsolete("Use DetectDocumentTitlesAsync")]
public Task<DetectDocumentTypesResponse> DetectDocumentTypesAsync(string authToken, string boxId, byte[] content)
{
if (string.IsNullOrEmpty(authToken))
Expand All @@ -1079,6 +1081,26 @@ public Task<DetectDocumentTypesResponse> DetectDocumentTypesAsync(string authTok
throw new ArgumentNullException("boxId");
return diadocHttpApi.DetectDocumentTypesAsync(authToken, boxId, content);
}

public Task<DetectTitleResponse> DetectDocumentTitlesAsync(string authToken, string boxId, string nameOnShelf)
{
if (string.IsNullOrEmpty(authToken))
throw new ArgumentNullException("authToken");
if (string.IsNullOrEmpty(boxId))
throw new ArgumentNullException("boxId");
if (string.IsNullOrEmpty(nameOnShelf))
throw new ArgumentNullException("nameOnShelf");
return diadocHttpApi.DetectDocumentTitlesAsync(authToken, boxId, nameOnShelf);
}

public Task<DetectTitleResponse> DetectDocumentTitlesAsync(string authToken, string boxId, byte[] content)
{
if (string.IsNullOrEmpty(authToken))
throw new ArgumentNullException("authToken");
if (string.IsNullOrEmpty(boxId))
throw new ArgumentNullException("boxId");
return diadocHttpApi.DetectDocumentTitlesAsync(authToken, boxId, content);
}

public Task<FileContent> GetContentAsync(string authToken, string typeNamedId, string function, string version, int titleIndex, XsdContentType contentType = default(XsdContentType))
{
Expand Down
22 changes: 22 additions & 0 deletions src/DiadocApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,7 @@ public GetDocumentTypesResponse GetDocumentTypes(string authToken, string boxId)
return diadocHttpApi.GetDocumentTypes(authToken, boxId);
}

[Obsolete("Use DetectDocumentTitles")]
public DetectDocumentTypesResponse DetectDocumentTypes(string authToken, string boxId, string nameOnShelf)
{
if (string.IsNullOrEmpty(authToken))
Expand All @@ -1205,6 +1206,7 @@ public DetectDocumentTypesResponse DetectDocumentTypes(string authToken, string
return diadocHttpApi.DetectDocumentTypes(authToken, boxId, nameOnShelf);
}

[Obsolete("Use DetectDocumentTitles")]
public DetectDocumentTypesResponse DetectDocumentTypes(string authToken, string boxId, byte[] content)
{
if (string.IsNullOrEmpty(authToken))
Expand All @@ -1214,6 +1216,26 @@ public DetectDocumentTypesResponse DetectDocumentTypes(string authToken, string
return diadocHttpApi.DetectDocumentTypes(authToken, boxId, content);
}

public DetectTitleResponse DetectDocumentTitles(string authToken, string boxId, string nameOnShelf)
{
if (string.IsNullOrEmpty(authToken))
throw new ArgumentNullException("authToken");
if (string.IsNullOrEmpty(boxId))
throw new ArgumentNullException("boxId");
if (string.IsNullOrEmpty(nameOnShelf))
throw new ArgumentNullException("nameOnShelf");
return diadocHttpApi.DetectDocumentTitles(authToken, boxId, nameOnShelf);
}

public DetectTitleResponse DetectDocumentTitles(string authToken, string boxId, byte[] content)
{
if (string.IsNullOrEmpty(authToken))
throw new ArgumentNullException("authToken");
if (string.IsNullOrEmpty(boxId))
throw new ArgumentNullException("boxId");
return diadocHttpApi.DetectDocumentTitles(authToken, boxId, content);
}

public FileContent GetContent(string authToken, string typeNamedId, string function, string version, int titleIndex, XsdContentType contentType = default(XsdContentType))
{
if (string.IsNullOrEmpty(authToken))
Expand Down
28 changes: 24 additions & 4 deletions src/DiadocHttpApi.Documents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ public DocumentList GetDocuments(
[NotNull] string boxId,
[NotNull] string filterCategory,
[CanBeNull] string counteragentBoxId,
DateTime? timestampFrom, DateTime? timestampTo,
[CanBeNull] string fromDocumentDate, [CanBeNull] string toDocumentDate,
[CanBeNull] string departmentId, bool excludeSubdepartments,
DateTime? timestampFrom,
DateTime? timestampTo,
[CanBeNull] string fromDocumentDate,
[CanBeNull] string toDocumentDate,
[CanBeNull] string departmentId,
bool excludeSubdepartments,
[CanBeNull] string afterIndexKey,
int? count = null
)
Expand Down Expand Up @@ -136,6 +139,7 @@ public GetDocumentTypesResponse GetDocumentTypes(string authToken, string boxId)
return PerformHttpRequest<GetDocumentTypesResponse>(authToken, "GET", qsb.BuildPathAndQuery());
}

[Obsolete("Use DetectDocumentTitles")]
public DetectDocumentTypesResponse DetectDocumentTypes(string authToken, string boxId, string nameOnShelf)
{
var qsb = new PathAndQueryBuilder("/DetectDocumentTypes");
Expand All @@ -144,13 +148,29 @@ public DetectDocumentTypesResponse DetectDocumentTypes(string authToken, string
return PerformHttpRequest<DetectDocumentTypesResponse>(authToken, "GET", qsb.BuildPathAndQuery());
}

[Obsolete("Use DetectDocumentTitles")]
public DetectDocumentTypesResponse DetectDocumentTypes(string authToken, string boxId, byte[] content)
{
var qsb = new PathAndQueryBuilder("/DetectDocumentTypes");
qsb.AddParameter("boxId", boxId);
return PerformHttpRequest<DetectDocumentTypesResponse>(authToken, "POST", qsb.BuildPathAndQuery(), content);
}

public DetectTitleResponse DetectDocumentTitles(string authToken, string boxId, string nameOnShelf)
{
var qsb = new PathAndQueryBuilder("/DetectDocumentTitles");
qsb.AddParameter("boxId", boxId);
qsb.AddParameter("nameOnShelf", nameOnShelf);
return PerformHttpRequest<DetectTitleResponse>(authToken, "GET", qsb.BuildPathAndQuery());
}

public DetectTitleResponse DetectDocumentTitles(string authToken, string boxId, byte[] content)
{
var qsb = new PathAndQueryBuilder("/DetectDocumentTitles");
qsb.AddParameter("boxId", boxId);
return PerformHttpRequest<DetectTitleResponse>(authToken, "POST", qsb.BuildPathAndQuery(), content);
}

public FileContent GetContent(string authToken, string typeNamedId, string function, string version, int titleIndex, XsdContentType contentType = default(XsdContentType))
{
var qsb = new PathAndQueryBuilder("/GetContent");
Expand All @@ -166,4 +186,4 @@ public DetectDocumentTypesResponse DetectDocumentTypes(string authToken, string
return new FileContent(response.Content, response.ContentDispositionFileName);
}
}
}
}
15 changes: 15 additions & 0 deletions src/DiadocHttpApi.DocumentsAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,21 @@ public Task<DetectDocumentTypesResponse> DetectDocumentTypesAsync(string authTok
qsb.AddParameter("boxId", boxId);
return PerformHttpRequestAsync<DetectDocumentTypesResponse>(authToken, "POST", qsb.BuildPathAndQuery(), content);
}

public Task<DetectTitleResponse> DetectDocumentTitlesAsync(string authToken, string boxId, string nameOnShelf)
{
var qsb = new PathAndQueryBuilder("/DetectDocumentTitles");
qsb.AddParameter("boxId", boxId);
qsb.AddParameter("nameOnShelf", nameOnShelf);
return PerformHttpRequestAsync<DetectTitleResponse>(authToken, "GET", qsb.BuildPathAndQuery());
}

public Task<DetectTitleResponse> DetectDocumentTitlesAsync(string authToken, string boxId, byte[] content)
{
var qsb = new PathAndQueryBuilder("/DetectDocumentTitles");
qsb.AddParameter("boxId", boxId);
return PerformHttpRequestAsync<DetectTitleResponse>(authToken, "POST", qsb.BuildPathAndQuery(), content);
}

public async Task<FileContent> GetContentAsync(string authToken, string typeNamedId, string function, string version, int titleIndex, XsdContentType contentType = default(XsdContentType))
{
Expand Down
4 changes: 4 additions & 0 deletions src/IDiadocApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ byte[] ParseTitleXml(
GetDocumentTypesResponse GetDocumentTypes(string authToken, string boxId);
DetectDocumentTypesResponse DetectDocumentTypes(string authToken, string boxId, string nameOnShelf);
DetectDocumentTypesResponse DetectDocumentTypes(string authToken, string boxId, byte[] content);
DetectTitleResponse DetectDocumentTitles(string authToken, string boxId, string nameOnShelf);
DetectTitleResponse DetectDocumentTitles(string authToken, string boxId, byte[] content);
FileContent GetContent(string authToken, string typeNamedId, string function, string version, int titleIndex, XsdContentType contentType = default(XsdContentType));
Employee GetEmployee(string authToken, string boxId, string userId);
EmployeeList GetEmployees(string authToken, string boxId, int? page, int? count);
Expand Down Expand Up @@ -419,6 +421,8 @@ Task<AutosignReceiptsResult> WaitAutosignReceiptsResultAsync(string authToken, s
Task<GetDocumentTypesResponse> GetDocumentTypesAsync(string authToken, string boxId);
Task<DetectDocumentTypesResponse> DetectDocumentTypesAsync(string authToken, string boxId, string nameOnShelf);
Task<DetectDocumentTypesResponse> DetectDocumentTypesAsync(string authToken, string boxId, byte[] content);
Task<DetectTitleResponse> DetectDocumentTitlesAsync(string authToken, string boxId, string nameOnShelf);
Task<DetectTitleResponse> DetectDocumentTitlesAsync(string authToken, string boxId, byte[] content);
[Obsolete("In order to download XSD schema use the link provided in DocumentTitle.XsdUrl")]
Task<FileContent> GetContentAsync(string authToken, string typeNamedId, string function, string version, int titleIndex, XsdContentType contentType = default(XsdContentType));
Task<Employee> GetEmployeeAsync(string authToken, string boxId, string userId);
Expand Down
47 changes: 47 additions & 0 deletions src/Proto/Documents/DetectTitleResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Runtime.InteropServices;
using Diadoc.Api.Com;

namespace Diadoc.Api.Proto.Documents
{
[ComVisible(true)]
[Guid("7A0E4E36-4ECD-4CBB-A326-66CE219E4601")]
public interface IDetectTitleResponse
{
ReadonlyList DocumentTitlesList { get; }
}

[ComVisible(true)]
[Guid("38C6484E-78A5-4DD5-9C54-F761B26E2801")]
[ClassInterface(ClassInterfaceType.None)]
[ComDefaultInterface(typeof(IDetectTitleResponse))]
public partial class DetectTitleResponse : SafeComObject, IDetectTitleResponse
{
public ReadonlyList DocumentTitlesList
{
get { return new ReadonlyList(DocumentTitles); }
}
}

[ComVisible(true)]
[Guid("48594CB9-DB64-4252-A8E3-6631BFABE94F")]
public interface IDetectedDocumentTitle
{
string TypeNamedId { get; }
string Function { get; }
string Version { get; }
int TitleIndex { get; }
ReadonlyList MetadataList { get; }
}

[ComVisible(true)]
[Guid("7AB7A204-FC84-4C62-9D40-EF1CDE29F9E6")]
[ClassInterface(ClassInterfaceType.None)]
[ComDefaultInterface(typeof(IDetectedDocumentTitle))]
public partial class DetectedDocumentTitle : SafeComObject, IDetectedDocumentTitle
{
public ReadonlyList MetadataList
{
get { return new ReadonlyList(Metadata); }
}
}
}
76 changes: 76 additions & 0 deletions src/Proto/Documents/DetectTitleResponse.proto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

// Generated from: Documents/DetectTitleResponse.proto
// Note: requires additional types generated from: Events/DiadocMessage-PostApi.proto
namespace Diadoc.Api.Proto.Documents
{
[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"DetectTitleResponse")]
public partial class DetectTitleResponse : global::ProtoBuf.IExtensible
{
public DetectTitleResponse() {}

private readonly global::System.Collections.Generic.List<Diadoc.Api.Proto.Documents.DetectedDocumentTitle> _DocumentTitles = new global::System.Collections.Generic.List<Diadoc.Api.Proto.Documents.DetectedDocumentTitle>();
[global::ProtoBuf.ProtoMember(1, Name=@"DocumentTitles", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<Diadoc.Api.Proto.Documents.DetectedDocumentTitle> DocumentTitles
{
get { return _DocumentTitles; }
}

private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}

[global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"DetectedDocumentTitle")]
public partial class DetectedDocumentTitle : global::ProtoBuf.IExtensible
{
public DetectedDocumentTitle() {}

private string _TypeNamedId;
[global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"TypeNamedId", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string TypeNamedId
{
get { return _TypeNamedId; }
set { _TypeNamedId = value; }
}
private string _Function;
[global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"Function", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string Function
{
get { return _Function; }
set { _Function = value; }
}
private string _Version;
[global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"Version", DataFormat = global::ProtoBuf.DataFormat.Default)]
public string Version
{
get { return _Version; }
set { _Version = value; }
}
private int _TitleIndex;
[global::ProtoBuf.ProtoMember(4, IsRequired = true, Name=@"TitleIndex", DataFormat = global::ProtoBuf.DataFormat.TwosComplement)]
public int TitleIndex
{
get { return _TitleIndex; }
set { _TitleIndex = value; }
}
private readonly global::System.Collections.Generic.List<Diadoc.Api.Proto.Events.MetadataItem> _Metadata = new global::System.Collections.Generic.List<Diadoc.Api.Proto.Events.MetadataItem>();
[global::ProtoBuf.ProtoMember(5, Name=@"Metadata", DataFormat = global::ProtoBuf.DataFormat.Default)]
public global::System.Collections.Generic.List<Diadoc.Api.Proto.Events.MetadataItem> Metadata
{
get { return _Metadata; }
}

private global::ProtoBuf.IExtension extensionObject;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{ return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); }
}

}

0 comments on commit e449205

Please sign in to comment.