send method

  1. @override
Future<PactSendResponse> send({
  1. required String host,
  2. required PactSendRequest commands,
})
override

Implementation

@override
Future<PactSendResponse> send({
  required String host,
  required PactSendRequest commands,
}) async {
  http.Response response = await http.post(
    Uri.parse(
      '$host/send',
    ),
    headers: <String, String>{
      'Content-Type': 'application/json; charset=UTF-8',
    },
    body: commands.toJson(),
  );

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