Files

25 lines
739 B
C#
Raw Permalink Normal View History

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