public HealthController( Pex2AplosMappingStorage pex2AplosMappingStorage, IPexApiClient pexApiClient) { _pex2AplosMappingStorage = pex2AplosMappingStorage; _pexApiClient = pexApiClient; }
public PopulateAplosAccountIds( Pex2AplosMappingStorage mappingStorage, IPexApiClient pexApiClient, ILogger <PopulateAplosAccountIds> logger) { _mappingStorage = mappingStorage; _pexApiClient = pexApiClient; _logger = logger; }
public PexController( IPexApiClient pexApiClient, PexOAuthSessionStorage pexOAuthSessionStorage, Pex2AplosMappingStorage pex2AplosMappingStorage) { _pexApiClient = pexApiClient; _pex2AplosMappingStorage = pex2AplosMappingStorage; _pexOAuthSessionStorage = pexOAuthSessionStorage; }
public TokenRefresher(Pex2AplosMappingStorage mappingStorage, PexOAuthSessionStorage sessionStorage, IPexApiClient pexApiClient, SyncResultStorage resultStorage, ILogger <TokenRefresher> log) { _mappingStorage = mappingStorage; _sessionStorage = sessionStorage; _pexApiClient = pexApiClient; _resultStorage = resultStorage; _log = log; }
public SessionController( PexOAuthSessionStorage pexOAuthSessionStorage, Pex2AplosMappingStorage pex2AplosMappingStorage, IOptions <AppSettingsModel> appSettings, IHttpClientFactory clientFactory, IPexApiClient pexApiClient, IAplosIntegrationService aplosIntegrationService) { _pexOAuthSessionStorage = pexOAuthSessionStorage; _pex2AplosMappingStorage = pex2AplosMappingStorage; _appSettings = appSettings.Value; _clientFactory = clientFactory; _pexApiClient = pexApiClient; _aplosIntegrationService = aplosIntegrationService; }
public static async Task <Dictionary <long, List <AllocationTagValue> > > GetTagAllocations( this IPexApiClient pexApiClient, string externalToken, List <TransactionModel> transactions, CancellationToken cancellationToken = default(CancellationToken)) { if (pexApiClient is null) { throw new ArgumentNullException(nameof(pexApiClient)); } if (externalToken is null) { throw new ArgumentNullException(nameof(externalToken)); } if (transactions is null) { throw new ArgumentNullException(nameof(transactions)); } var tagDefinitions = new List <TagDetailsModel>(); if (transactions.Any(t => t.TransactionTags?.Tags != null)) { //Only get the tag definitions if we see tags on the transactions. //If a businesses uses tags for some time then disables them, this will throw an exception. tagDefinitions.AddRange(await pexApiClient.GetTags(externalToken, cancellationToken)); } return(await GetTagAllocations( pexApiClient, externalToken, transactions, tagDefinitions)); }
public static async Task <Dictionary <long, List <AllocationTagValue> > > GetTagAllocations( this IPexApiClient pexApiClient, string externalToken, List <TransactionModel> transactions, List <TagDetailsModel> tagDefinitions) { if (pexApiClient is null) { throw new ArgumentNullException(nameof(pexApiClient)); } if (externalToken is null) { throw new ArgumentNullException(nameof(externalToken)); } if (transactions is null) { throw new ArgumentNullException(nameof(transactions)); } if (tagDefinitions is null) { throw new ArgumentNullException(nameof(tagDefinitions)); } var result = new Dictionary <long, List <AllocationTagValue> >(); Dictionary <string, TagDetailsModel> hashedTagDefinitions = tagDefinitions.ToDictionary(key => key.Id, value => value); foreach (TransactionModel transaction in transactions) { var allocations = new List <AllocationTagValue>(); var defaultAllocation = new AllocationTagValue { TagId = null, Allocation = new List <TagValueItem>(), Amount = Math.Abs(transaction.TransactionAmount), }; if (transaction.TransactionTags?.Tags != null) { foreach (TransactionTagModel tag in transaction.TransactionTags.Tags) { if (!hashedTagDefinitions.TryGetValue(tag.FieldId, out TagDetailsModel tagDefinition)) { throw new KeyNotFoundException($"Unable to find tag defintion for {nameof(TagDetailsModel.Id)} '{tag.FieldId}'."); } if (tagDefinition.Type == CustomFieldType.Allocation) { //Split tags var allocation = JsonConvert.DeserializeObject <AllocationTagValue>(tag.Value.ToString()); allocations.Add(allocation); } else { //Non-split tags defaultAllocation.Allocation.Add(new TagValueItem { TagId = tag.FieldId, Value = tag.Value, }); } } } if (!allocations.Any()) { //Ensure each transaction has at least one allocation allocations.Add(defaultAllocation); } result.Add(transaction.TransactionId, allocations); } return(result); }