Skip to content

Commit

Permalink
Add GetRoamingOperators method
Browse files Browse the repository at this point in the history
  • Loading branch information
Capucinimo committed Jun 17, 2022
1 parent 1020d15 commit 6023ed2
Show file tree
Hide file tree
Showing 11 changed files with 297 additions and 67 deletions.
17 changes: 17 additions & 0 deletions proto/RoamingOperator.proto
Original file line number Diff line number Diff line change
@@ -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;
}
136 changes: 71 additions & 65 deletions src/ComDiadocApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
}
}
}
5 changes: 5 additions & 0 deletions src/DiadocApi.Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ public Task<Organization> GetOrganizationByInnKppAsync(string inn, string kpp)
return diadocHttpApi.GetOrganizationByInnKppAsync(inn, kpp);
}

public Task<RoamingOperatorList> GetRoamingOperatorsAsync(string authToken, string boxId)
{
return diadocHttpApi.GetRoamingOperatorsAsync(authToken, boxId);
}

public Task<Box> GetBoxAsync(string boxId)
{
if (boxId == null) throw new ArgumentNullException("boxId");
Expand Down
5 changes: 5 additions & 0 deletions src/DiadocApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion src/DiadocHttpApi.References.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,4 @@ public List<OrganizationWithCounteragentStatus> GetOrganizationsByInnList(string
return response.Organizations;
}
}
}
}
16 changes: 16 additions & 0 deletions src/DiadocHttpApi.RoamingOperators.Async.cs
Original file line number Diff line number Diff line change
@@ -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<RoamingOperatorList> GetRoamingOperatorsAsync(string authToken, string boxId)
{
var queryString = new PathAndQueryBuilder("/GetRoamingOperators");
queryString.AddParameter("boxId", boxId);
return PerformHttpRequestAsync<RoamingOperatorList>(authToken, "GET", queryString.BuildPathAndQuery());
}
}
}
15 changes: 15 additions & 0 deletions src/DiadocHttpApi.RoamingOperators.cs
Original file line number Diff line number Diff line change
@@ -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<RoamingOperatorList>(authToken, "GET", queryString.BuildPathAndQuery());
}
}
}
2 changes: 2 additions & 0 deletions src/IDiadocApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -312,6 +313,7 @@ Task<string> AuthenticateWithKeyAsync(byte[] certificateBytes, bool useLocalSyst
Task<Organization> GetOrganizationByBoxIdAsync(string boxId);
Task<Organization> GetOrganizationByFnsParticipantIdAsync(string fnsParticipantId);
Task<Organization> GetOrganizationByInnKppAsync(string inn, string kpp);
Task<RoamingOperatorList> GetRoamingOperatorsAsync(string authToken, string boxId);
Task<Box> GetBoxAsync(string boxId);
Task<Department> GetDepartmentAsync(string authToken, string orgId, string departmentId);
Task UpdateOrganizationPropertiesAsync(string authToken, OrganizationPropertiesToUpdate orgProps);
Expand Down
2 changes: 1 addition & 1 deletion src/Proto/Invoicing/ExtendedSigner.proto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,4 +384,4 @@ public enum DocumentTitleType
Ucd736Buyer = 11
}

}
}
72 changes: 72 additions & 0 deletions src/Proto/RoamingOperator.cs
Original file line number Diff line number Diff line change
@@ -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}";
}
}
}
Loading

0 comments on commit 6023ed2

Please sign in to comment.