updateLocation method

Future<Location> updateLocation(
  1. String locationId, {
  2. String? name,
  3. String? code,
  4. String? description,
  5. String? type,
  6. String? status,
  7. String? parentId,
  8. Address? address,
  9. ContactInfo? contactInfo,
  10. Map<String, dynamic>? metadata,
})

Update location

Implementation

Future<Location> updateLocation(
  String locationId, {
  String? name,
  String? code,
  String? description,
  String? type,
  String? status,
  String? parentId,
  Address? address,
  ContactInfo? contactInfo,
  Map<String, dynamic>? metadata,
}) async {
  final data = <String, dynamic>{};
  if (name != null) data['name'] = name;
  if (code != null) data['code'] = code;
  if (description != null) data['description'] = description;
  if (type != null) data['type'] = type;
  if (status != null) data['status'] = status;
  if (parentId != null) data['parentId'] = parentId;
  if (address != null) data['address'] = address.toJson();
  if (contactInfo != null) data['contactInfo'] = contactInfo.toJson();
  if (metadata != null) data['metadata'] = metadata;

  final response = await _apiClient.put<Map<String, dynamic>>(
    '/api/v1/locations/$locationId',
    data: data,
  );

  final responseData = response['data'] as Map<String, dynamic>;
  return Location.fromJson(responseData);
}