2023-05-17 23:36:20 +03:00
|
|
|
using Telegram.Bot.Types;
|
2023-07-28 23:13:56 +03:00
|
|
|
using West.TelegramBot.ContentStore.API;
|
2023-05-17 23:36:20 +03:00
|
|
|
using West.TelegramBot.ContentStore.Model;
|
|
|
|
|
|
2023-07-28 20:04:05 +03:00
|
|
|
namespace West.TelegramBot.ContentStore.Service.SomeRandomApi;
|
2023-05-17 23:36:20 +03:00
|
|
|
|
|
|
|
|
public abstract class SomeRandomApiAbstractService : IRandomMediaService
|
|
|
|
|
{
|
2023-07-28 23:13:56 +03:00
|
|
|
private readonly ISomeRandomApi _api;
|
|
|
|
|
|
2023-05-17 23:36:20 +03:00
|
|
|
public StoreItem StoreItem { get; }
|
|
|
|
|
|
2023-07-28 23:13:56 +03:00
|
|
|
protected SomeRandomApiAbstractService(ISomeRandomApi api, string id, string name, double price, int order)
|
2023-05-17 23:36:20 +03:00
|
|
|
{
|
|
|
|
|
StoreItem = new(id, name, price, order);
|
2023-07-28 23:13:56 +03:00
|
|
|
_api = api;
|
2023-05-17 23:36:20 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<RandomMedia> GetRandomMediaAsync()
|
|
|
|
|
{
|
2023-07-28 23:13:56 +03:00
|
|
|
var image = await _api.GetAnimalAsync(StoreItem.Id);
|
2023-05-17 23:36:20 +03:00
|
|
|
|
|
|
|
|
return new RandomMedia(new InputFileUrl(image.Image), image.Fact);
|
|
|
|
|
}
|
|
|
|
|
}
|