CarbsEntry+LoopKit.swift 948 B

123456789101112131415161718192021222324252627282930
  1. import Foundation
  2. import LoopKit
  3. // LoopKit adapter for `CarbsEntry`.
  4. //
  5. // Kept out of `CarbsEntry.swift` so that the model itself stays Foundation-only and can be
  6. // compiled by the algorithm package (see `AlgorithmPackage/Package.swift`). Consumed by
  7. // `TidepoolManager`.
  8. extension CarbsEntry {
  9. func convertSyncCarb(operation: LoopKit.Operation = .create) -> SyncCarbObject {
  10. SyncCarbObject(
  11. absorptionTime: nil,
  12. createdByCurrentApp: true,
  13. foodType: nil,
  14. grams: Double(carbs),
  15. startDate: createdAt,
  16. uuid: UUID(uuidString: id!),
  17. provenanceIdentifier: enteredBy ?? "Trio",
  18. syncIdentifier: id,
  19. syncVersion: nil,
  20. userCreatedDate: nil,
  21. userUpdatedDate: nil,
  22. userDeletedDate: nil,
  23. operation: operation,
  24. addedDate: nil,
  25. supercededDate: nil
  26. )
  27. }
  28. }