async def packages(
            self, package_state: Union[int, str] = '',
            show_archived: bool = False) -> list:
        """Get the list of packages associated with the account."""
        packages_resp = await self._request(
            'post',
            API_URL_BUYER,
            json={
                'version': '1.0',
                'method': 'GetTrackInfoList',
                'param': {
                    'IsArchived': show_archived,
                    'Item': '',
                    'Page': 1,
                    'PerPage': 40,
                    'PackageState': package_state,
                    'Sequence': '0'
                },
                'sourcetype': 0
            })

        _LOGGER.debug('Packages response: %s', packages_resp)

        packages = []
        for package in packages_resp.get('Json', []):
            last_event = package.get('FLastEvent')
            if last_event:
                event = json.loads(last_event)
            else:
                event = {}

            kwargs = {
                'destination_country': package.get('FSecondCountry', 0),
                'friendly_name': package.get('FRemark'),
                'info_text': event.get('z'),
                'location': event.get('c'),
                'origin_country': package.get('FFirstCountry', 0),
                'package_type': package.get('FTrackStateType', 0),
                'status': package.get('FPackageState', 0)
            }
            packages.append(Package(package['FTrackNo'], **kwargs))
        return packages
async def packages ( self , package_state : Union [ int , str ] = '' , show_archived : bool = False ) -> list : packages_resp = await self . _request ( 'post' , API_URL_BUYER , json = { 'version' : '1.0' , 'method' : 'GetTrackInfoList' , 'param' : { 'IsArchived' : show_archived , 'Item' : '' , 'Page' : 1 , 'PerPage' : 40 , 'PackageState' : package_state , 'Sequence' : '0' } , 'sourcetype' : 0 } ) _LOGGER . debug ( 'Packages response: %s' , packages_resp ) packages = [ ] for package in packages_resp . get ( 'Json' , [ ] ) : last_event = package . get ( 'FLastEvent' ) if last_event : event = json . loads ( last_event ) else : event = { } kwargs = { 'destination_country' : package . get ( 'FSecondCountry' , 0 ) , 'friendly_name' : package . get ( 'FRemark' ) , 'info_text' : event . get ( 'z' ) , 'location' : event . get ( 'c' ) , 'origin_country' : package . get ( 'FFirstCountry' , 0 ) , 'package_type' : package . get ( 'FTrackStateType' , 0 ) , 'status' : package . get ( 'FPackageState' , 0 ) } packages . append ( Package ( package [ 'FTrackNo' ] , ** kwargs ) ) return packages
Get the list of packages associated with the account.