27 lines
715 B
C#
27 lines
715 B
C#
using Newtonsoft.Json;
|
|
using jtom38.Newsbot.Domain.Models.Collector;
|
|
|
|
namespace Newsbot.Services.Collector;
|
|
|
|
public class ArticlesClient
|
|
{
|
|
private readonly HttpClient _client;
|
|
private string? InstanceUri { get; set; }
|
|
|
|
public ArticlesClient(string? instanceUri)
|
|
{
|
|
_client = new HttpClient();
|
|
InstanceUri = instanceUri;
|
|
}
|
|
|
|
public async Task<List<ArticlesDto>> ListArticles()
|
|
{
|
|
var resp = await _client.GetAsync($"{InstanceUri}/api/articles");
|
|
var content = await resp.Content.ReadAsStringAsync();
|
|
var res = JsonConvert.DeserializeObject<List<ArticlesDto>>(content);
|
|
|
|
res ??= new List<ArticlesDto>();
|
|
|
|
return res;
|
|
}
|
|
} |