put static method

Future<Map<String, dynamic>?> put({
  1. required String bridgeIpAddr,
  2. String? pathToResource,
  3. required String applicationKey,
  4. required ResourceType? resourceType,
  5. required String body,
  6. required String? token,
})

Update an existing resource.

bridgeIpAddr is the IP address of the target bridge.

If a specific resource is being queried, include pathToResource. This is most likely the resource's ID.

applicationKey is the key associated with this devices in the bridge's whitelist.

The resourceType is used to let the bridge know what type of resource is being queried.

body is the actual content being sent to the bridge.

token is the access token for remote access.

May throw ExpiredAccessTokenException if trying to connect to the bridge remotely and the token is expired. If this happens, refresh the token with TokenRepo.refreshRemoteToken.

Implementation

static Future<Map<String, dynamic>?> put({
  required String bridgeIpAddr,
  String? pathToResource,
  required String applicationKey,
  required ResourceType? resourceType,
  required String body,
  required String? token,
}) async {
  return await HueHttpClient.put(
    url: getTargetUrl(
      bridgeIpAddr: bridgeIpAddr,
      resourceType: resourceType,
      pathToResource: pathToResource,
      isRemote: false,
    ),
    applicationKey: applicationKey,
    token: null,
    body: body,
  ).timeout(
    const Duration(seconds: 1),
    onTimeout: () async {
      return await HueHttpClient.put(
        url: getTargetUrl(
          bridgeIpAddr: bridgeIpAddr,
          resourceType: resourceType,
          pathToResource: pathToResource,
          isRemote: true,
        ),
        applicationKey: applicationKey,
        token: token,
        body: body,
      );
    },
  );
}