RemoteDataService.swift 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. //
  2. // RemoteDataService.swift
  3. // LoopKit
  4. //
  5. // Created by Darin Krauss on 5/21/19.
  6. // Copyright © 2019 LoopKit Authors. All rights reserved.
  7. //
  8. /**
  9. Protocol for a remote data service.
  10. */
  11. public protocol RemoteDataService: Service {
  12. /// The maximum number of carb data to upload to the remote data service at one time.
  13. var carbDataLimit: Int? { get }
  14. /**
  15. Upload carb data to the remote data service.
  16. - Parameter created: The created carb data to upload.
  17. - Parameter updated: The updated carb data to upload.
  18. - Parameter deleted: The deleted carb data to upload.
  19. - Parameter completion: The completion function to call with any success or failure.
  20. */
  21. func uploadCarbData(created: [SyncCarbObject], updated: [SyncCarbObject], deleted: [SyncCarbObject], completion: @escaping (_ result: Result<Bool, Error>) -> Void)
  22. /// The maximum number of dose data to upload to the remote data service at one time.
  23. var doseDataLimit: Int? { get }
  24. /**
  25. Upload dose data to the remote data service.
  26. - Parameter stored: The stored dose data to upload.
  27. - Parameter completion: The completion function to call with any success or failure.
  28. */
  29. func uploadDoseData(_ stored: [DoseEntry], completion: @escaping (_ result: Result<Bool, Error>) -> Void)
  30. /// The maximum number of dosing decision data to upload to the remote data service at one time.
  31. var dosingDecisionDataLimit: Int? { get }
  32. /**
  33. Upload dosing decision data to the remote data service.
  34. - Parameter stored: The stored dosing decision data to upload.
  35. - Parameter completion: The completion function to call with any success or failure.
  36. */
  37. func uploadDosingDecisionData(_ stored: [StoredDosingDecision], completion: @escaping (_ result: Result<Bool, Error>) -> Void)
  38. /// The maximum number of glucose data to upload to the remote data service at one time.
  39. var glucoseDataLimit: Int? { get }
  40. /**
  41. Upload glucose data to the remote data service.
  42. - Parameter stored: The stored glucose data to upload.
  43. - Parameter completion: The completion function to call with any success or failure.
  44. */
  45. func uploadGlucoseData(_ stored: [StoredGlucoseSample], completion: @escaping (_ result: Result<Bool, Error>) -> Void)
  46. /// The maximum number of pump event data to upload to the remote data service at one time.
  47. var pumpEventDataLimit: Int? { get }
  48. /**
  49. Upload pump event data to the remote data service.
  50. - Parameter stored: The stored pump event data to upload.
  51. - Parameter completion: The completion function to call with any success or failure.
  52. */
  53. func uploadPumpEventData(_ stored: [PersistedPumpEvent], completion: @escaping (_ result: Result<Bool, Error>) -> Void)
  54. /// The maximum number of settings data to upload to the remote data service at one time.
  55. var settingsDataLimit: Int? { get }
  56. /**
  57. Upload settings data to the remote data service.
  58. - Parameter stored: The stored settings data to upload.
  59. - Parameter completion: The completion function to call with any success or failure.
  60. */
  61. func uploadSettingsData(_ stored: [StoredSettings], completion: @escaping (_ result: Result<Bool, Error>) -> Void)
  62. }
  63. public extension RemoteDataService {
  64. var carbDataLimit: Int? { return nil }
  65. func uploadCarbData(created: [SyncCarbObject], updated: [SyncCarbObject], deleted: [SyncCarbObject], completion: @escaping (_ result: Result<Bool, Error>) -> Void) {
  66. completion(.success(false))
  67. }
  68. var doseDataLimit: Int? { return nil }
  69. func uploadDoseData(_ stored: [DoseEntry], completion: @escaping (_ result: Result<Bool, Error>) -> Void) {
  70. completion(.success(false))
  71. }
  72. var dosingDecisionDataLimit: Int? { return nil }
  73. func uploadDosingDecisionData(_ stored: [StoredDosingDecision], completion: @escaping (_ result: Result<Bool, Error>) -> Void) {
  74. completion(.success(false))
  75. }
  76. var glucoseDataLimit: Int? { return nil }
  77. func uploadGlucoseData(_ stored: [StoredGlucoseSample], completion: @escaping (_ result: Result<Bool, Error>) -> Void) {
  78. completion(.success(false))
  79. }
  80. var pumpEventDataLimit: Int? { return nil }
  81. func uploadPumpEventData(_ stored: [PersistedPumpEvent], completion: @escaping (_ result: Result<Bool, Error>) -> Void) {
  82. completion(.success(false))
  83. }
  84. var settingsDataLimit: Int? { return nil }
  85. func uploadSettingsData(_ stored: [StoredSettings], completion: @escaping (_ result: Result<Bool, Error>) -> Void) {
  86. completion(.success(false))
  87. }
  88. }