python-dependency-injector/examples/miniapps/giphynav-aiohttp/giphynavigator/services.py

19 lines
444 B
Python
Raw Normal View History

2020-07-27 05:39:01 +03:00
"""Services module."""
from .giphy import GiphyClient
class SearchService:
def __init__(self, giphy_client: GiphyClient):
self._giphy_client = giphy_client
async def search(self, query, limit):
2020-07-28 04:49:13 +03:00
"""Search for gifs and return formatted data."""
2020-07-27 05:39:01 +03:00
if not query:
return []
result = await self._giphy_client.search(query, limit)
return [{'url': gif['url']} for gif in result['data']]