Skip to content

Commit

Permalink
feat: add get niscode by validFrom date
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Added method INisCodeService
  • Loading branch information
jvandaal authored and ArneD committed Nov 4, 2024
1 parent d09ec30 commit f244cc9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ nuget Newtonsoft.Json 13.0.3

// VBR STUFF
nuget Be.Vlaanderen.Basisregisters.Build.Pipeline 7.0.4 strategy:max
nuget Be.Vlaanderen.Basisregisters.DockerUtilities 2.0.0
nuget Be.Vlaanderen.Basisregisters.DockerUtilities 3.0.0
nuget Be.Vlaanderen.Basisregisters.Aws.DistributedMutex 4.0.1

// TEST STUFF
Expand Down
3 changes: 3 additions & 0 deletions src/NisCodeService.Abstractions/INisCodeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

namespace NisCodeService.Abstractions
{
using System;

public interface INisCodeService
{
Task<Dictionary<string, string>> GetAll(CancellationToken cancellationToken = default);
Task<string?> Get(string ovoCode, CancellationToken cancellationToken = default);
Task<string?> Get(string ovoCode, DateTime validFrom, CancellationToken cancellationToken = default);
}
}
6 changes: 6 additions & 0 deletions src/NisCodeService.DynamoDb/DynamoDbNisCodeService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace NisCodeService.DynamoDb
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
Expand Down Expand Up @@ -54,5 +55,10 @@ public async Task<Dictionary<string, string>> GetAll(CancellationToken cancellat
var response = await _amazonDynamoDb.GetItemAsync(query, cancellationToken);
return response.Item?.GetValueOrDefault(ColumnNames.NisCode)?.S;
}

public Task<string?> Get(string ovoCode, DateTime validFrom, CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}
}
}
7 changes: 7 additions & 0 deletions src/NisCodeService.HardCoded/HardCodedNisCodeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,12 @@ public Task<Dictionary<string, string>> GetAll(CancellationToken cancellationTok

return Task.FromResult(nisCodes?.SingleOrDefault(x => x.IsValid(DateTime.Now))?.NisCode);
}

public Task<string?> Get(string ovoCode, DateTime validFrom, CancellationToken cancellationToken = default)
{
_allNisCodeByOvoCodes.TryGetValue(ovoCode, out var nisCodes);

return Task.FromResult(nisCodes?.SingleOrDefault(x => x.IsValid(validFrom))?.NisCode);
}
}
}

0 comments on commit f244cc9

Please sign in to comment.