2022-08-08 20:29:07 +00:00
|
|
|
//
|
2022-08-16 02:37:47 +00:00
|
|
|
// jellyfin-sdk-swift is subject to the terms of the Mozilla Public
|
2022-08-08 20:29:07 +00:00
|
|
|
// License, v2.0. If a copy of the MPL was not distributed with this
|
|
|
|
// file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
//
|
|
|
|
// Copyright (c) 2022 Jellyfin & Jellyfin Contributors
|
|
|
|
//
|
2022-08-08 20:21:06 +00:00
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
public struct MessageCommand: Codable {
|
|
|
|
public var header: String?
|
|
|
|
public var text: String
|
2022-08-17 05:32:51 +00:00
|
|
|
public var timeoutMs: Int64?
|
2022-08-08 20:21:06 +00:00
|
|
|
|
2022-08-17 05:32:51 +00:00
|
|
|
public init(header: String? = nil, text: String, timeoutMs: Int64? = nil) {
|
2022-08-08 20:21:06 +00:00
|
|
|
self.header = header
|
|
|
|
self.text = text
|
|
|
|
self.timeoutMs = timeoutMs
|
|
|
|
}
|
2022-08-17 05:47:00 +00:00
|
|
|
|
|
|
|
public init(from decoder: Decoder) throws {
|
|
|
|
let values = try decoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
self.header = try values.decodeIfPresent(String.self, forKey: "Header")
|
|
|
|
self.text = try values.decode(String.self, forKey: "Text")
|
|
|
|
self.timeoutMs = try values.decodeIfPresent(Int64.self, forKey: "TimeoutMs")
|
|
|
|
}
|
|
|
|
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
|
|
var values = encoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
try values.encodeIfPresent(header, forKey: "Header")
|
|
|
|
try values.encode(text, forKey: "Text")
|
|
|
|
try values.encodeIfPresent(timeoutMs, forKey: "TimeoutMs")
|
|
|
|
}
|
2022-08-08 20:21:06 +00:00
|
|
|
}
|