PushMessage.swift 1.6 KB

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