Files

25 lines
759 B
C#

using Telegram.Bot.Types;
using West.TelegramBot.ContentStore.API;
using West.TelegramBot.ContentStore.Model;
namespace West.TelegramBot.ContentStore.Service.SomeRandomApi;
public abstract class SomeRandomApiAbstractService : IRandomMediaService
{
private readonly ISomeRandomApi _api;
public StoreItem StoreItem { get; }
protected SomeRandomApiAbstractService(ISomeRandomApi api, string id, string name, double price, int order)
{
StoreItem = new(id, name, price, order);
_api = api;
}
public async Task<RandomMedia> GetRandomMediaAsync(Chat chat, User user)
{
var image = await _api.GetAnimalAsync(StoreItem.Id);
return new RandomMedia(new InputFileUrl(image.Image), image.Fact);
}
}