File: test_api.py

package info (click to toggle)
py17track 2021.12.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 276 kB
  • sloc: python: 859; sh: 41; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 1,010 bytes parent folder | download | duplicates (2)
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
27
28
29
30
31
32
33
34
35
"""Run an example script to quickly test a 17track.net account."""
import asyncio
import logging

from aiohttp import ClientSession

from py17track import Client
from py17track.errors import SeventeenTrackError

_LOGGER = logging.getLogger()


async def main() -> None:
    """Create the aiohttp session and run the example."""
    logging.basicConfig(level=logging.INFO)

    async with ClientSession() as session:
        try:
            client = Client(session=session)

            await client.profile.login("<EMAIL>", "<PASSWORD>")
            _LOGGER.info("Account ID: %s", client.profile.account_id)

            # await client.profile.add_package("<TRACKING NUMBER>", "<FRIENDLY NAME>")

            summary = await client.profile.summary()
            _LOGGER.info("Account Summary: %s", summary)

            packages = await client.profile.packages()
            _LOGGER.info("Package Summary: %s", packages)
        except SeventeenTrackError as err:
            print(err)


asyncio.run(main())