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."); } }
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); }
private async Task <TagCollection> LoadTagsAsync() { IRestListResponse <Tag> response = await _client.GetAsJsonListAsync <Tag>(this.Endpoint).ConfigureAwait(false); return(new TagCollection(this.ProcessResponse(response))); }
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); }