createLocation method
Create new location
Implementation
Future<Location> createLocation({
required String name,
required String code,
String? description,
String? type,
String? parentId,
Address? address,
ContactInfo? contactInfo,
Map<String, dynamic>? metadata,
}) async {
final response = await _apiClient.post<Map<String, dynamic>>(
'/api/v1/locations',
data: {
'name': name,
'code': code,
if (description != null) 'description': description,
if (type != null) 'type': type,
if (parentId != null) 'parentId': parentId,
if (address != null) 'address': address.toJson(),
if (contactInfo != null) 'contactInfo': contactInfo.toJson(),
if (metadata != null) 'metadata': metadata,
},
);
final data = response['data'] as Map<String, dynamic>;
return Location.fromJson(data);
}