Пример #1
0
        private List <Tag> ProcessResponse(IRestListResponse <Tag> response)
        {
            if (!response.IsFaulted)
            {
                return(response.Content);
            }

            else if (response.IsFaulted && response.HasException)
            {
                throw response.Exception;
            }

            else
            {
                throw new InvalidOperationException("An unknown error occurred.");
            }
        }
Пример #2
0
        private async static Task <IndexerSchemaCollection> GetIndexerSchemasAsync(ISonarrClient client)
        {
            IRestListResponse <IndexerSchema> schResponse = await client.GetAsJsonListAsync <IndexerSchema>(GetEndpoint(ApiEndpoints.IndexerSchema));

            return(!schResponse.IsFaulted ? IndexerSchemaCollection.FromSchemas(schResponse.Content) : null);
        }
Пример #3
0
        private async Task <TagCollection> LoadTagsAsync()
        {
            IRestListResponse <Tag> response = await _client.GetAsJsonListAsync <Tag>(this.Endpoint).ConfigureAwait(false);

            return(new TagCollection(this.ProcessResponse(response)));
        }
Пример #4
0
        private async static Task <QualityDictionary> GetQualityDictionaryAsync(ISonarrClient client)
        {
            IRestListResponse <QualityDefinition> defResponse = await client.GetAsJsonListAsync <QualityDefinition>(GetEndpoint(ApiEndpoints.QualityDefinitions));

            return(!defResponse.IsFaulted ? new QualityDictionary(defResponse.Content.Select(x => x.Quality)) : null);
        }