Files
telegram-bot/modules/ContentStore/Service/SomeRandomApi/SomeRandomApiAbstractService.cs
T
2023-07-28 23:14:05 +03:00

25 lines
739 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()
{
var image = await _api.GetAnimalAsync(StoreItem.Id);
return new RandomMedia(new InputFileUrl(image.Image), image.Fact);
}
}