jellyfin-sdk-swift/Sources/Paths/GetItemImageByIndexAPI.swift

99 lines
3.4 KiB
Swift
Raw Permalink Normal View History

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/.
//
2024-02-19 03:34:53 +00:00
// Copyright (c) 2024 Jellyfin & Jellyfin Contributors
2022-08-08 20:29:07 +00:00
//
2022-08-08 20:21:06 +00:00
import Foundation
import Get
import URLQueryEncoder
2022-08-17 21:08:41 +00:00
public extension Paths {
2022-08-08 20:21:06 +00:00
/// Gets the item's image.
2022-08-17 21:08:41 +00:00
static func getItemImageByIndex(
itemID: String,
imageType: String,
imageIndex: Int,
parameters: GetItemImageByIndexParameters? = nil
) -> Request<Data> {
Request(
2023-08-30 22:09:52 +00:00
path: "/Items/\(itemID)/Images/\(imageType)/\(imageIndex)",
2022-08-17 21:08:41 +00:00
method: "GET",
query: parameters?.asQuery,
id: "GetItemImageByIndex"
)
2022-08-08 20:21:06 +00:00
}
2022-08-17 21:08:41 +00:00
struct GetItemImageByIndexParameters {
public var maxWidth: Int?
public var maxHeight: Int?
public var width: Int?
public var height: Int?
public var quality: Int?
public var fillWidth: Int?
public var fillHeight: Int?
2022-08-08 20:21:06 +00:00
public var tag: String?
public var format: Format?
public var percentPlayed: Double?
public var unplayedCount: Int?
public var blur: Int?
2022-08-08 20:21:06 +00:00
public var backgroundColor: String?
public var foregroundLayer: String?
public typealias Format = JellyfinAPI.ImageFormat
2022-08-17 21:08:41 +00:00
public init(
maxWidth: Int? = nil,
maxHeight: Int? = nil,
width: Int? = nil,
height: Int? = nil,
quality: Int? = nil,
fillWidth: Int? = nil,
fillHeight: Int? = nil,
2022-08-17 21:08:41 +00:00
tag: String? = nil,
format: Format? = nil,
percentPlayed: Double? = nil,
unplayedCount: Int? = nil,
blur: Int? = nil,
2022-08-17 21:08:41 +00:00
backgroundColor: String? = nil,
foregroundLayer: String? = nil
) {
2022-08-08 20:21:06 +00:00
self.maxWidth = maxWidth
self.maxHeight = maxHeight
self.width = width
self.height = height
self.quality = quality
self.fillWidth = fillWidth
self.fillHeight = fillHeight
self.tag = tag
self.format = format
self.percentPlayed = percentPlayed
self.unplayedCount = unplayedCount
self.blur = blur
self.backgroundColor = backgroundColor
self.foregroundLayer = foregroundLayer
}
public var asQuery: [(String, String?)] {
let encoder = URLQueryEncoder()
encoder.encode(maxWidth, forKey: "maxWidth")
encoder.encode(maxHeight, forKey: "maxHeight")
encoder.encode(width, forKey: "width")
encoder.encode(height, forKey: "height")
encoder.encode(quality, forKey: "quality")
encoder.encode(fillWidth, forKey: "fillWidth")
encoder.encode(fillHeight, forKey: "fillHeight")
encoder.encode(tag, forKey: "tag")
encoder.encode(format, forKey: "format")
encoder.encode(percentPlayed, forKey: "percentPlayed")
encoder.encode(unplayedCount, forKey: "unplayedCount")
encoder.encode(blur, forKey: "blur")
encoder.encode(backgroundColor, forKey: "backgroundColor")
encoder.encode(foregroundLayer, forKey: "foregroundLayer")
return encoder.items
}
}
}