local method

  1. @override
Future<PactResponse> local({
  1. required String host,
  2. required PactCommand command,
  3. bool preflight = true,
  4. bool signatureValidation = true,
})
override

Implementation

@override
Future<PactResponse> local({
  required String host,
  required PactCommand command,
  bool preflight = true,
  bool signatureValidation = true,
}) async {
  http.Response response = await http.post(
    Uri.parse(
      '$host/local?preflight=$preflight&signatureValidation=$signatureValidation',
    ),
    headers: <String, String>{
      'Content-Type': 'application/json; charset=UTF-8',
    },
    body: command.toJson(),
  );

  try {
    return PactResponse.fromJson(
      jsonDecode(
        response.body,
      ),
    );
  } catch (e) {
    throw PactApiError(
      error: response.body,
    );
  }
}