updateContact method

Future<void> updateContact(
  1. String contactId,
  2. Map<String, dynamic> contactData
)

Implementation

Future<void> updateContact(
    String contactId, Map<String, dynamic> contactData) async {
  final url = '$mauticBaseUrl/api/contacts/$contactId/edit';
  final headers = getHeaders();

  // Send the update request to Mautic
  final response = await httpClient.patch(
    Uri.parse(url),
    headers: headers,
    body: jsonEncode(contactData),
  );

  if (response.statusCode != 200) {
    throw Exception('Failed to update contact: ${response.statusCode}');
  }
}