using System.Collections.Generic; using System.Threading.Tasks; using Newtonsoft.Json; using LCU.Library.Internal.CoreApiWrapperModel.CoreModels; using LCU.Library.Internal.CoreApiWrapperLib.Utilities; using LCU.Library.Internal.CoreApiWrapperLib.Configuration; using LCU.Library.Internal.CoreApiWrapperLib.CoreApiUtilities; using LCU.Library.Internal.CoreApiWrapperModel.Constants; using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests; using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.AccessChannelPersons; namespace LCU.Library.Internal.CoreApiWrapperLib.DataAccess { public class AccessChannelPersonsDao : BaseCoreDao, IAccessChannelPersonsDao { private readonly CoreConfiguration _coreConfiguration; private readonly CoreApiConfiguration _coreApiConfiguration; public AccessChannelPersonsDao(ICoreRequest coreRequest, CoreConfiguration coreConfiguration) : base(coreRequest) { _coreConfiguration = coreConfiguration; _coreApiConfiguration = _coreConfiguration.CoreApiConfiguration; } /// /// Calls Core API to update Access Channel Person. /// /// /// AccessChannelPerson public async Task UpdateAccessChannelPerson(CoreApiMessage request) { var endpoint = HttpUtilities.ReplaceRootParameter(_coreApiConfiguration.CoreEndPointConfiguration.AccessChannelPersonsAccessChannelPersonId, RequestRootParameters.AccessChannelPersonId, request.MessageBody.Id); var jsonBody = JsonConvert.SerializeObject(request); var result = await _coreRequest.PutRequestObject>(endpoint, null, jsonBody); return result?.MessageBody; } /// /// Calls Core API to search for AccessChannelPersons based By Person. /// Default Included: Graph /// /// /// /// IEnumerable public async Task>> FindAccessChannelPersonsByPerson(CoreRequestParameters coreRequestParameters, AccessChannelPersonsByPersonRequest request) { var endpointParameters = HttpUtilities.BuildDictionaryOfNonNullValues(coreRequestParameters); var jsonBody = JsonConvert.SerializeObject(request); return await _coreRequest.PostRequestObject>>( _coreApiConfiguration.CoreEndPointConfiguration.AccessChannelPersonsByPerson, endpointParameters, jsonBody); } } }