From 6023ed235f10d2a696bac50c2b3c04bb76bdd3b0 Mon Sep 17 00:00:00 2001 From: Dmitriy Ipatyev Date: Wed, 6 Apr 2022 10:25:03 +0500 Subject: [PATCH] Add GetRoamingOperators method --- proto/RoamingOperator.proto | 17 +++ src/ComDiadocApi.cs | 136 ++++++++++---------- src/DiadocApi.Async.cs | 5 + src/DiadocApi.cs | 5 + src/DiadocHttpApi.References.cs | 2 +- src/DiadocHttpApi.RoamingOperators.Async.cs | 16 +++ src/DiadocHttpApi.RoamingOperators.cs | 15 +++ src/IDiadocApi.cs | 2 + src/Proto/Invoicing/ExtendedSigner.proto.cs | 2 +- src/Proto/RoamingOperator.cs | 72 +++++++++++ src/Proto/RoamingOperator.proto.cs | 92 +++++++++++++ 11 files changed, 297 insertions(+), 67 deletions(-) create mode 100644 proto/RoamingOperator.proto create mode 100644 src/DiadocHttpApi.RoamingOperators.Async.cs create mode 100644 src/DiadocHttpApi.RoamingOperators.cs create mode 100644 src/Proto/RoamingOperator.cs create mode 100644 src/Proto/RoamingOperator.proto.cs diff --git a/proto/RoamingOperator.proto b/proto/RoamingOperator.proto new file mode 100644 index 00000000..64e8f06e --- /dev/null +++ b/proto/RoamingOperator.proto @@ -0,0 +1,17 @@ +package Diadoc.Api.Proto; + +message RoamingOperatorList { + repeated RoamingOperator RoamingOperators = 1; +} + +message RoamingOperator { + required string FnsId = 1; + required string Name = 2; + required bool IsActive = 3; + repeated OperatorFeature Features = 4; +} + +message OperatorFeature { + required string Name = 1; + required string Description = 2; +} \ No newline at end of file diff --git a/src/ComDiadocApi.cs b/src/ComDiadocApi.cs index f1dc66b1..3d8a45a9 100644 --- a/src/ComDiadocApi.cs +++ b/src/ComDiadocApi.cs @@ -6,6 +6,7 @@ using Diadoc.Api.Cryptography; using Diadoc.Api.Proto; using Diadoc.Api.Proto.Certificates; +using Diadoc.Api.Proto.Departments; using Diadoc.Api.Proto.Docflow; using Diadoc.Api.Proto.Documents; using Diadoc.Api.Proto.Documents.Types; @@ -24,10 +25,9 @@ using Diadoc.Api.Proto.Users; using Diadoc.Api.Proto.Workflows; using JetBrains.Annotations; -using DocumentTitleType = Diadoc.Api.Proto.Invoicing.Signers.DocumentTitleType; +using Department = Diadoc.Api.Proto.Department; using DocumentType = Diadoc.Api.Proto.DocumentType; using Employee = Diadoc.Api.Proto.Employees.Employee; -using Departments = Diadoc.Api.Proto.Departments; using RevocationRequestInfo = Diadoc.Api.Proto.Invoicing.RevocationRequestInfo; namespace Diadoc.Api @@ -512,10 +512,10 @@ void DeleteEmployeePowerOfAttorney( string registrationNumber, string issuerInn); - Departments.Department GetDepartmentByFullId(string authToken, string boxId, string departmentId); - Departments.DepartmentList GetDepartments(string authToken, string boxId, int page = 0, int count = 0); - Departments.Department CreateDepartment(string authToken, string boxId, [MarshalAs(UnmanagedType.IDispatch)] object departmentToCreate); - Departments.Department UpdateDepartment(string authToken, string boxId, string departmentId, [MarshalAs(UnmanagedType.IDispatch)] object departmentToUpdate); + Proto.Departments.Department GetDepartmentByFullId(string authToken, string boxId, string departmentId); + DepartmentList GetDepartments(string authToken, string boxId, int page = 0, int count = 0); + Proto.Departments.Department CreateDepartment(string authToken, string boxId, [MarshalAs(UnmanagedType.IDispatch)] object departmentToCreate); + Proto.Departments.Department UpdateDepartment(string authToken, string boxId, string departmentId, [MarshalAs(UnmanagedType.IDispatch)] object departmentToUpdate); void DeleteDepartment(string authToken, string boxId, string departmentId); Template PostTemplate(string authToken, [MarshalAs(UnmanagedType.IDispatch)] object template); @@ -637,7 +637,7 @@ public Organization GetOrganizationById(string orgId) public Organization GetOrganizationByInn(string inn) { - return diadoc.GetOrganizationByInnKpp(inn, null); + return diadoc.GetOrganizationByInnKpp(inn, kpp: null); } public Organization GetOrganizationByBoxId(string boxId) @@ -714,11 +714,11 @@ public BoxEventList GetNewEvents( messageTypes, typeNamedIds, documentDirections, - timestampFromTicks != 0 ? timestampFromTicks : (long?)null, - timestampToTicks != 0 ? timestampToTicks : (long?)null, + timestampFromTicks != 0 ? timestampFromTicks : (long?) null, + timestampToTicks != 0 ? timestampToTicks : (long?) null, counteragentBoxId, orderBy, - limit != 0 ? limit : (int?)null); + limit != 0 ? limit : (int?) null); } public BoxEvent GetEvent(string authToken, string boxId, string eventId) @@ -770,11 +770,6 @@ public void DeleteEmployee(string authToken, string boxId, string userId) diadoc.DeleteEmployee(authToken, boxId, userId); } - public Employee GetMyEmployee(string authToken, string boxId) - { - return diadoc.GetMyEmployee(authToken, boxId); - } - public EmployeeSubscriptions GetSubscriptions(string authToken, string boxId, string userId) { return diadoc.GetSubscriptions(authToken, boxId, userId); @@ -811,24 +806,24 @@ public void DeleteEmployeePowerOfAttorney(string authToken, string boxId, [CanBe diadoc.DeleteEmployeePowerOfAttorney(authToken, boxId, userId, registrationNumber, issuerInn); } - public Departments.Department GetDepartmentByFullId(string authToken, string boxId, string departmentId) + public Proto.Departments.Department GetDepartmentByFullId(string authToken, string boxId, string departmentId) { return diadoc.GetDepartmentByFullId(authToken, boxId, departmentId); } - public Departments.DepartmentList GetDepartments(string authToken, string boxId, int page = 0, int count = 0) + public DepartmentList GetDepartments(string authToken, string boxId, int page = 0, int count = 0) { - return diadoc.GetDepartments(authToken, boxId, page != 0 ? page : (int?)null, count != 0 ? count : (int?)null); + return diadoc.GetDepartments(authToken, boxId, page != 0 ? page : (int?) null, count != 0 ? count : (int?) null); } - public Departments.Department CreateDepartment(string authToken, string boxId, object departmentToCreate) + public Proto.Departments.Department CreateDepartment(string authToken, string boxId, object departmentToCreate) { - return diadoc.CreateDepartment(authToken, boxId, (Departments.DepartmentToCreate) departmentToCreate); + return diadoc.CreateDepartment(authToken, boxId, (DepartmentToCreate) departmentToCreate); } - public Departments.Department UpdateDepartment(string authToken, string boxId, string departmentId, object departmentToUpdate) + public Proto.Departments.Department UpdateDepartment(string authToken, string boxId, string departmentId, object departmentToUpdate) { - return diadoc.UpdateDepartment(authToken, boxId, departmentId, (Departments.DepartmentToUpdate) departmentToUpdate); + return diadoc.UpdateDepartment(authToken, boxId, departmentId, (DepartmentToUpdate) departmentToUpdate); } public void DeleteDepartment(string authToken, string boxId, string departmentId) @@ -1306,17 +1301,7 @@ public string GeneratePrintFormFromAttachment(string authToken, int documentType public DateTime NullDateTime() { - return new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); - } - - public DateTime? GetNullable(DateTime dateTime) - { - return dateTime == NullDateTime() ? (DateTime?) null : dateTime; - } - - private DateTime? ToUtcDateTime(long dateTime) - { - return dateTime == 0 ? (DateTime?) null : new DateTime(dateTime, DateTimeKind.Utc); + return new DateTime(year: 1970, month: 1, day: 1, hour: 0, minute: 0, second: 0, millisecond: 0, DateTimeKind.Utc); } public DocumentList GetDocuments(string authToken, object filter) @@ -1579,6 +1564,59 @@ public FileContent GetContent( return diadoc.GetContent(token, typeNamedId, function, version, titleIndex, (XsdContentType) contentType); } + public BoxEvent GetLastEvent(string token, string boxId) + { + return diadoc.GetLastEvent(token, boxId); + } + + public CustomPrintFormDetectionResult DetectCustomPrintForms( + string authToken, + string boxId, + [MarshalAs(UnmanagedType.IDispatch)] object request) + { + return diadoc.DetectCustomPrintForms(authToken, boxId, (CustomPrintFormDetectionRequest) request); + } + + public AsyncMethodResult RegisterPowerOfAttorney(string authToken, string boxId, object powerOfAttorneyToRegister) + { + return diadoc.RegisterPowerOfAttorney(authToken, boxId, (PowerOfAttorneyToRegister) powerOfAttorneyToRegister); + } + + public PowerOfAttorneyRegisterResult RegisterPowerOfAttorneyResult(string authToken, string boxId, string taskId) + { + return diadoc.RegisterPowerOfAttorneyResult(authToken, boxId, taskId); + } + + public PowerOfAttorneyPrevalidateResult PrevalidatePowerOfAttorney(string authToken, string boxId, string registrationNumber, string issuerInn, object request) + { + return diadoc.PrevalidatePowerOfAttorney(authToken, boxId, registrationNumber, issuerInn, (PowerOfAttorneyPrevalidateRequest) request); + } + + public PowerOfAttorney GetPowerOfAttorneyInfo(string authToken, string boxId, string messageId, string entityId) + { + return diadoc.GetPowerOfAttorneyInfo(authToken, boxId, messageId, entityId); + } + + public RoamingOperatorList GetRoamingOperators(string authToken, string boxId) + { + return diadoc.GetRoamingOperators(authToken, boxId); + } + + public Employee GetMyEmployee(string authToken, string boxId) + { + return diadoc.GetMyEmployee(authToken, boxId); + } + + public DateTime? GetNullable(DateTime dateTime) + { + return dateTime == NullDateTime() ? (DateTime?) null : dateTime; + } + + private DateTime? ToUtcDateTime(long dateTime) + { + return dateTime == 0 ? (DateTime?) null : new DateTime(dateTime, DateTimeKind.Utc); + } + #region Counteragents public Counteragent GetCounteragent(string authToken, string myOrgId, string counteragentOrgId) @@ -1819,37 +1857,5 @@ public byte[] ParseTitleXml( #endregion - public BoxEvent GetLastEvent(string token, string boxId) - { - return diadoc.GetLastEvent(token, boxId); - } - - public CustomPrintFormDetectionResult DetectCustomPrintForms( - string authToken, - string boxId, - [MarshalAs(UnmanagedType.IDispatch)] object request) - { - return diadoc.DetectCustomPrintForms(authToken, boxId, (CustomPrintFormDetectionRequest) request); - } - - public AsyncMethodResult RegisterPowerOfAttorney(string authToken, string boxId, object powerOfAttorneyToRegister) - { - return diadoc.RegisterPowerOfAttorney(authToken, boxId, (PowerOfAttorneyToRegister) powerOfAttorneyToRegister); - } - - public PowerOfAttorneyRegisterResult RegisterPowerOfAttorneyResult(string authToken, string boxId, string taskId) - { - return diadoc.RegisterPowerOfAttorneyResult(authToken, boxId, taskId); - } - - public PowerOfAttorneyPrevalidateResult PrevalidatePowerOfAttorney(string authToken, string boxId, string registrationNumber, string issuerInn, object request) - { - return diadoc.PrevalidatePowerOfAttorney(authToken, boxId, registrationNumber, issuerInn, (PowerOfAttorneyPrevalidateRequest) request); - } - - public PowerOfAttorney GetPowerOfAttorneyInfo(string authToken, string boxId, string messageId, string entityId) - { - return diadoc.GetPowerOfAttorneyInfo(authToken, boxId, messageId, entityId); - } } } diff --git a/src/DiadocApi.Async.cs b/src/DiadocApi.Async.cs index fbb1cf71..1f47a6b0 100644 --- a/src/DiadocApi.Async.cs +++ b/src/DiadocApi.Async.cs @@ -157,6 +157,11 @@ public Task GetOrganizationByInnKppAsync(string inn, string kpp) return diadocHttpApi.GetOrganizationByInnKppAsync(inn, kpp); } + public Task GetRoamingOperatorsAsync(string authToken, string boxId) + { + return diadocHttpApi.GetRoamingOperatorsAsync(authToken, boxId); + } + public Task GetBoxAsync(string boxId) { if (boxId == null) throw new ArgumentNullException("boxId"); diff --git a/src/DiadocApi.cs b/src/DiadocApi.cs index db08f5e1..93d6101f 100644 --- a/src/DiadocApi.cs +++ b/src/DiadocApi.cs @@ -215,6 +215,11 @@ public Organization GetOrganizationByInnKpp(string inn, string kpp) return diadocHttpApi.GetOrganizationByInnKpp(inn, kpp); } + public RoamingOperatorList GetRoamingOperators(string authToken, string boxId) + { + return diadocHttpApi.GetRoamingOperators(authToken, boxId); + } + public Box GetBox(string boxId) { if (boxId == null) throw new ArgumentNullException("boxId"); diff --git a/src/DiadocHttpApi.References.cs b/src/DiadocHttpApi.References.cs index 6ced6aee..cc5693c1 100644 --- a/src/DiadocHttpApi.References.cs +++ b/src/DiadocHttpApi.References.cs @@ -125,4 +125,4 @@ public List GetOrganizationsByInnList(string return response.Organizations; } } -} \ No newline at end of file +} diff --git a/src/DiadocHttpApi.RoamingOperators.Async.cs b/src/DiadocHttpApi.RoamingOperators.Async.cs new file mode 100644 index 00000000..7a99b9fa --- /dev/null +++ b/src/DiadocHttpApi.RoamingOperators.Async.cs @@ -0,0 +1,16 @@ +using System.Threading.Tasks; +using Diadoc.Api.Http; +using Diadoc.Api.Proto; + +namespace Diadoc.Api +{ + public partial class DiadocHttpApi + { + public Task GetRoamingOperatorsAsync(string authToken, string boxId) + { + var queryString = new PathAndQueryBuilder("/GetRoamingOperators"); + queryString.AddParameter("boxId", boxId); + return PerformHttpRequestAsync(authToken, "GET", queryString.BuildPathAndQuery()); + } + } +} diff --git a/src/DiadocHttpApi.RoamingOperators.cs b/src/DiadocHttpApi.RoamingOperators.cs new file mode 100644 index 00000000..1a81601d --- /dev/null +++ b/src/DiadocHttpApi.RoamingOperators.cs @@ -0,0 +1,15 @@ +using Diadoc.Api.Http; +using Diadoc.Api.Proto; + +namespace Diadoc.Api +{ + public partial class DiadocHttpApi + { + public RoamingOperatorList GetRoamingOperators(string authToken, string boxId) + { + var queryString = new PathAndQueryBuilder("/GetRoamingOperators"); + queryString.AddParameter("boxId", boxId); + return PerformHttpRequest(authToken, "GET", queryString.BuildPathAndQuery()); + } + } +} diff --git a/src/IDiadocApi.cs b/src/IDiadocApi.cs index bcd9261a..78efe895 100644 --- a/src/IDiadocApi.cs +++ b/src/IDiadocApi.cs @@ -65,6 +65,7 @@ public interface IDiadocApi Organization GetOrganizationByBoxId(string boxId); Organization GetOrganizationByFnsParticipantId(string fnsParticipantId); Organization GetOrganizationByInnKpp(string inn, string kpp); + RoamingOperatorList GetRoamingOperators(string authToken, string boxId); Box GetBox(string boxId); Department GetDepartment(string authToken, string orgId, string departmentId); void UpdateOrganizationProperties(string authToken, OrganizationPropertiesToUpdate orgProps); @@ -312,6 +313,7 @@ Task AuthenticateWithKeyAsync(byte[] certificateBytes, bool useLocalSyst Task GetOrganizationByBoxIdAsync(string boxId); Task GetOrganizationByFnsParticipantIdAsync(string fnsParticipantId); Task GetOrganizationByInnKppAsync(string inn, string kpp); + Task GetRoamingOperatorsAsync(string authToken, string boxId); Task GetBoxAsync(string boxId); Task GetDepartmentAsync(string authToken, string orgId, string departmentId); Task UpdateOrganizationPropertiesAsync(string authToken, OrganizationPropertiesToUpdate orgProps); diff --git a/src/Proto/Invoicing/ExtendedSigner.proto.cs b/src/Proto/Invoicing/ExtendedSigner.proto.cs index 1c346610..9765ba76 100644 --- a/src/Proto/Invoicing/ExtendedSigner.proto.cs +++ b/src/Proto/Invoicing/ExtendedSigner.proto.cs @@ -384,4 +384,4 @@ public enum DocumentTitleType Ucd736Buyer = 11 } -} +} \ No newline at end of file diff --git a/src/Proto/RoamingOperator.cs b/src/Proto/RoamingOperator.cs new file mode 100644 index 00000000..e269fa10 --- /dev/null +++ b/src/Proto/RoamingOperator.cs @@ -0,0 +1,72 @@ +using System.Linq; +using System.Runtime.InteropServices; +using Diadoc.Api.Com; + +namespace Diadoc.Api.Proto +{ + [ComVisible(true)] + [Guid("B1B86134-D9FD-48F9-AA05-F46817010A03")] + public interface IRoamingOperatorList + { + ReadonlyList RoamingOperatorsList { get; } + } + + [ComVisible(true)] + [Guid("A5FABD58-BF70-4253-9E74-CBCFE3C7C9C4")] + [ClassInterface(ClassInterfaceType.None)] + [ComDefaultInterface(typeof(IRoamingOperatorList))] + public partial class RoamingOperatorList : SafeComObject, IRoamingOperatorList + { + public ReadonlyList RoamingOperatorsList => new ReadonlyList(RoamingOperators); + + public override string ToString() + { + return string.Join("\r\n", RoamingOperators.Select(o => o.ToString()).ToArray()); + } + } + + [ComVisible(true)] + [Guid("0B5BC0B1-D4E6-4632-960B-7ABB47FD919F")] + public interface IRoamingOperator + { + string FnsId { get; } + string Name { get; } + bool IsActive { get; } + ReadonlyList FeaturesList { get; } + } + + [ComVisible(true)] + [Guid("CD1042B8-014E-4916-8F01-8CA2396B928F")] + [ClassInterface(ClassInterfaceType.None)] + [ComDefaultInterface(typeof(IRoamingOperator))] + public partial class RoamingOperator : SafeComObject, IRoamingOperator + { + public ReadonlyList FeaturesList => new ReadonlyList(Features); + + public override string ToString() + { + var features = string.Join("\r\n", Features.Select(o => o.ToString()).ToArray()); + return $"FnsId: {FnsId}, Name: {Name}, IsActive: {IsActive}, Features: {features}"; + } + } + + [ComVisible(true)] + [Guid("D8E3AF96-D485-4B11-A42E-3553065CD223")] + public interface IOperatorFeature + { + string Name { get; } + string Description { get; } + } + + [ComVisible(true)] + [Guid("686DBA55-F111-42A7-8703-2FEE14EAF082")] + [ClassInterface(ClassInterfaceType.None)] + [ComDefaultInterface(typeof(IOperatorFeature))] + public partial class OperatorFeature : SafeComObject, IOperatorFeature + { + public override string ToString() + { + return $"Name: {Name}, Description: {Description}"; + } + } +} diff --git a/src/Proto/RoamingOperator.proto.cs b/src/Proto/RoamingOperator.proto.cs new file mode 100644 index 00000000..cd4976b2 --- /dev/null +++ b/src/Proto/RoamingOperator.proto.cs @@ -0,0 +1,92 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +// Generated from: RoamingOperator.proto +namespace Diadoc.Api.Proto +{ + [global::System.Serializable, global::ProtoBuf.ProtoContract(Name=@"RoamingOperatorList")] + public partial class RoamingOperatorList : global::ProtoBuf.IExtensible + { + public RoamingOperatorList() {} + + private readonly global::System.Collections.Generic.List _RoamingOperators = new global::System.Collections.Generic.List(); + [global::ProtoBuf.ProtoMember(1, Name=@"RoamingOperators", DataFormat = global::ProtoBuf.DataFormat.Default)] + public global::System.Collections.Generic.List RoamingOperators + { + get { return _RoamingOperators; } + } + + 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=@"RoamingOperator")] + public partial class RoamingOperator : global::ProtoBuf.IExtensible + { + public RoamingOperator() {} + + private string _FnsId; + [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"FnsId", DataFormat = global::ProtoBuf.DataFormat.Default)] + public string FnsId + { + get { return _FnsId; } + set { _FnsId = value; } + } + private string _Name; + [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"Name", DataFormat = global::ProtoBuf.DataFormat.Default)] + public string Name + { + get { return _Name; } + set { _Name = value; } + } + private bool _IsActive; + [global::ProtoBuf.ProtoMember(3, IsRequired = true, Name=@"IsActive", DataFormat = global::ProtoBuf.DataFormat.Default)] + public bool IsActive + { + get { return _IsActive; } + set { _IsActive = value; } + } + private readonly global::System.Collections.Generic.List _Features = new global::System.Collections.Generic.List(); + [global::ProtoBuf.ProtoMember(4, Name=@"Features", DataFormat = global::ProtoBuf.DataFormat.Default)] + public global::System.Collections.Generic.List Features + { + get { return _Features; } + } + + 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=@"OperatorFeature")] + public partial class OperatorFeature : global::ProtoBuf.IExtensible + { + public OperatorFeature() {} + + private string _Name; + [global::ProtoBuf.ProtoMember(1, IsRequired = true, Name=@"Name", DataFormat = global::ProtoBuf.DataFormat.Default)] + public string Name + { + get { return _Name; } + set { _Name = value; } + } + private string _Description; + [global::ProtoBuf.ProtoMember(2, IsRequired = true, Name=@"Description", DataFormat = global::ProtoBuf.DataFormat.Default)] + public string Description + { + get { return _Description; } + set { _Description = value; } + } + private global::ProtoBuf.IExtension extensionObject; + global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing) + { return global::ProtoBuf.Extensible.GetExtensionObject(ref extensionObject, createIfMissing); } + } + +} \ No newline at end of file