| 1234567891011121314151617181920212223242526272829303132 |
- from __future__ import annotations
- import sys
- import typing
- import httpx
- from config import config
- def main():
- items = frozenset(i.upper() for i in sys.argv[1:])
- storages: typing.Sequence[Storage] = httpx.get('https://api.punoted.net/v1/storages/user',
- headers={'X-Data-Token': config.punoted_api_key}).raise_for_status().json()
- for storage in storages:
- for item in storage['StorageItems']:
- if item['MaterialTicker'] in items:
- name = storage['Name']
- if name == 'null':
- name = storage['Location']
- print(f'{name}: {item["MaterialAmount"]} {item["MaterialTicker"]}')
- class Storage(typing.TypedDict):
- Name: str
- Location: str
- StorageItems: typing.Sequence[StorageItem]
- class StorageItem(typing.TypedDict):
- MaterialTicker: str
- MaterialAmount: int
- if __name__ == '__main__':
- main()
|