//
//  ZoneAPI.swift
//  CloudKit Download
//
//  Created by Andreas Reuter on 23.08.21.
//

import CloudKit

class ZoneAPI {
  func loadItems(containerIdentifier: String, database: Database, completion: @escaping ([CKRecordZone]?, Error?) -> Void) {
    let cloudKitDatabase = CloudKitAdapter(
      containerIdentifier: containerIdentifier,
      database: database
    )
    .instance()

    cloudKitDatabase.fetchAllRecordZones { records, error in
      DispatchQueue.main.async {
        completion(records, error)
      }
    }
  }
}
