2023-08-13 06:59:16 -04:00
|
|
|
using Newtonsoft.Json;
|
2023-08-13 07:44:06 -04:00
|
|
|
using Smakolykytl2Epub.Models;
|
2023-08-13 06:59:16 -04:00
|
|
|
|
|
|
|
namespace Smakolykytl2Epub.Utils;
|
|
|
|
|
|
|
|
public class Ranobe
|
|
|
|
{
|
|
|
|
private const string ApiUrl = "https://api.smakolykytl.site/api/user/";
|
|
|
|
private const string SiteUrl = "https://smakolykytl.site/";
|
2023-08-13 07:44:06 -04:00
|
|
|
private static readonly HttpClient Client = new();
|
2023-08-13 06:59:16 -04:00
|
|
|
|
|
|
|
public static async Task<Projects?> GetById(int id)
|
|
|
|
{
|
2023-08-13 07:44:06 -04:00
|
|
|
var response = await Client.GetAsync(ApiUrl + "projects/" + id);
|
2023-08-13 06:59:16 -04:00
|
|
|
var content = await response.Content.ReadAsStringAsync();
|
|
|
|
// Console.WriteLine(content);
|
|
|
|
return JsonConvert.DeserializeObject<Projects>(content);
|
|
|
|
}
|
2023-08-13 07:44:06 -04:00
|
|
|
|
2023-08-13 06:59:16 -04:00
|
|
|
public static async Task<Books?> GetChaptersById(int id)
|
|
|
|
{
|
2023-08-13 07:44:06 -04:00
|
|
|
var response = await Client.GetAsync(ApiUrl + "projects/" + id + "/books");
|
2023-08-13 06:59:16 -04:00
|
|
|
var content = await response.Content.ReadAsStringAsync();
|
|
|
|
// Console.WriteLine(content);
|
|
|
|
return JsonConvert.DeserializeObject<Books>(content);
|
|
|
|
}
|
2023-08-13 07:44:06 -04:00
|
|
|
|
2023-08-13 06:59:16 -04:00
|
|
|
public static async Task<Chapters?> GetChapterById(int id)
|
|
|
|
{
|
2023-08-13 07:44:06 -04:00
|
|
|
var response = await Client.GetAsync(ApiUrl + "chapters/" + id);
|
2023-08-13 06:59:16 -04:00
|
|
|
var content = await response.Content.ReadAsStringAsync();
|
|
|
|
// Console.WriteLine(content);
|
|
|
|
return JsonConvert.DeserializeObject<Chapters>(content);
|
|
|
|
}
|
|
|
|
}
|