postUri property

Uri get postUri

Implementation

Uri get postUri {
  final uriCopy = uri!;
  final port = uriCopy.hasPort &&
          ((uriCopy.scheme == 'http' && uriCopy.port != 80) ||
              (uriCopy.scheme == 'https' && uriCopy.port != 443))
      ? ':${uriCopy.port}'
      : '';

  final pathLength = uriCopy.pathSegments.length;

  String apiPath;
  if (pathLength > 1) {
    // some paths would present before the projectID in the uri
    apiPath =
        (uriCopy.pathSegments.sublist(0, pathLength - 1) + ['api']).join('/');
  } else {
    apiPath = 'api';
  }
  return Uri.parse(
    '${uriCopy.scheme}://${uriCopy.host}$port/$apiPath/$projectId/envelope/',
  );
}