using System; using System.Collections.Generic; using System.Threading.Tasks; using BO.AppServer.Metadata.Dto; using BO.AppServer.Metadata.Enums; using Quadarax.Foundation.Core.Data.Interface; using Quadarax.Foundation.Core.Data.Interface.Entity.Dto; using Quadarax.Foundation.Core.Logging; namespace BO.Connector.Console { public class Connection : AbstractConnection { #region *** Private fields *** protected override string ApiName => "Console"; #endregion #region *** Constructors *** public Connection(Uri uriApiBase, TimeSpan timeout, ILogHandler log = null, bool isDumpContentEnabled = false) : base(uriApiBase, timeout, log, isDumpContentEnabled) { } #endregion #region *** CRUD User *** public async Task GetUserAsync(IdentificationTypeEnum identificationType, string identificationValue) { CheckIsOpen(); var result = await CallRequestAsync>($"{Ticket}/user/{identificationType}/{identificationValue}", RestCallTypeEnum.Get); return result.Value; } public async Task> GetUsersAsync(UserScopeEnums scope, PagingDto paging = null) { CheckIsOpen(); var result = await CallRequestAsync>($"{Ticket}/users/{scope}", RestCallTypeEnum.Get,null, GetPagingHeaderAttributes(paging)); return result.Values; } public async Task CreateUserAsync(UserCDto newUser) { CheckIsOpen(); var result = await CallRequestAsync>($"{Ticket}/user", RestCallTypeEnum.Post, newUser); return result.Value; } public async Task UpdateUserAsnc(IdentificationTypeEnum identificationType, string identificationValue, UserUDto updateUser) { CheckIsOpen(); var result = await CallRequestAsync>($"{Ticket}/user/{identificationType}/{identificationValue}", RestCallTypeEnum.Put, updateUser); return result.Value; } public async Task DeleteUserAsync(IdentificationTypeEnum identificationType, string identificationValue) { CheckIsOpen(); var result = await CallRequestAsync>($"{Ticket}/user/{identificationType}/{identificationValue}", RestCallTypeEnum.Delete); return result.Value; } #endregion #region *** Statistics *** public async Task> GetStatisticsAsync(StatisticsScopeEnums scope, PagingDto paging = null) { CheckIsOpen(); var result = await CallRequestAsync>($"{Ticket}/statistics/{scope}", RestCallTypeEnum.Get,null,GetPagingHeaderAttributes(paging)); return result.Values; } public async Task> GetVersionsAsync() { CheckIsOpen(); var result = await CallRequestAsync>($"{Ticket}/versions", RestCallTypeEnum.Get); return result.Values; } #endregion #region *** CRUD BillingPlan *** public async Task CreateBillingPlanAsync(BillingPlanCDto newBillingPlan) { CheckIsOpen(); var result = await CallRequestAsync>($"{Ticket}/bplan", RestCallTypeEnum.Post,newBillingPlan); return result.Value; } public async Task UpdateBillingPlanAsync(BillingPlanUDto updBillingPlan) { CheckIsOpen(); var result = await CallRequestAsync>($"{Ticket}/bplan", RestCallTypeEnum.Put,updBillingPlan); return result.Value; } public async Task> GetBillingPlansAsync(BPlanScopeEnums scope, PagingDto paging = null) { CheckIsOpen(); var result = await CallRequestAsync>($"{Ticket}/bplans/{scope}", RestCallTypeEnum.Get,null,GetPagingHeaderAttributes(paging)); return result.Values; } #endregion #region *** CRUD MIME Type *** public async Task CreateMimeTypeAsync(MimeTypeCDto newMimeType) { CheckIsOpen(); var result = await CallRequestAsync>($"{Ticket}/mtype", RestCallTypeEnum.Post,newMimeType); return result.Value; } public async Task UpdateMimeTypeAsync(MimeTypeUDto updMimeType) { CheckIsOpen(); var result = await CallRequestAsync>($"{Ticket}/mtype", RestCallTypeEnum.Put,updMimeType); return result.Value; } public async Task> GetMimeTypesAsync(MimeTypeScopeEnums scope, PagingDto paging = null) { CheckIsOpen(); var result = await CallRequestAsync>($"{Ticket}/mtypes/{scope}", RestCallTypeEnum.Get,null,GetPagingHeaderAttributes(paging)); return result.Values; } #endregion #region *** Documents *** public async Task> GetDocumentsAsync(MimeTypeScopeEnums scope,IdentificationTypeEnum identificationType, string identificationValue, PagingDto paging = null) { CheckIsOpen(); var result = await CallRequestAsync>($"{Ticket}/documents/{identificationType}/{identificationValue}/{scope}", RestCallTypeEnum.Get,null,GetPagingHeaderAttributes(paging)); return result.Values; } #endregion } }