get method

Future<Map<String, dynamic>?> get(
  1. Resource resource, {
  2. String decrypter(
    1. String ciphertext
    )?,
})

Fetch the given resource from this bridge.

decrypter When the old tokens are read from local storage, they are decrypted. This parameter allows you to provide your own decryption method. This will be used in addition to the default decryption method. This will be performed after the default decryption method.

Will return null if:

  • The resource does not exist on this bridge
  • This bridge does not have an IP address
  • This bridge does not have an application key
  • Any other unforeseen error

Implementation

Future<Map<String, dynamic>?> get(
  Resource resource, {
  String Function(String ciphertext)? decrypter,
}) async {
  if (ipAddress == null) return null;
  if (applicationKey == null) return null;

  try {
    return await HueHttpRepo.get(
      bridgeIpAddr: ipAddress!,
      pathToResource: resource.id,
      applicationKey: applicationKey!,
      resourceType: resource.type,
      decrypter: decrypter,
    );
  } catch (_) {
    return null;
  }
}