// 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 ArtifactPropertiesData : ArtifactPropertiesProtocol {
    public var title: String?
    public var description: String?
    public var publisher: String?
    public var filePath: String?
    public var icon: String?
    public var targetOsType: String?
    public var parameters: [String: String?]?
    public var createdDate: Date?

        enum CodingKeys: String, CodingKey {case title = "title"
        case description = "description"
        case publisher = "publisher"
        case filePath = "filePath"
        case icon = "icon"
        case targetOsType = "targetOsType"
        case parameters = "parameters"
        case createdDate = "createdDate"
        }

  public init()  {
  }

  public init(from decoder: Decoder) throws {
    let container = try decoder.container(keyedBy: CodingKeys.self)
      if container.contains(.title) {
        self.title = try container.decode(String?.self, forKey: .title)
    }
    if container.contains(.description) {
        self.description = try container.decode(String?.self, forKey: .description)
    }
    if container.contains(.publisher) {
        self.publisher = try container.decode(String?.self, forKey: .publisher)
    }
    if container.contains(.filePath) {
        self.filePath = try container.decode(String?.self, forKey: .filePath)
    }
    if container.contains(.icon) {
        self.icon = try container.decode(String?.self, forKey: .icon)
    }
    if container.contains(.targetOsType) {
        self.targetOsType = try container.decode(String?.self, forKey: .targetOsType)
    }
    if container.contains(.parameters) {
        self.parameters = try container.decode([String: String?]?.self, forKey: .parameters)
    }
    if container.contains(.createdDate) {
        self.createdDate = DateConverter.fromString(dateStr: (try container.decode(String?.self, forKey: .createdDate)), format: .dateTime)
    }
    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.title != nil {try container.encode(self.title, forKey: .title)}
    if self.description != nil {try container.encode(self.description, forKey: .description)}
    if self.publisher != nil {try container.encode(self.publisher, forKey: .publisher)}
    if self.filePath != nil {try container.encode(self.filePath, forKey: .filePath)}
    if self.icon != nil {try container.encode(self.icon, forKey: .icon)}
    if self.targetOsType != nil {try container.encode(self.targetOsType, forKey: .targetOsType)}
    if self.parameters != nil {try container.encode(self.parameters, forKey: .parameters)}
    if self.createdDate != nil {
        try container.encode(DateConverter.toString(date: self.createdDate!, format: .dateTime), forKey: .createdDate)
    }
  }
}

extension DataFactory {
  public static func createArtifactPropertiesProtocol() -> ArtifactPropertiesProtocol {
    return ArtifactPropertiesData()
  }
}
