update method

Future<ApiResponseModel<GroupModel?>> update({
  1. required String id,
  2. required String name,
  3. required List<ContactModel> contacts,
})

Updates a group in the group list.

id is the ID of the group to update. name is the new name of the group. description is the new description of the group. Returns a GroupModel instance if successful, or null if there's an error.

Implementation

Future<ApiResponseModel<GroupModel?>> update({
  required String id,
  required String name,
  required List<ContactModel> contacts,
}) async {
  final url = "$_baseUrl/group/$id/update";

  final payload = {
    'id': id,
    'name': name,
    'contacts': contacts.map((e) => e.toJson()).toList(),
  };

  debugPrint("flutter_mon_sms_pro/group/update/payload: $payload");

  final r = await _dio.post(url, data: {
    ...payload,
    "apiKey": _apiKey,
  });

  debugPrint("flutter_mon_sms_pro/group/update/data: ${r.data}");

  final response = ApiResponseModel.fromJson(
      r.data, (data) => GroupModel.fromJson(data as Map<String, dynamic>));

  return response;
}