示例#1
0
        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));
        }
示例#2
0
 public static async Task <QuerySireneResponse> RunAsync(QuerySireneRequest request)
 {
     return(await RunAsync(
                request,
                GetLocalCacheKey,
                GetLocalCacheAsync,
                SetLocalCacheAsync
                ));
 }
示例#3
0
 private static string GetLocalCacheKey(QuerySireneRequest request) => $"sirene_{request.Siren}.json";