# retrieveDeviceBundles method

Future <Result<OmemoError, List <OmemoBundle>>> retrieveDeviceBundles(

1. JID jid

)

Retrieve all device bundles for the JID `jid`.

On success, returns a list of devices. On failure, returns am OmemoError.

## Implementation

    Future<Result<OmemoError, List<omemo.OmemoBundle>>> retrieveDeviceBundles(
      JID jid,
    ) async {
      // TODO(Unknown): Should we query the device list first?
      final pm = getAttributes().getManagerById<PubSubManager>(pubsubManager)!;
      final bundlesRaw = await pm.getItems(jid, omemoBundlesXmlns);
      if (bundlesRaw.isType<PubSubError>()) return Result(UnknownOmemoError());

      final bundles = bundlesRaw
          .get<List<PubSubItem>>()
          .map(
            (bundle) => bundleFromXML(jid, int.parse(bundle.id), bundle.payload),
          )
          .toList();

      return Result(bundles);
    }