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:])
	users: typing.Sequence[UserStore] = httpx.get('https://api.punoted.net/v1/storages/',
			headers={'X-Data-Token': config.punoted_api_key}).raise_for_status().json()

	for user in users:
		print(user['Username'])
		for storage in user['Storages']:
			for item in storage['StorageItems']:
				if item['MaterialTicker'] in items:
					name = storage['Name']
					if name == 'null':
						name = storage['Location']
					print(f'\t{name}: {item["MaterialAmount"]}')

class UserStore(typing.TypedDict):
	Username: str
	Storages: typing.Sequence[Storage]

class Storage(typing.TypedDict):
	Name: str
	Location: str
	StorageItems: typing.Sequence[StorageItem]

class StorageItem(typing.TypedDict):
	MaterialTicker: str
	MaterialAmount: int

if __name__ == '__main__':
	main()
