PushMessage.swift 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // LoopFollow
  2. // PushMessage.swift
  3. import Foundation
  4. struct EncryptedPushMessage: Encodable {
  5. let aps: [String: Int] = ["content-available": 1]
  6. let encryptedData: String
  7. enum CodingKeys: String, CodingKey {
  8. case aps
  9. case encryptedData = "encrypted_data"
  10. }
  11. }
  12. struct CommandPayload: Encodable {
  13. var user: String
  14. var commandType: TRCCommandType
  15. var timestamp: TimeInterval
  16. var bolusAmount: Decimal?
  17. var target: Int?
  18. var duration: Int?
  19. var carbs: Int?
  20. var protein: Int?
  21. var fat: Int?
  22. var overrideName: String?
  23. var scheduledTime: TimeInterval?
  24. var returnNotification: ReturnNotificationInfo?
  25. struct ReturnNotificationInfo: Encodable {
  26. let productionEnvironment: Bool
  27. let deviceToken: String
  28. let bundleId: String
  29. let teamId: String
  30. let keyId: String
  31. let apnsKey: String
  32. enum CodingKeys: String, CodingKey {
  33. case productionEnvironment = "production_environment"
  34. case deviceToken = "device_token"
  35. case bundleId = "bundle_id"
  36. case teamId = "team_id"
  37. case keyId = "key_id"
  38. case apnsKey = "apns_key"
  39. }
  40. }
  41. enum CodingKeys: String, CodingKey {
  42. case user
  43. case commandType = "command_type"
  44. case timestamp
  45. case bolusAmount = "bolus_amount"
  46. case target
  47. case duration
  48. case carbs
  49. case protein
  50. case fat
  51. case overrideName
  52. case scheduledTime = "scheduled_time"
  53. case returnNotification = "return_notification"
  54. }
  55. }