mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
22 lines
709 B
C#
22 lines
709 B
C#
|
|
using System;
|
||
|
|
using System.Net.Http;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using Newtonsoft.Json;
|
||
|
|
|
||
|
|
namespace Kruzya.TelegramBot.Core.Extensions
|
||
|
|
{
|
||
|
|
public static class HttpClientExtension
|
||
|
|
{
|
||
|
|
public static async Task<T> GetJsonAsync<T>(this HttpClient client, Uri requestUri)
|
||
|
|
{
|
||
|
|
var response = await client.GetStringAsync(requestUri);
|
||
|
|
return JsonConvert.DeserializeObject<T>(response);
|
||
|
|
}
|
||
|
|
|
||
|
|
public static async Task<T> GetJsonAsync<T>(this HttpClient client, string requestUri)
|
||
|
|
{
|
||
|
|
var response = await client.GetStringAsync(requestUri);
|
||
|
|
return JsonConvert.DeserializeObject<T>(response);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|