put method

Future<void> put()

Sends a PUT request to the bridge for each resource in the list.

NOTE: This method will not send a PUT request for a resource that has a null bridge property.

Implementation

Future<void> put() async {
  List<List<Resource>> nonPuttableResources = [
    bridgeHomes,
    behaviorScripts,
    matterFabrics,
  ];

  for (List<Resource> resourceList in resources) {
    if (nonPuttableResources.contains(resourceList)) continue;

    for (Resource resource in resourceList) {
      Map<String, dynamic> data = resource.toJson();

      if (data.isEmpty) continue;

      if (resource.bridge != null) {
        await resource.bridge!.put(resource);
      }
    }
  }
}