deleteRecords method
deleteRecords()
- Method DELETES New Item(s) on DNS Table
- Returns
true
if successful, false
otherwise
Required : List<DNSRecord>
Implementation
Future<bool> deleteRecords(List<DNSRecord> records) async {
// Fetch records
final data = await refresh();
// Verify Records exist
final validated = data.records.where((r) => records.any((gR) => gR.host == r.host));
// Validate Length
if (validated.length == records.length) {
// Convert Records to Map List
final List<Map<String, dynamic>> mappedRecords = records.map<Map<String, dynamic>>((e) => e.toMap()).toList();
// Build Request
var map = {'records': [], 'deleteRecords': mappedRecords};
var body = jsonEncode(map);
var resp = await put(apiUrl + apiDnsEndpoint, body, headers: authHeaders);
return resp.body != null ? resp.body["success"] : true;
}
return false;
}