File: examples.py

package info (click to toggle)
pynordpool 0.3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 524 kB
  • sloc: python: 349; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 772 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""Example usage of the library."""

import asyncio
from datetime import datetime, timedelta

import aiohttp

from pynordpool import Currency, NordPoolClient


async def main(loop: asyncio.AbstractEventLoop) -> None:
    """Print the delivery period."""
    async with aiohttp.ClientSession(loop=loop) as session:
        client = NordPoolClient(session)
        output = await client.async_get_delivery_period(
            datetime.now(), Currency.EUR, ["SE3"]
        )
        output2 = await client.async_get_delivery_periods(
            [datetime.now(), datetime.now() + timedelta(days=1)], Currency.EUR, ["SE3"]
        )
        print(output)  # noqa: T201
        print(output2)  # noqa: T201


loop = asyncio.get_event_loop()
loop.run_until_complete(main(loop))