// 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 SourceControlSyncJobPropertiesData : SourceControlSyncJobPropertiesProtocol {
    public var sourceControlSyncJobId: String?
    public var creationTime: Date?
    public var provisioningState: ProvisioningStateEnum?
    public var startTime: Date?
    public var endTime: Date?
    public var startedBy: String?

        enum CodingKeys: String, CodingKey {case sourceControlSyncJobId = "sourceControlSyncJobId"
        case creationTime = "creationTime"
        case provisioningState = "provisioningState"
        case startTime = "startTime"
        case endTime = "endTime"
        case startedBy = "startedBy"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.sourceControlSyncJobId) {
        self.sourceControlSyncJobId = try container.decode(String?.self, forKey: .sourceControlSyncJobId)
    }
    if container.contains(.creationTime) {
        self.creationTime = DateConverter.fromString(dateStr: (try container.decode(String?.self, forKey: .creationTime)), format: .dateTime)
    }
    if container.contains(.provisioningState) {
        self.provisioningState = try container.decode(ProvisioningStateEnum?.self, forKey: .provisioningState)
    }
    if container.contains(.startTime) {
        self.startTime = DateConverter.fromString(dateStr: (try container.decode(String?.self, forKey: .startTime)), format: .dateTime)
    }
    if container.contains(.endTime) {
        self.endTime = DateConverter.fromString(dateStr: (try container.decode(String?.self, forKey: .endTime)), format: .dateTime)
    }
    if container.contains(.startedBy) {
        self.startedBy = try container.decode(String?.self, forKey: .startedBy)
    }
    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.sourceControlSyncJobId != nil {try container.encode(self.sourceControlSyncJobId, forKey: .sourceControlSyncJobId)}
    if self.creationTime != nil {
        try container.encode(DateConverter.toString(date: self.creationTime!, format: .dateTime), forKey: .creationTime)
    }
    if self.provisioningState != nil {try container.encode(self.provisioningState, forKey: .provisioningState)}
    if self.startTime != nil {
        try container.encode(DateConverter.toString(date: self.startTime!, format: .dateTime), forKey: .startTime)
    }
    if self.endTime != nil {
        try container.encode(DateConverter.toString(date: self.endTime!, format: .dateTime), forKey: .endTime)
    }
    if self.startedBy != nil {try container.encode(self.startedBy, forKey: .startedBy)}
  }
}

extension DataFactory {
  public static func createSourceControlSyncJobPropertiesProtocol() -> SourceControlSyncJobPropertiesProtocol {
    return SourceControlSyncJobPropertiesData()
  }
}
