MiniProgramPublisherBackendContract constructor

MiniProgramPublisherBackendContract({
  1. int schemaVersion = currentSchemaVersion,
  2. String contractVersion = currentContractVersion,
  3. required String appId,
  4. required Uri backendBaseUri,
  5. String accessMode = accessModeProtected,
  6. String healthEndpoint = defaultHealthEndpoint,
  7. List<MiniProgramPublisherBackendSmokeCase>? smokeTests,
  8. bool allowLocalHttp = false,
})

Creates a provider-neutral Publisher API contract.

Implementation

MiniProgramPublisherBackendContract({
  this.schemaVersion = currentSchemaVersion,
  this.contractVersion = currentContractVersion,
  required String appId,
  required Uri backendBaseUri,
  String accessMode = accessModeProtected,
  String healthEndpoint = defaultHealthEndpoint,
  List<MiniProgramPublisherBackendSmokeCase>? smokeTests,
  bool allowLocalHttp = false,
}) : appId = _normalizeAppId(appId),
     backendBaseUri = _normalizeBackendBaseUri(
       backendBaseUri,
       allowLocalHttp: allowLocalHttp,
     ),
     accessMode = _normalizeAccessMode(accessMode),
     healthEndpoint = _normalizeRelativeEndpoint(
       healthEndpoint,
       'healthEndpoint',
     ),
     smokeTests = List.unmodifiable(
       _normalizeSmokeTests(smokeTests, healthEndpoint: healthEndpoint),
     ) {
  if (schemaVersion != currentSchemaVersion) {
    throw FormatException(
      'Unsupported Publisher API contract schemaVersion: '
      '$schemaVersion.',
    );
  }
  if (contractVersion.trim() != currentContractVersion) {
    throw FormatException(
      'Unsupported Publisher API contractVersion: $contractVersion.',
    );
  }
}