// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
import Foundation
import azureSwiftRuntime
internal struct MabFileFolderProtectedItemExtendedInfoData : MabFileFolderProtectedItemExtendedInfoProtocol {
    public var lastRefreshedAt: Date?
    public var oldestRecoveryPoint: Date?
    public var recoveryPointCount: Int32?

        enum CodingKeys: String, CodingKey {case lastRefreshedAt = "lastRefreshedAt"
        case oldestRecoveryPoint = "oldestRecoveryPoint"
        case recoveryPointCount = "recoveryPointCount"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.lastRefreshedAt) {
        self.lastRefreshedAt = DateConverter.fromString(dateStr: (try container.decode(String?.self, forKey: .lastRefreshedAt)), format: .dateTime)
    }
    if container.contains(.oldestRecoveryPoint) {
        self.oldestRecoveryPoint = DateConverter.fromString(dateStr: (try container.decode(String?.self, forKey: .oldestRecoveryPoint)), format: .dateTime)
    }
    if container.contains(.recoveryPointCount) {
        self.recoveryPointCount = try container.decode(Int32?.self, forKey: .recoveryPointCount)
    }
    if var pageDecoder = decoder as? PageDecoder  {
      if pageDecoder.isPagedData,
        let nextLinkName = pageDecoder.nextLinkName {
          pageDecoder.nextLink = try UnknownCodingKey.decodeStringForKey(decoder: decoder, keyForDecode: nextLinkName)
      }
    }
  }

  public func encode(to encoder: Encoder) throws {
    var container = encoder.container(keyedBy: CodingKeys.self)
    if self.lastRefreshedAt != nil {
        try container.encode(DateConverter.toString(date: self.lastRefreshedAt!, format: .dateTime), forKey: .lastRefreshedAt)
    }
    if self.oldestRecoveryPoint != nil {
        try container.encode(DateConverter.toString(date: self.oldestRecoveryPoint!, format: .dateTime), forKey: .oldestRecoveryPoint)
    }
    if self.recoveryPointCount != nil {try container.encode(self.recoveryPointCount, forKey: .recoveryPointCount)}
  }
}

extension DataFactory {
  public static func createMabFileFolderProtectedItemExtendedInfoProtocol() -> MabFileFolderProtectedItemExtendedInfoProtocol {
    return MabFileFolderProtectedItemExtendedInfoData()
  }
}
