public static async Task <QuerySireneResponse> RunAsync( QuerySireneRequest request, GetCacheKey getCacheKey, GetCacheAsync getCache, SetCacheAsync setCache ) { if (request == null) { throw new ArgumentNullException(nameof(request)); } if (!request.IsValid) { throw new ArgumentException(nameof(request)); } string content = await getCache?.Invoke(getCacheKey?.Invoke(request)); if (string.IsNullOrEmpty(content)) { content = await QueryOrganizationsAsync(request.Token, request.Siren, request.Siret); await setCache?.Invoke(getCacheKey?.Invoke(request), content); } var infos = GetOrganizationsInfos(content); return(new QuerySireneResponse(infos)); }
public static async Task <QuerySireneResponse> RunAsync(QuerySireneRequest request) { return(await RunAsync( request, GetLocalCacheKey, GetLocalCacheAsync, SetLocalCacheAsync )); }
private static string GetLocalCacheKey(QuerySireneRequest request) => $"sirene_{request.Siren}.json";