mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
[store] kitties now have own http client factory
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using System.Text;
|
||||
using West.TelegramBot.ContentStore.Model;
|
||||
|
||||
namespace West.TelegramBot.ContentStore.API;
|
||||
|
||||
public class KittiesApi : IKittiesApi
|
||||
{
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public KittiesApi(HttpClient client)
|
||||
{
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public async Task<KittiesResponse> GetKittiesImageAsync(string type)
|
||||
{
|
||||
var httpResponse = await _client.GetAsync($"v1/{type}");
|
||||
var headers = httpResponse.Headers;
|
||||
var titleBytes =
|
||||
Convert.FromBase64String(headers.GetValues("X-Video-Title").First());
|
||||
|
||||
return new KittiesResponse(
|
||||
await httpResponse.Content.ReadAsStreamAsync(),
|
||||
headers.GetValues("X-Video-Source").First(),
|
||||
Encoding.UTF8.GetString(titleBytes)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user