MiniProgramPublisherBackendSmokeCase.fromJson constructor

MiniProgramPublisherBackendSmokeCase.fromJson(
  1. Object? json
)

Decodes a smoke-test route from JSON.

Implementation

factory MiniProgramPublisherBackendSmokeCase.fromJson(Object? json) {
  if (json is! Map) {
    throw const FormatException(
      'Publisher API smoke test must be a JSON object.',
    );
  }
  return MiniProgramPublisherBackendSmokeCase(
    id: _readString(json, 'id'),
    method: _readOptionalString(json, 'method') ?? 'GET',
    endpoint: _readString(json, 'endpoint'),
    body: _readOptionalMap(json, 'body') ?? const <String, Object?>{},
    expectation: MiniProgramPublisherBackendSmokeExpectation(
      expectedStatus:
          _readOptionalInt(json, 'expectedStatus') ??
          MiniProgramPublisherBackendSmokeExpectation.defaultExpectedStatus,
      expectJsonObject:
          _readOptionalBool(json, 'expectJsonObject') ??
          MiniProgramPublisherBackendSmokeExpectation.defaultExpectJsonObject,
    ),
  );
}