getTargetUrl static method

String getTargetUrl({
  1. required String bridgeIpAddr,
  2. ResourceType? resourceType,
  3. String? pathToResource,
})

Returns a properly formatted target URL.

bridgeIpAddr is the IP address of the target bridge.

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

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

Implementation

static String getTargetUrl({
  required String bridgeIpAddr,
  ResourceType? resourceType,
  String? pathToResource,
}) {
  String resourceTypeStr = resourceType?.value ?? "";

  if (resourceTypeStr.isNotEmpty) {
    resourceTypeStr = "/$resourceTypeStr";
  }

  String subPath = pathToResource ?? "";

  if (subPath.isNotEmpty && !subPath.startsWith("/")) {
    subPath = "/$subPath";
  }

  return "https://$bridgeIpAddr/clip/v2/resource$resourceTypeStr$subPath";
}