Пример #1
0
        public async Task <Clan> GetOrFetchClanAsync(string tag, CancellationToken?cancellationToken = default)
        {
            Clan?result = (await GetCachedClanOrDefaultAsync(tag, cancellationToken).ConfigureAwait(false))?.Data;

            if (result == null)
            {
                result = await _clansApi.FetchClanAsync(tag, cancellationToken).ConfigureAwait(false);
            }

            return(result);
        }
Пример #2
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            if (string.IsNullOrWhiteSpace(_settings.Value.Token) || _settings.Value.Token == "put your token here")
            {
                throw InvalidToken();
            }

            try
            {
                await ClansApi.FetchClanAsync("#929YJPYJ", cancellationToken);
            }
            catch (ApiException e) when(e.Message == "Forbidden")
            {
                throw InvalidToken();
            }
        }