Ability to book a single court at a given time with gestion-sports
This commit is contained in:
parent
3f18f0f4a2
commit
e953a4110b
14 changed files with 489 additions and 66 deletions
|
@ -1,25 +1,33 @@
|
|||
import asyncio
|
||||
import logging
|
||||
|
||||
import pendulum
|
||||
from aiohttp import ClientSession
|
||||
|
||||
from resa_padel import config
|
||||
from resa_padel.gestion_sports_connector import GestionSportsConnector
|
||||
from resa_padel.gestion_sports.gestion_sports_connector import GestionSportsConnector
|
||||
from resa_padel.models import User, BookingFilter
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def book(url: str, user: str, password: str, club_id: str) -> ClientSession:
|
||||
async def book(url: str, user: User, booking_filter: BookingFilter) -> ClientSession:
|
||||
async with ClientSession() as session:
|
||||
platform = GestionSportsConnector(session, url)
|
||||
await platform.connect()
|
||||
await platform.login(user, password, club_id)
|
||||
await platform.login(user)
|
||||
await platform.book(booking_filter)
|
||||
|
||||
return session
|
||||
|
||||
|
||||
def main() -> None:
|
||||
LOGGER.info("Starting booking padel court")
|
||||
asyncio.run(
|
||||
book(config.GESTION_SPORTS_URL, config.USER, config.PASSWORD, config.CLUB_ID)
|
||||
user = User(login=config.USER, password=config.PASSWORD, club_id=config.CLUB_ID)
|
||||
booking_filter = BookingFilter(
|
||||
court_id=config.COURT_ID,
|
||||
sport_id=config.SPORT_ID,
|
||||
date=pendulum.parse(config.DATE_TIME),
|
||||
)
|
||||
asyncio.run(book(config.GESTION_SPORTS_URL, user, booking_filter))
|
||||
LOGGER.info("Finished booking padel court")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue