diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 01b70ee..c1bd5e9 100755 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 5d77204e-e413-4fd0-a14a-bad3aee2247a management: - docChecksum: 911d74baa0d06121d2ce2c71d94e977a + docChecksum: 37654ea0982ab5e87a9a9576014c9d19 docVersion: 0.0.3 - speakeasyVersion: 1.299.6 - generationVersion: 2.338.12 - releaseVersion: 0.3.1 - configChecksum: 118251f8f3f1b3c85b9dc10712fa7a5f + speakeasyVersion: 1.308.1 + generationVersion: 2.342.6 + releaseVersion: 0.4.0 + configChecksum: 13dc4c5ae6371accdb7e2797a7681034 repoURL: https://github.com/LukeHagar/plexswift.git features: swift: @@ -16,22 +16,24 @@ features: globals: 2.81.3 methodServerURLs: 3.0.1 nameOverrides: 2.81.2 + typeOverrides: 2.81.1 generatedFiles: - Sources/Plexswift/internal/api/_ServerAPI.swift - Sources/Plexswift/internal/api/_MediaAPI.swift - Sources/Plexswift/internal/api/_VideoAPI.swift - Sources/Plexswift/internal/api/_ActivitiesAPI.swift - Sources/Plexswift/internal/api/_ButlerAPI.swift + - Sources/Plexswift/internal/api/_PlexAPI.swift - Sources/Plexswift/internal/api/_HubsAPI.swift - Sources/Plexswift/internal/api/_SearchAPI.swift - Sources/Plexswift/internal/api/_LibraryAPI.swift - Sources/Plexswift/internal/api/_LogAPI.swift - - Sources/Plexswift/internal/api/_PlexAPI.swift - Sources/Plexswift/internal/api/_PlaylistsAPI.swift - Sources/Plexswift/internal/api/_AuthenticationAPI.swift - Sources/Plexswift/internal/api/_StatisticsAPI.swift - Sources/Plexswift/internal/api/_SessionsAPI.swift - Sources/Plexswift/internal/api/_UpdaterAPI.swift + - Sources/Plexswift/internal/api/_WatchlistAPI.swift - Sources/Plexswift/configuration/GlobalServer.swift - Sources/Plexswift/configuration/GlobalParameters.swift - Sources/Plexswift/Client.swift @@ -120,6 +122,7 @@ generatedFiles: - Sources/Plexswift/models/operations/Field.swift - Sources/Plexswift/models/operations/FieldType.swift - Sources/Plexswift/models/operations/Filter.swift + - Sources/Plexswift/internal/models/Filter+Serialization.swift - Sources/Plexswift/models/operations/Force.swift - Sources/Plexswift/internal/models/Force+Serialization.swift - Sources/Plexswift/models/operations/Genre.swift @@ -150,6 +153,10 @@ generatedFiles: - Sources/Plexswift/internal/models/GetGlobalHubsRequest+Serialization.swift - Sources/Plexswift/models/operations/GetGlobalHubsResponse.swift - Sources/Plexswift/models/operations/GetGlobalHubsResponseBody.swift + - Sources/Plexswift/models/operations/GetHomeDataErrors.swift + - Sources/Plexswift/models/operations/GetHomeDataPlexResponseBody.swift + - Sources/Plexswift/models/operations/GetHomeDataResponse.swift + - Sources/Plexswift/models/operations/GetHomeDataResponseBody.swift - Sources/Plexswift/models/operations/GetLibrariesDirectory.swift - Sources/Plexswift/models/operations/GetLibrariesErrors.swift - Sources/Plexswift/models/operations/GetLibrariesLibraryResponseBody.swift @@ -159,6 +166,7 @@ generatedFiles: - Sources/Plexswift/models/operations/GetLibrariesResponseBody.swift - Sources/Plexswift/models/operations/GetLibraryDirectory.swift - Sources/Plexswift/models/operations/GetLibraryErrors.swift + - Sources/Plexswift/models/operations/GetLibraryFilter.swift - Sources/Plexswift/models/operations/GetLibraryHubsCountry.swift - Sources/Plexswift/models/operations/GetLibraryHubsDirector.swift - Sources/Plexswift/models/operations/GetLibraryHubsErrors.swift @@ -275,6 +283,7 @@ generatedFiles: - Sources/Plexswift/models/operations/GetRecentlyAddedErrors.swift - Sources/Plexswift/models/operations/GetRecentlyAddedLibraryResponseBody.swift - Sources/Plexswift/models/operations/GetRecentlyAddedMediaContainer.swift + - Sources/Plexswift/models/operations/GetRecentlyAddedMetadata.swift - Sources/Plexswift/models/operations/GetRecentlyAddedResponse.swift - Sources/Plexswift/models/operations/GetRecentlyAddedResponseBody.swift - Sources/Plexswift/models/operations/GetResizedPhotoErrors.swift @@ -355,6 +364,8 @@ generatedFiles: - Sources/Plexswift/models/operations/GetTimelineResponse.swift - Sources/Plexswift/models/operations/GetTimelineResponseBody.swift - Sources/Plexswift/models/operations/GetTokenErrors.swift + - Sources/Plexswift/models/operations/GetTokenLocation.swift + - Sources/Plexswift/models/operations/GetTokenPlexResponseBody.swift - Sources/Plexswift/models/operations/GetTokenRequest.swift - Sources/Plexswift/internal/models/GetTokenRequest+Serialization.swift - Sources/Plexswift/models/operations/GetTokenResponse.swift @@ -376,12 +387,25 @@ generatedFiles: - Sources/Plexswift/models/operations/GetUpdateStatusResponse.swift - Sources/Plexswift/models/operations/GetUpdateStatusResponseBody.swift - Sources/Plexswift/models/operations/GetUpdateStatusUpdaterResponseBody.swift + - Sources/Plexswift/models/operations/GetWatchlistErrors.swift + - Sources/Plexswift/models/operations/GetWatchlistRequest.swift + - Sources/Plexswift/internal/models/GetWatchlistRequest+Serialization.swift + - Sources/Plexswift/models/operations/GetWatchlistResponse.swift + - Sources/Plexswift/models/operations/GetWatchlistResponseBody.swift + - Sources/Plexswift/models/operations/GetWatchlistWatchlistResponseBody.swift - Sources/Plexswift/models/operations/Guids.swift - Sources/Plexswift/models/operations/Hub.swift + - Sources/Plexswift/models/operations/Image.swift + - Sources/Plexswift/models/operations/IncludeCollections.swift + - Sources/Plexswift/internal/models/IncludeCollections+Serialization.swift - Sources/Plexswift/models/operations/IncludeDetails.swift - Sources/Plexswift/internal/models/IncludeDetails+Serialization.swift + - Sources/Plexswift/models/operations/IncludeExternalMedia.swift + - Sources/Plexswift/internal/models/IncludeExternalMedia+Serialization.swift - Sources/Plexswift/models/operations/Level.swift - Sources/Plexswift/internal/models/Level+Serialization.swift + - Sources/Plexswift/models/operations/Libtype.swift + - Sources/Plexswift/internal/models/Libtype+Serialization.swift - Sources/Plexswift/models/operations/Location.swift - Sources/Plexswift/models/operations/LogLineErrors.swift - Sources/Plexswift/models/operations/LogLineRequest.swift diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 26a1966..fde90a4 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: true swift: - version: 0.3.1 + version: 0.4.0 author: LukeHagar description: Swift Client SDK Generated by Speakeasy imports: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index afc25a0..846dfb8 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -2,8 +2,8 @@ speakeasyVersion: 1.308.0 sources: my-source: sourceNamespace: my-source - sourceRevisionDigest: sha256:8a55e4d358b370c539223f7ca9d8ee71aac82295ae3df605a54e9c25ff3dbd35 - sourceBlobDigest: sha256:5b8d105e28a64fda9bf9e366db182a47097880bd8f309fbada44fbc0bd745bbb + sourceRevisionDigest: sha256:5624db047dbcbdea446c5bfd39647c4eeff845353f814d00a01f5591a4667a38 + sourceBlobDigest: sha256:853e4c9838e000baff90393829ccf8e6bafd9a6e6017368e04fa33f174ba0904 tags: - latest - main @@ -11,8 +11,8 @@ targets: plexswift: source: my-source sourceNamespace: my-source - sourceRevisionDigest: sha256:8a55e4d358b370c539223f7ca9d8ee71aac82295ae3df605a54e9c25ff3dbd35 - sourceBlobDigest: sha256:5b8d105e28a64fda9bf9e366db182a47097880bd8f309fbada44fbc0bd745bbb + sourceRevisionDigest: sha256:5624db047dbcbdea446c5bfd39647c4eeff845353f814d00a01f5591a4667a38 + sourceBlobDigest: sha256:853e4c9838e000baff90393829ccf8e6bafd9a6e6017368e04fa33f174ba0904 outLocation: /github/workspace/repo workflow: workflowVersion: 1.0.0 diff --git a/README.md b/README.md index 98217cb..f4aa817 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ You can add `plexswift` to your project directly in Xcode `(File > Add Packages. ```bash dependencies: [ - .package(url: "https://github.com/LukeHagar/plexswift.git", .upToNextMajor(from: "0.3.1")) + .package(url: "https://github.com/LukeHagar/plexswift.git", .upToNextMajor(from: "0.4.0")) ] ``` @@ -127,12 +127,13 @@ let client = Client() let response = try await client.plex.getPin( request: Operations.GetPinRequest( + xPlexProduct: "Postman", strong: false, ) ) switch response.data { -case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): +case .twoHundredAndOneApplicationJsonObject(let twoHundredAndOneApplicationJsonObject): // Handle response break case .fourHundredApplicationJsonObject(let fourHundredApplicationJsonObject): diff --git a/RELEASES.md b/RELEASES.md index 069be48..e7d5265 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -462,4 +462,14 @@ Based on: ### Generated - [swift v0.3.1] . ### Releases -- [Swift Package Manager v0.3.1] https://github.com/LukeHagar/plexswift/releases/tag/v0.3.1 - . \ No newline at end of file +- [Swift Package Manager v0.3.1] https://github.com/LukeHagar/plexswift/releases/tag/v0.3.1 - . + +## 2024-06-15 00:13:24 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.308.1 (2.342.6) https://github.com/speakeasy-api/speakeasy +### Generated +- [swift v0.4.0] . +### Releases +- [Swift Package Manager v0.4.0] https://github.com/LukeHagar/plexswift/releases/tag/v0.4.0 - . \ No newline at end of file diff --git a/Sources/Plexswift/Client.swift b/Sources/Plexswift/Client.swift index a7e13e1..380f9b0 100644 --- a/Sources/Plexswift/Client.swift +++ b/Sources/Plexswift/Client.swift @@ -66,16 +66,17 @@ import FoundationNetworking /// - ``video`` /// - ``activities`` /// - ``butler`` +/// - ``plex`` /// - ``hubs`` /// - ``search`` /// - ``library`` /// - ``log`` -/// - ``plex`` /// - ``playlists`` /// - ``authentication`` /// - ``statistics`` /// - ``sessions`` /// - ``updater`` +/// - ``watchlist`` /// public final class Client { internal struct APIResponse { diff --git a/Sources/Plexswift/Plexswift.docc/Plexswift.md b/Sources/Plexswift/Plexswift.docc/Plexswift.md index 9513299..08dc55f 100644 --- a/Sources/Plexswift/Plexswift.docc/Plexswift.md +++ b/Sources/Plexswift/Plexswift.docc/Plexswift.md @@ -56,20 +56,22 @@ case .empty: - ``VideoAPI`` - ``ActivitiesAPI`` - ``ButlerAPI`` +- ``PlexAPI`` - ``HubsAPI`` - ``SearchAPI`` - ``LibraryAPI`` - ``LogAPI`` -- ``PlexAPI`` - ``PlaylistsAPI`` - ``AuthenticationAPI`` - ``StatisticsAPI`` - ``SessionsAPI`` - ``UpdaterAPI`` +- ``WatchlistAPI`` ### Server configuration - ``PlexServers/GetPin`` - ``PlexServers/GetToken`` +- ``WatchlistServers/GetWatchlist`` ### Shared models @@ -90,6 +92,7 @@ case .empty: - ``Operations/GetDevicesResponse`` - ``Operations/GetFileHashResponse`` - ``Operations/GetGlobalHubsResponse`` +- ``Operations/GetHomeDataResponse`` - ``Operations/GetLibrariesResponse`` - ``Operations/GetLibraryResponse`` - ``Operations/GetLibraryHubsResponse`` @@ -119,6 +122,7 @@ case .empty: - ``Operations/GetTranscodeSessionsResponse`` - ``Operations/GetTransientTokenResponse`` - ``Operations/GetUpdateStatusResponse`` +- ``Operations/GetWatchlistResponse`` - ``Operations/LogLineResponse`` - ``Operations/LogMultiLineResponse`` - ``Operations/MarkPlayedResponse`` @@ -206,6 +210,9 @@ case .empty: - ``Operations/GetGlobalHubsMetadata`` - ``Operations/GetGlobalHubsRequest`` - ``Operations/GetGlobalHubsResponseBody`` +- ``Operations/GetHomeDataErrors`` +- ``Operations/GetHomeDataPlexResponseBody`` +- ``Operations/GetHomeDataResponseBody`` - ``Operations/GetLibrariesDirectory`` - ``Operations/GetLibrariesErrors`` - ``Operations/GetLibrariesLibraryResponseBody`` @@ -214,6 +221,7 @@ case .empty: - ``Operations/GetLibrariesResponseBody`` - ``Operations/GetLibraryDirectory`` - ``Operations/GetLibraryErrors`` +- ``Operations/GetLibraryFilter`` - ``Operations/GetLibraryLibraryResponseBody`` - ``Operations/GetLibraryMediaContainer`` - ``Operations/GetLibraryRequest`` @@ -310,6 +318,7 @@ case .empty: - ``Operations/GetRecentlyAddedErrors`` - ``Operations/GetRecentlyAddedLibraryResponseBody`` - ``Operations/GetRecentlyAddedMediaContainer`` +- ``Operations/GetRecentlyAddedMetadata`` - ``Operations/GetRecentlyAddedResponseBody`` - ``Operations/GetResizedPhotoErrors`` - ``Operations/GetResizedPhotoRequest`` @@ -372,6 +381,8 @@ case .empty: - ``Operations/GetTimelineRequest`` - ``Operations/GetTimelineResponseBody`` - ``Operations/GetTokenErrors`` +- ``Operations/GetTokenLocation`` +- ``Operations/GetTokenPlexResponseBody`` - ``Operations/GetTokenRequest`` - ``Operations/GetTokenResponseBody`` - ``Operations/GetTranscodeSessionsErrors`` @@ -386,10 +397,18 @@ case .empty: - ``Operations/GetUpdateStatusMediaContainer`` - ``Operations/GetUpdateStatusResponseBody`` - ``Operations/GetUpdateStatusUpdaterResponseBody`` +- ``Operations/GetWatchlistErrors`` +- ``Operations/GetWatchlistRequest`` +- ``Operations/GetWatchlistResponseBody`` +- ``Operations/GetWatchlistWatchlistResponseBody`` - ``Operations/Guids`` - ``Operations/Hub`` +- ``Operations/Image`` +- ``Operations/IncludeCollections`` - ``Operations/IncludeDetails`` +- ``Operations/IncludeExternalMedia`` - ``Operations/Level`` +- ``Operations/Libtype`` - ``Operations/Location`` - ``Operations/LogLineErrors`` - ``Operations/LogLineRequest`` diff --git a/Sources/Plexswift/internal/api/_PlexAPI.swift b/Sources/Plexswift/internal/api/_PlexAPI.swift index 9006a79..2de559a 100644 --- a/Sources/Plexswift/internal/api/_PlexAPI.swift +++ b/Sources/Plexswift/internal/api/_PlexAPI.swift @@ -10,6 +10,15 @@ class _PlexAPI: PlexAPI { self.client = client } + public func getHomeData() async throws -> Response { + return try await client.makeRequest( + configureRequest: { configuration in + try configureGetHomeDataRequest(with: configuration) + }, + handleResponse: handleGetHomeDataResponse + ) + } + public func getPin(request: Operations.GetPinRequest, server: PlexServers.GetPin?) async throws -> Response { return try await client.makeRequest( with: try server?.server() ?? PlexServers.GetPin.default(), @@ -34,6 +43,12 @@ class _PlexAPI: PlexAPI { // MARK: - Request Configuration +private func configureGetHomeDataRequest(with configuration: URLRequestConfiguration) throws { + configuration.path = "/home" + configuration.method = .get + configuration.telemetryHeader = .userAgent +} + private func configureGetPinRequest(with configuration: URLRequestConfiguration, request: Operations.GetPinRequest) throws { configuration.path = "/pins" configuration.method = .post @@ -52,13 +67,39 @@ private func configureGetTokenRequest(with configuration: URLRequestConfiguratio // MARK: - Response Handlers -private func handleGetPinResponse(response: Client.APIResponse) throws -> Operations.GetPinResponse { +private func handleGetHomeDataResponse(response: Client.APIResponse) throws -> Operations.GetHomeDataResponse { let httpResponse = response.httpResponse if httpResponse.statusCode == 200 { if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data { do { - return .twoHundredApplicationJsonObject(try JSONDecoder().decode(Operations.GetPinResponseBody.self, from: data)) + return .twoHundredApplicationJsonObject(try JSONDecoder().decode(Operations.GetHomeDataResponseBody.self, from: data)) + } catch { + throw ResponseHandlerError.failedToDecodeJSON(error) + } + } + } else if httpResponse.statusCode == 400 { + return .empty + } else if httpResponse.statusCode == 401 { + if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data { + do { + return .fourHundredAndOneApplicationJsonObject(try JSONDecoder().decode(Operations.GetHomeDataPlexResponseBody.self, from: data)) + } catch { + throw ResponseHandlerError.failedToDecodeJSON(error) + } + } + } + + return .empty +} + +private func handleGetPinResponse(response: Client.APIResponse) throws -> Operations.GetPinResponse { + let httpResponse = response.httpResponse + + if httpResponse.statusCode == 201 { + if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data { + do { + return .twoHundredAndOneApplicationJsonObject(try JSONDecoder().decode(Operations.GetPinResponseBody.self, from: data)) } catch { throw ResponseHandlerError.failedToDecodeJSON(error) } @@ -80,11 +121,17 @@ private func handleGetTokenResponse(response: Client.APIResponse) throws -> Oper let httpResponse = response.httpResponse if httpResponse.statusCode == 200 { - return .empty + if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data { + do { + return .twoHundredApplicationJsonObject(try JSONDecoder().decode(Operations.GetTokenResponseBody.self, from: data)) + } catch { + throw ResponseHandlerError.failedToDecodeJSON(error) + } + } } else if httpResponse.statusCode == 400 { if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data { do { - return .object(try JSONDecoder().decode(Operations.GetTokenResponseBody.self, from: data)) + return .fourHundredApplicationJsonObject(try JSONDecoder().decode(Operations.GetTokenPlexResponseBody.self, from: data)) } catch { throw ResponseHandlerError.failedToDecodeJSON(error) } diff --git a/Sources/Plexswift/internal/api/_WatchlistAPI.swift b/Sources/Plexswift/internal/api/_WatchlistAPI.swift new file mode 100644 index 0000000..99e96aa --- /dev/null +++ b/Sources/Plexswift/internal/api/_WatchlistAPI.swift @@ -0,0 +1,62 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + + +import Foundation + +class _WatchlistAPI: WatchlistAPI { + private let client: Client + + init(client: Client) { + self.client = client + } + + public func getWatchlist(request: Operations.GetWatchlistRequest, server: WatchlistServers.GetWatchlist?) async throws -> Response { + return try await client.makeRequest( + with: try server?.server() ?? WatchlistServers.GetWatchlist.default(), + configureRequest: { configuration in + try configureGetWatchlistRequest(with: configuration, request: request) + }, + handleResponse: handleGetWatchlistResponse + ) + } + +} + +// MARK: - Request Configuration + +private func configureGetWatchlistRequest(with configuration: URLRequestConfiguration, request: Operations.GetWatchlistRequest) throws { + configuration.path = "/library/sections/watchlist/{filter}" + configuration.method = .get + configuration.pathParameterSerializable = request + configuration.queryParameterSerializable = request + configuration.telemetryHeader = .userAgent +} + +// MARK: - Response Handlers + +private func handleGetWatchlistResponse(response: Client.APIResponse) throws -> Operations.GetWatchlistResponse { + let httpResponse = response.httpResponse + + if httpResponse.statusCode == 200 { + if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data { + do { + return .twoHundredApplicationJsonObject(try JSONDecoder().decode(Operations.GetWatchlistResponseBody.self, from: data)) + } catch { + throw ResponseHandlerError.failedToDecodeJSON(error) + } + } + } else if httpResponse.statusCode == 400 { + return .empty + } else if httpResponse.statusCode == 401 { + if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data { + do { + return .fourHundredAndOneApplicationJsonObject(try JSONDecoder().decode(Operations.GetWatchlistWatchlistResponseBody.self, from: data)) + } catch { + throw ResponseHandlerError.failedToDecodeJSON(error) + } + } + } + + return .empty +} + diff --git a/Sources/Plexswift/internal/models/Filter+Serialization.swift b/Sources/Plexswift/internal/models/Filter+Serialization.swift new file mode 100644 index 0000000..1cbaa9c --- /dev/null +++ b/Sources/Plexswift/internal/models/Filter+Serialization.swift @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + + +import Foundation + +extension Operations.Filter: Serializable { + func serialize(with format: SerializableFormat) throws -> String { + return try rawValue.serialize(with: format) + } + + func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] { + return [QueryParameter(key: [], serialized: try serialize(with: format))] + } +} diff --git a/Sources/Plexswift/internal/models/GetPinRequest+Serialization.swift b/Sources/Plexswift/internal/models/GetPinRequest+Serialization.swift index c9ef89d..2b44dcc 100644 --- a/Sources/Plexswift/internal/models/GetPinRequest+Serialization.swift +++ b/Sources/Plexswift/internal/models/GetPinRequest+Serialization.swift @@ -31,6 +31,7 @@ extension Operations.GetPinRequest: QueryParameterSerializable { extension Operations.GetPinRequest: HeaderParameterSerializable { func serializedHeaderParameters() throws -> [SerializedParameter] { return [ + SerializedParameter(name: "X-Plex-Product", serialized: try xPlexProduct.serialize(with: .header(explode: false))), SerializedParameter(name: "X-Plex-Client-Identifier", serialized: try xPlexClientIdentifier?.serialize(with: .header(explode: false))) ] } diff --git a/Sources/Plexswift/internal/models/GetWatchlistRequest+Serialization.swift b/Sources/Plexswift/internal/models/GetWatchlistRequest+Serialization.swift new file mode 100644 index 0000000..56591b0 --- /dev/null +++ b/Sources/Plexswift/internal/models/GetWatchlistRequest+Serialization.swift @@ -0,0 +1,44 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + + +import Foundation + +extension Operations.GetWatchlistRequest: Serializable { + func serialize(with format: SerializableFormat) throws -> String { + switch format { + case .path: + return try serializePathParameterSerializable(self, with: format) + case .query: + return try serializeQueryParameterSerializable(self, with: format) + case .header, .multipart, .form: + throw SerializationError.invalidSerializationParameter(type: "Operations.GetWatchlistRequest", format: format.formatDescription) + } + } + + func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] { + return try serializedQueryParameters(with: nil, formatOverride: format) + } +} + +extension Operations.GetWatchlistRequest: PathParameterSerializable { + func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] { + return [ + "filter": try filter.serialize(with: formatOverride ?? .path(explode: false)), + ].compactMapValues { $0 } + } +} + +extension Operations.GetWatchlistRequest: QueryParameterSerializable { + func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] { + let builder = QueryParameterBuilder() + try builder.addQueryParameters(from: xPlexToken, named: "X-Plex-Token", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + try builder.addQueryParameters(from: includeCollections, named: "includeCollections", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + try builder.addQueryParameters(from: includeExternalMedia, named: "includeExternalMedia", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + try builder.addQueryParameters(from: libtype, named: "libtype", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + try builder.addQueryParameters(from: maxresults, named: "maxresults", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + try builder.addQueryParameters(from: sort, named: "sort", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + try builder.addQueryParameters(from: xPlexContainerSize, named: "X-Plex-Container-Size", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + try builder.addQueryParameters(from: xPlexContainerStart, named: "X-Plex-Container-Start", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults) + return builder.build() + } +} diff --git a/Sources/Plexswift/internal/models/IncludeCollections+Serialization.swift b/Sources/Plexswift/internal/models/IncludeCollections+Serialization.swift new file mode 100644 index 0000000..eb56046 --- /dev/null +++ b/Sources/Plexswift/internal/models/IncludeCollections+Serialization.swift @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + + +import Foundation + +extension Operations.IncludeCollections: Serializable { + func serialize(with format: SerializableFormat) throws -> String { + return try rawValue.serialize(with: format) + } + + func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] { + return [QueryParameter(key: [], serialized: try serialize(with: format))] + } +} diff --git a/Sources/Plexswift/internal/models/IncludeExternalMedia+Serialization.swift b/Sources/Plexswift/internal/models/IncludeExternalMedia+Serialization.swift new file mode 100644 index 0000000..0787f07 --- /dev/null +++ b/Sources/Plexswift/internal/models/IncludeExternalMedia+Serialization.swift @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + + +import Foundation + +extension Operations.IncludeExternalMedia: Serializable { + func serialize(with format: SerializableFormat) throws -> String { + return try rawValue.serialize(with: format) + } + + func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] { + return [QueryParameter(key: [], serialized: try serialize(with: format))] + } +} diff --git a/Sources/Plexswift/internal/models/Libtype+Serialization.swift b/Sources/Plexswift/internal/models/Libtype+Serialization.swift new file mode 100644 index 0000000..c091faf --- /dev/null +++ b/Sources/Plexswift/internal/models/Libtype+Serialization.swift @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + + +import Foundation + +extension Operations.Libtype: Serializable { + func serialize(with format: SerializableFormat) throws -> String { + return try rawValue.serialize(with: format) + } + + func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] { + return [QueryParameter(key: [], serialized: try serialize(with: format))] + } +} diff --git a/Sources/Plexswift/models/operations/Filter.swift b/Sources/Plexswift/models/operations/Filter.swift index 2f415de..19e9f0c 100644 --- a/Sources/Plexswift/models/operations/Filter.swift +++ b/Sources/Plexswift/models/operations/Filter.swift @@ -3,34 +3,10 @@ import Foundation extension Operations { - /// A model object - public struct Filter { - public let filter: String? - public let filterType: String? - public let key: String? - public let title: String? - public let type: String? - - /// Creates an object with the specified parameters - /// - /// - public init(filter: String? = nil, filterType: String? = nil, key: String? = nil, title: String? = nil, type: String? = nil) { - self.filter = filter - self.filterType = filterType - self.key = key - self.title = title - self.type = type - } + /// Filter + public enum Filter: String, Codable, APIValue { + case all = "all" + case available = "available" + case released = "released" } } - -extension Operations.Filter: Codable { - enum CodingKeys: String, CodingKey { - case filter - case filterType - case key - case title - case type - } -} - diff --git a/Sources/Plexswift/models/operations/GetHomeDataErrors.swift b/Sources/Plexswift/models/operations/GetHomeDataErrors.swift new file mode 100644 index 0000000..ef32a63 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetHomeDataErrors.swift @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetHomeDataErrors { + @DecimalSerialized + public private(set) var code: Double? + public let message: String? + @DecimalSerialized + public private(set) var status: Double? + + /// Creates an object with the specified parameters + /// + /// + public init(code: Double? = nil, message: String? = nil, status: Double? = nil) { + self._code = DecimalSerialized(wrappedValue: code) + self.message = message + self._status = DecimalSerialized(wrappedValue: status) + } + } +} + +extension Operations.GetHomeDataErrors: Codable { + enum CodingKeys: String, CodingKey { + case code + case message + case status + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self._code = try container.decodeIfPresent(DecimalSerialized.self, forKey: .code) ?? DecimalSerialized(wrappedValue: nil) + self.message = try container.decodeIfPresent(String.self, forKey: .message) + self._status = try container.decodeIfPresent(DecimalSerialized.self, forKey: .status) ?? DecimalSerialized(wrappedValue: nil) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + if self.code != nil { + try container.encode(self._code, forKey: .code) + } + try container.encodeIfPresent(self.message, forKey: .message) + if self.status != nil { + try container.encode(self._status, forKey: .status) + } + } +} + +extension Operations.GetHomeDataErrors { + var codeWrapper: DecimalSerialized { + return _code + } + var statusWrapper: DecimalSerialized { + return _status + } +} diff --git a/Sources/Plexswift/models/operations/GetHomeDataPlexResponseBody.swift b/Sources/Plexswift/models/operations/GetHomeDataPlexResponseBody.swift new file mode 100644 index 0000000..51518bf --- /dev/null +++ b/Sources/Plexswift/models/operations/GetHomeDataPlexResponseBody.swift @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// Unauthorized - Returned if the X-Plex-Token is missing from the header or query. + public struct GetHomeDataPlexResponseBody { + public let errors: [Operations.GetHomeDataErrors]? + + /// Creates an object with the specified parameters + /// + /// + public init(errors: [Operations.GetHomeDataErrors]? = nil) { + self.errors = errors + } + } +} + +extension Operations.GetHomeDataPlexResponseBody: Codable { + enum CodingKeys: String, CodingKey { + case errors + } +} + diff --git a/Sources/Plexswift/models/operations/GetHomeDataResponse.swift b/Sources/Plexswift/models/operations/GetHomeDataResponse.swift new file mode 100644 index 0000000..304860f --- /dev/null +++ b/Sources/Plexswift/models/operations/GetHomeDataResponse.swift @@ -0,0 +1,34 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A response model + public enum GetHomeDataResponse { + case empty + case twoHundredApplicationJsonObject(Operations.GetHomeDataResponseBody) + case fourHundredAndOneApplicationJsonObject(Operations.GetHomeDataPlexResponseBody) + + var isEmpty: Bool { + if case .empty = self { + return true + } else { + return false + } + } + + public func twoHundredApplicationJsonObject() throws -> Operations.GetHomeDataResponseBody { + guard case .twoHundredApplicationJsonObject(let value) = self else { + throw PlexswiftError.missingResponseData + } + return value + } + + public func fourHundredAndOneApplicationJsonObject() throws -> Operations.GetHomeDataPlexResponseBody { + guard case .fourHundredAndOneApplicationJsonObject(let value) = self else { + throw PlexswiftError.missingResponseData + } + return value + } + } +} diff --git a/Sources/Plexswift/models/operations/GetHomeDataResponseBody.swift b/Sources/Plexswift/models/operations/GetHomeDataResponseBody.swift new file mode 100644 index 0000000..0b3df3a --- /dev/null +++ b/Sources/Plexswift/models/operations/GetHomeDataResponseBody.swift @@ -0,0 +1,73 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// Home Data + public struct GetHomeDataResponseBody { + public let guestEnabled: Bool? + @DecimalSerialized + public private(set) var guestUserID: Double? + public let guestUserUUID: String? + @DecimalSerialized + public private(set) var id: Double? + public let name: String? + public let subscription: Bool? + + /// Creates an object with the specified parameters + /// + /// + public init(guestEnabled: Bool? = nil, guestUserID: Double? = nil, guestUserUUID: String? = nil, id: Double? = nil, name: String? = nil, subscription: Bool? = nil) { + self.guestEnabled = guestEnabled + self._guestUserID = DecimalSerialized(wrappedValue: guestUserID) + self.guestUserUUID = guestUserUUID + self._id = DecimalSerialized(wrappedValue: id) + self.name = name + self.subscription = subscription + } + } +} + +extension Operations.GetHomeDataResponseBody: Codable { + enum CodingKeys: String, CodingKey { + case guestEnabled + case guestUserID + case guestUserUUID + case id + case name + case subscription + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.guestEnabled = try container.decodeIfPresent(Bool.self, forKey: .guestEnabled) + self._guestUserID = try container.decodeIfPresent(DecimalSerialized.self, forKey: .guestUserID) ?? DecimalSerialized(wrappedValue: nil) + self.guestUserUUID = try container.decodeIfPresent(String.self, forKey: .guestUserUUID) + self._id = try container.decodeIfPresent(DecimalSerialized.self, forKey: .id) ?? DecimalSerialized(wrappedValue: nil) + self.name = try container.decodeIfPresent(String.self, forKey: .name) + self.subscription = try container.decodeIfPresent(Bool.self, forKey: .subscription) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(self.guestEnabled, forKey: .guestEnabled) + if self.guestUserID != nil { + try container.encode(self._guestUserID, forKey: .guestUserID) + } + try container.encodeIfPresent(self.guestUserUUID, forKey: .guestUserUUID) + if self.id != nil { + try container.encode(self._id, forKey: .id) + } + try container.encodeIfPresent(self.name, forKey: .name) + try container.encodeIfPresent(self.subscription, forKey: .subscription) + } +} + +extension Operations.GetHomeDataResponseBody { + var idWrapper: DecimalSerialized { + return _id + } + var guestUserIDWrapper: DecimalSerialized { + return _guestUserID + } +} diff --git a/Sources/Plexswift/models/operations/GetLibraryFilter.swift b/Sources/Plexswift/models/operations/GetLibraryFilter.swift new file mode 100644 index 0000000..b9081e8 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetLibraryFilter.swift @@ -0,0 +1,36 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetLibraryFilter { + public let filter: String? + public let filterType: String? + public let key: String? + public let title: String? + public let type: String? + + /// Creates an object with the specified parameters + /// + /// + public init(filter: String? = nil, filterType: String? = nil, key: String? = nil, title: String? = nil, type: String? = nil) { + self.filter = filter + self.filterType = filterType + self.key = key + self.title = title + self.type = type + } + } +} + +extension Operations.GetLibraryFilter: Codable { + enum CodingKeys: String, CodingKey { + case filter + case filterType + case key + case title + case type + } +} + diff --git a/Sources/Plexswift/models/operations/GetLibraryItemsRequest.swift b/Sources/Plexswift/models/operations/GetLibraryItemsRequest.swift index 0478aa5..18783ca 100644 --- a/Sources/Plexswift/models/operations/GetLibraryItemsRequest.swift +++ b/Sources/Plexswift/models/operations/GetLibraryItemsRequest.swift @@ -6,7 +6,7 @@ extension Operations { /// A model object public struct GetLibraryItemsRequest: APIValue { /// the Id of the library to query - public let sectionId: Int + public let sectionId: AnyValue /// A key representing a specific tag within the section. public let tag: Operations.Tag @@ -15,7 +15,7 @@ extension Operations { /// - Parameter sectionId: the Id of the library to query /// - Parameter tag: A key representing a specific tag within the section. /// - public init(sectionId: Int, tag: Operations.Tag) { + public init(sectionId: AnyValue, tag: Operations.Tag) { self.sectionId = sectionId self.tag = tag } diff --git a/Sources/Plexswift/models/operations/GetLibraryType.swift b/Sources/Plexswift/models/operations/GetLibraryType.swift index 19465c3..5470ead 100644 --- a/Sources/Plexswift/models/operations/GetLibraryType.swift +++ b/Sources/Plexswift/models/operations/GetLibraryType.swift @@ -7,7 +7,7 @@ extension Operations { public struct GetLibraryType { public let active: Bool? public let field: [Operations.Field]? - public let filter: [Operations.Filter]? + public let filter: [Operations.GetLibraryFilter]? public let key: String? public let sort: [Operations.Sort]? public let title: String? @@ -16,7 +16,7 @@ extension Operations { /// Creates an object with the specified parameters /// /// - public init(active: Bool? = nil, field: [Operations.Field]? = nil, filter: [Operations.Filter]? = nil, key: String? = nil, sort: [Operations.Sort]? = nil, title: String? = nil, type: String? = nil) { + public init(active: Bool? = nil, field: [Operations.Field]? = nil, filter: [Operations.GetLibraryFilter]? = nil, key: String? = nil, sort: [Operations.Sort]? = nil, title: String? = nil, type: String? = nil) { self.active = active self.field = field self.filter = filter diff --git a/Sources/Plexswift/models/operations/GetPinRequest.swift b/Sources/Plexswift/models/operations/GetPinRequest.swift index a96e8e5..6073096 100644 --- a/Sources/Plexswift/models/operations/GetPinRequest.swift +++ b/Sources/Plexswift/models/operations/GetPinRequest.swift @@ -5,6 +5,9 @@ import Foundation extension Operations { /// A model object public struct GetPinRequest: APIValue { + /// Product name of the application shown in the list of devices + /// + public let xPlexProduct: String /// Determines the kind of code returned by the API call /// Strong codes are used for Pin authentication flows /// Non-Strong codes are used for `Plex.tv/link` @@ -18,6 +21,8 @@ extension Operations { /// Creates an object with the specified parameters /// + /// - Parameter xPlexProduct: Product name of the application shown in the list of devices + /// /// - Parameter strong: Determines the kind of code returned by the API call /// Strong codes are used for Pin authentication flows /// Non-Strong codes are used for `Plex.tv/link` @@ -27,7 +32,8 @@ extension Operations { /// (UUID, serial number, or other number unique per device) /// /// - public init(strong: Bool? = nil, xPlexClientIdentifier: String? = nil) { + public init(xPlexProduct: String, strong: Bool? = nil, xPlexClientIdentifier: String? = nil) { + self.xPlexProduct = xPlexProduct self.strong = strong self.xPlexClientIdentifier = xPlexClientIdentifier } diff --git a/Sources/Plexswift/models/operations/GetPinResponse.swift b/Sources/Plexswift/models/operations/GetPinResponse.swift index d18e9be..7e43181 100644 --- a/Sources/Plexswift/models/operations/GetPinResponse.swift +++ b/Sources/Plexswift/models/operations/GetPinResponse.swift @@ -6,7 +6,7 @@ extension Operations { /// A response model public enum GetPinResponse { case empty - case twoHundredApplicationJsonObject(Operations.GetPinResponseBody) + case twoHundredAndOneApplicationJsonObject(Operations.GetPinResponseBody) case fourHundredApplicationJsonObject(Operations.GetPinPlexResponseBody) var isEmpty: Bool { @@ -17,8 +17,8 @@ extension Operations { } } - public func twoHundredApplicationJsonObject() throws -> Operations.GetPinResponseBody { - guard case .twoHundredApplicationJsonObject(let value) = self else { + public func twoHundredAndOneApplicationJsonObject() throws -> Operations.GetPinResponseBody { + guard case .twoHundredAndOneApplicationJsonObject(let value) = self else { throw PlexswiftError.missingResponseData } return value diff --git a/Sources/Plexswift/models/operations/GetRecentlyAddedMediaContainer.swift b/Sources/Plexswift/models/operations/GetRecentlyAddedMediaContainer.swift index a6a49d4..018a116 100644 --- a/Sources/Plexswift/models/operations/GetRecentlyAddedMediaContainer.swift +++ b/Sources/Plexswift/models/operations/GetRecentlyAddedMediaContainer.swift @@ -10,7 +10,7 @@ extension Operations { public let mediaTagPrefix: String? @DecimalSerialized public private(set) var mediaTagVersion: Double? - public let metadata: [Operations.Metadata]? + public let metadata: [Operations.GetRecentlyAddedMetadata]? public let mixedParents: Bool? @DecimalSerialized public private(set) var size: Double? @@ -18,7 +18,7 @@ extension Operations { /// Creates an object with the specified parameters /// /// - public init(allowSync: Bool? = nil, identifier: String? = nil, mediaTagPrefix: String? = nil, mediaTagVersion: Double? = nil, metadata: [Operations.Metadata]? = nil, mixedParents: Bool? = nil, size: Double? = nil) { + public init(allowSync: Bool? = nil, identifier: String? = nil, mediaTagPrefix: String? = nil, mediaTagVersion: Double? = nil, metadata: [Operations.GetRecentlyAddedMetadata]? = nil, mixedParents: Bool? = nil, size: Double? = nil) { self.allowSync = allowSync self.identifier = identifier self.mediaTagPrefix = mediaTagPrefix @@ -47,7 +47,7 @@ extension Operations.GetRecentlyAddedMediaContainer: Codable { self.identifier = try container.decodeIfPresent(String.self, forKey: .identifier) self.mediaTagPrefix = try container.decodeIfPresent(String.self, forKey: .mediaTagPrefix) self._mediaTagVersion = try container.decodeIfPresent(DecimalSerialized.self, forKey: .mediaTagVersion) ?? DecimalSerialized(wrappedValue: nil) - self.metadata = try container.decodeIfPresent([Operations.Metadata].self, forKey: .metadata) + self.metadata = try container.decodeIfPresent([Operations.GetRecentlyAddedMetadata].self, forKey: .metadata) self.mixedParents = try container.decodeIfPresent(Bool.self, forKey: .mixedParents) self._size = try container.decodeIfPresent(DecimalSerialized.self, forKey: .size) ?? DecimalSerialized(wrappedValue: nil) } diff --git a/Sources/Plexswift/models/operations/GetRecentlyAddedMetadata.swift b/Sources/Plexswift/models/operations/GetRecentlyAddedMetadata.swift new file mode 100644 index 0000000..6e1e785 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetRecentlyAddedMetadata.swift @@ -0,0 +1,245 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetRecentlyAddedMetadata { + @DecimalSerialized + public private(set) var addedAt: Double? + public let allowSync: Bool? + public let art: String? + @DecimalSerialized + public private(set) var audienceRating: Double? + public let audienceRatingImage: String? + public let chapterSource: String? + public let contentRating: String? + public let country: [Operations.Country]? + public let director: [Operations.Director]? + @DecimalSerialized + public private(set) var duration: Double? + public let genre: [Operations.Genre]? + public let guid: String? + public let key: String? + @DecimalSerialized + public private(set) var librarySectionID: Double? + public let librarySectionTitle: String? + public let librarySectionUUID: String? + public let media: [Operations.Media]? + @DateTime + public private(set) var originallyAvailableAt: Date? + public let primaryExtraKey: String? + @DecimalSerialized + public private(set) var rating: Double? + public let ratingImage: String? + @DecimalSerialized + public private(set) var ratingKey: Double? + public let role: [Operations.Role]? + public let studio: String? + public let summary: String? + public let tagline: String? + public let thumb: String? + public let title: String? + public let type: String? + @DecimalSerialized + public private(set) var updatedAt: Double? + public let writer: [Operations.Writer]? + @DecimalSerialized + public private(set) var year: Double? + + /// Creates an object with the specified parameters + /// + /// + public init(addedAt: Double? = nil, allowSync: Bool? = nil, art: String? = nil, audienceRating: Double? = nil, audienceRatingImage: String? = nil, chapterSource: String? = nil, contentRating: String? = nil, country: [Operations.Country]? = nil, director: [Operations.Director]? = nil, duration: Double? = nil, genre: [Operations.Genre]? = nil, guid: String? = nil, key: String? = nil, librarySectionID: Double? = nil, librarySectionTitle: String? = nil, librarySectionUUID: String? = nil, media: [Operations.Media]? = nil, originallyAvailableAt: Date? = nil, primaryExtraKey: String? = nil, rating: Double? = nil, ratingImage: String? = nil, ratingKey: Double? = nil, role: [Operations.Role]? = nil, studio: String? = nil, summary: String? = nil, tagline: String? = nil, thumb: String? = nil, title: String? = nil, type: String? = nil, updatedAt: Double? = nil, writer: [Operations.Writer]? = nil, year: Double? = nil) { + self._addedAt = DecimalSerialized(wrappedValue: addedAt) + self.allowSync = allowSync + self.art = art + self._audienceRating = DecimalSerialized(wrappedValue: audienceRating) + self.audienceRatingImage = audienceRatingImage + self.chapterSource = chapterSource + self.contentRating = contentRating + self.country = country + self.director = director + self._duration = DecimalSerialized(wrappedValue: duration) + self.genre = genre + self.guid = guid + self.key = key + self._librarySectionID = DecimalSerialized(wrappedValue: librarySectionID) + self.librarySectionTitle = librarySectionTitle + self.librarySectionUUID = librarySectionUUID + self.media = media + self._originallyAvailableAt = DateTime(wrappedValue: originallyAvailableAt) + self.primaryExtraKey = primaryExtraKey + self._rating = DecimalSerialized(wrappedValue: rating) + self.ratingImage = ratingImage + self._ratingKey = DecimalSerialized(wrappedValue: ratingKey) + self.role = role + self.studio = studio + self.summary = summary + self.tagline = tagline + self.thumb = thumb + self.title = title + self.type = type + self._updatedAt = DecimalSerialized(wrappedValue: updatedAt) + self.writer = writer + self._year = DecimalSerialized(wrappedValue: year) + } + } +} + +extension Operations.GetRecentlyAddedMetadata: Codable { + enum CodingKeys: String, CodingKey { + case addedAt + case allowSync + case art + case audienceRating + case audienceRatingImage + case chapterSource + case contentRating + case country = "Country" + case director = "Director" + case duration + case genre = "Genre" + case guid + case key + case librarySectionID + case librarySectionTitle + case librarySectionUUID + case media = "Media" + case originallyAvailableAt + case primaryExtraKey + case rating + case ratingImage + case ratingKey + case role = "Role" + case studio + case summary + case tagline + case thumb + case title + case type + case updatedAt + case writer = "Writer" + case year + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self._addedAt = try container.decodeIfPresent(DecimalSerialized.self, forKey: .addedAt) ?? DecimalSerialized(wrappedValue: nil) + self.allowSync = try container.decodeIfPresent(Bool.self, forKey: .allowSync) + self.art = try container.decodeIfPresent(String.self, forKey: .art) + self._audienceRating = try container.decodeIfPresent(DecimalSerialized.self, forKey: .audienceRating) ?? DecimalSerialized(wrappedValue: nil) + self.audienceRatingImage = try container.decodeIfPresent(String.self, forKey: .audienceRatingImage) + self.chapterSource = try container.decodeIfPresent(String.self, forKey: .chapterSource) + self.contentRating = try container.decodeIfPresent(String.self, forKey: .contentRating) + self.country = try container.decodeIfPresent([Operations.Country].self, forKey: .country) + self.director = try container.decodeIfPresent([Operations.Director].self, forKey: .director) + self._duration = try container.decodeIfPresent(DecimalSerialized.self, forKey: .duration) ?? DecimalSerialized(wrappedValue: nil) + self.genre = try container.decodeIfPresent([Operations.Genre].self, forKey: .genre) + self.guid = try container.decodeIfPresent(String.self, forKey: .guid) + self.key = try container.decodeIfPresent(String.self, forKey: .key) + self._librarySectionID = try container.decodeIfPresent(DecimalSerialized.self, forKey: .librarySectionID) ?? DecimalSerialized(wrappedValue: nil) + self.librarySectionTitle = try container.decodeIfPresent(String.self, forKey: .librarySectionTitle) + self.librarySectionUUID = try container.decodeIfPresent(String.self, forKey: .librarySectionUUID) + self.media = try container.decodeIfPresent([Operations.Media].self, forKey: .media) + self._originallyAvailableAt = try container.decodeIfPresent(DateTime.self, forKey: .originallyAvailableAt) ?? DateTime(wrappedValue: nil) + self.primaryExtraKey = try container.decodeIfPresent(String.self, forKey: .primaryExtraKey) + self._rating = try container.decodeIfPresent(DecimalSerialized.self, forKey: .rating) ?? DecimalSerialized(wrappedValue: nil) + self.ratingImage = try container.decodeIfPresent(String.self, forKey: .ratingImage) + self._ratingKey = try container.decodeIfPresent(DecimalSerialized.self, forKey: .ratingKey) ?? DecimalSerialized(wrappedValue: nil) + self.role = try container.decodeIfPresent([Operations.Role].self, forKey: .role) + self.studio = try container.decodeIfPresent(String.self, forKey: .studio) + self.summary = try container.decodeIfPresent(String.self, forKey: .summary) + self.tagline = try container.decodeIfPresent(String.self, forKey: .tagline) + self.thumb = try container.decodeIfPresent(String.self, forKey: .thumb) + self.title = try container.decodeIfPresent(String.self, forKey: .title) + self.type = try container.decodeIfPresent(String.self, forKey: .type) + self._updatedAt = try container.decodeIfPresent(DecimalSerialized.self, forKey: .updatedAt) ?? DecimalSerialized(wrappedValue: nil) + self.writer = try container.decodeIfPresent([Operations.Writer].self, forKey: .writer) + self._year = try container.decodeIfPresent(DecimalSerialized.self, forKey: .year) ?? DecimalSerialized(wrappedValue: nil) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + if self.addedAt != nil { + try container.encode(self._addedAt, forKey: .addedAt) + } + try container.encodeIfPresent(self.allowSync, forKey: .allowSync) + try container.encodeIfPresent(self.art, forKey: .art) + if self.audienceRating != nil { + try container.encode(self._audienceRating, forKey: .audienceRating) + } + try container.encodeIfPresent(self.audienceRatingImage, forKey: .audienceRatingImage) + try container.encodeIfPresent(self.chapterSource, forKey: .chapterSource) + try container.encodeIfPresent(self.contentRating, forKey: .contentRating) + try container.encodeIfPresent(self.country, forKey: .country) + try container.encodeIfPresent(self.director, forKey: .director) + if self.duration != nil { + try container.encode(self._duration, forKey: .duration) + } + try container.encodeIfPresent(self.genre, forKey: .genre) + try container.encodeIfPresent(self.guid, forKey: .guid) + try container.encodeIfPresent(self.key, forKey: .key) + if self.librarySectionID != nil { + try container.encode(self._librarySectionID, forKey: .librarySectionID) + } + try container.encodeIfPresent(self.librarySectionTitle, forKey: .librarySectionTitle) + try container.encodeIfPresent(self.librarySectionUUID, forKey: .librarySectionUUID) + try container.encodeIfPresent(self.media, forKey: .media) + if self.originallyAvailableAt != nil { + try container.encode(self._originallyAvailableAt, forKey: .originallyAvailableAt) + } + try container.encodeIfPresent(self.primaryExtraKey, forKey: .primaryExtraKey) + if self.rating != nil { + try container.encode(self._rating, forKey: .rating) + } + try container.encodeIfPresent(self.ratingImage, forKey: .ratingImage) + if self.ratingKey != nil { + try container.encode(self._ratingKey, forKey: .ratingKey) + } + try container.encodeIfPresent(self.role, forKey: .role) + try container.encodeIfPresent(self.studio, forKey: .studio) + try container.encodeIfPresent(self.summary, forKey: .summary) + try container.encodeIfPresent(self.tagline, forKey: .tagline) + try container.encodeIfPresent(self.thumb, forKey: .thumb) + try container.encodeIfPresent(self.title, forKey: .title) + try container.encodeIfPresent(self.type, forKey: .type) + if self.updatedAt != nil { + try container.encode(self._updatedAt, forKey: .updatedAt) + } + try container.encodeIfPresent(self.writer, forKey: .writer) + if self.year != nil { + try container.encode(self._year, forKey: .year) + } + } +} + +extension Operations.GetRecentlyAddedMetadata { + var librarySectionIDWrapper: DecimalSerialized { + return _librarySectionID + } + var ratingKeyWrapper: DecimalSerialized { + return _ratingKey + } + var ratingWrapper: DecimalSerialized { + return _rating + } + var audienceRatingWrapper: DecimalSerialized { + return _audienceRating + } + var yearWrapper: DecimalSerialized { + return _year + } + var durationWrapper: DecimalSerialized { + return _duration + } + var originallyAvailableAtWrapper: DateTime { + return _originallyAvailableAt + } + var addedAtWrapper: DecimalSerialized { + return _addedAt + } + var updatedAtWrapper: DecimalSerialized { + return _updatedAt + } +} diff --git a/Sources/Plexswift/models/operations/GetTokenLocation.swift b/Sources/Plexswift/models/operations/GetTokenLocation.swift new file mode 100644 index 0000000..a122947 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetTokenLocation.swift @@ -0,0 +1,51 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetTokenLocation { + public let city: String? + public let code: String? + public let continentCode: String? + public let coordinates: String? + public let country: String? + public let europeanUnionMember: Bool? + public let inPrivacyRestrictedCountry: Bool? + public let postalCode: String? + public let subdivisions: String? + public let timeZone: String? + + /// Creates an object with the specified parameters + /// + /// + public init(city: String? = nil, code: String? = nil, continentCode: String? = nil, coordinates: String? = nil, country: String? = nil, europeanUnionMember: Bool? = nil, inPrivacyRestrictedCountry: Bool? = nil, postalCode: String? = nil, subdivisions: String? = nil, timeZone: String? = nil) { + self.city = city + self.code = code + self.continentCode = continentCode + self.coordinates = coordinates + self.country = country + self.europeanUnionMember = europeanUnionMember + self.inPrivacyRestrictedCountry = inPrivacyRestrictedCountry + self.postalCode = postalCode + self.subdivisions = subdivisions + self.timeZone = timeZone + } + } +} + +extension Operations.GetTokenLocation: Codable { + enum CodingKeys: String, CodingKey { + case city + case code + case continentCode = "continent_code" + case coordinates + case country + case europeanUnionMember = "european_union_member" + case inPrivacyRestrictedCountry = "in_privacy_restricted_country" + case postalCode = "postal_code" + case subdivisions + case timeZone = "time_zone" + } +} + diff --git a/Sources/Plexswift/models/operations/GetTokenPlexResponseBody.swift b/Sources/Plexswift/models/operations/GetTokenPlexResponseBody.swift new file mode 100644 index 0000000..4f5324d --- /dev/null +++ b/Sources/Plexswift/models/operations/GetTokenPlexResponseBody.swift @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// X-Plex-Client-Identifier is missing + public struct GetTokenPlexResponseBody { + public let errors: [Operations.GetTokenErrors]? + + /// Creates an object with the specified parameters + /// + /// + public init(errors: [Operations.GetTokenErrors]? = nil) { + self.errors = errors + } + } +} + +extension Operations.GetTokenPlexResponseBody: Codable { + enum CodingKeys: String, CodingKey { + case errors + } +} + diff --git a/Sources/Plexswift/models/operations/GetTokenResponse.swift b/Sources/Plexswift/models/operations/GetTokenResponse.swift index d9a7c8c..c251d95 100644 --- a/Sources/Plexswift/models/operations/GetTokenResponse.swift +++ b/Sources/Plexswift/models/operations/GetTokenResponse.swift @@ -6,7 +6,8 @@ extension Operations { /// A response model public enum GetTokenResponse { case empty - case object(Operations.GetTokenResponseBody) + case twoHundredApplicationJsonObject(Operations.GetTokenResponseBody) + case fourHundredApplicationJsonObject(Operations.GetTokenPlexResponseBody) var isEmpty: Bool { if case .empty = self { @@ -16,8 +17,15 @@ extension Operations { } } - public func object() throws -> Operations.GetTokenResponseBody { - guard case .object(let value) = self else { + public func twoHundredApplicationJsonObject() throws -> Operations.GetTokenResponseBody { + guard case .twoHundredApplicationJsonObject(let value) = self else { + throw PlexswiftError.missingResponseData + } + return value + } + + public func fourHundredApplicationJsonObject() throws -> Operations.GetTokenPlexResponseBody { + guard case .fourHundredApplicationJsonObject(let value) = self else { throw PlexswiftError.missingResponseData } return value diff --git a/Sources/Plexswift/models/operations/GetTokenResponseBody.swift b/Sources/Plexswift/models/operations/GetTokenResponseBody.swift index 2c8781b..cfabb5b 100644 --- a/Sources/Plexswift/models/operations/GetTokenResponseBody.swift +++ b/Sources/Plexswift/models/operations/GetTokenResponseBody.swift @@ -3,22 +3,123 @@ import Foundation extension Operations { - /// X-Plex-Client-Identifier is missing + /// Access Token public struct GetTokenResponseBody { - public let errors: [Operations.GetTokenErrors]? + public let authToken: String? + public let clientIdentifier: String? + public let code: String? + @DateTime + public private(set) var createdAt: Date? + @DateTime + public private(set) var expiresAt: Date? + @DecimalSerialized + public private(set) var expiresIn: Double? + /// PinID for use with authentication + @DecimalSerialized + public private(set) var id: Double? + public let location: Operations.GetTokenLocation? + public let newRegistration: String? + public let product: String? + /// a link to a QR code hosted on plex.tv + /// The QR code redirects to the relevant `plex.tv/link` authentication page + /// Which then prompts the user for the 4 Digit Link Pin + /// + public let qr: String? + public let trusted: Bool? /// Creates an object with the specified parameters /// + /// - Parameter id: PinID for use with authentication + /// - Parameter qr: a link to a QR code hosted on plex.tv + /// The QR code redirects to the relevant `plex.tv/link` authentication page + /// Which then prompts the user for the 4 Digit Link Pin + /// /// - public init(errors: [Operations.GetTokenErrors]? = nil) { - self.errors = errors + public init(authToken: String? = nil, clientIdentifier: String? = nil, code: String? = nil, createdAt: Date? = nil, expiresAt: Date? = nil, expiresIn: Double? = nil, id: Double? = nil, location: Operations.GetTokenLocation? = nil, newRegistration: String? = nil, product: String? = nil, qr: String? = nil, trusted: Bool? = nil) { + self.authToken = authToken + self.clientIdentifier = clientIdentifier + self.code = code + self._createdAt = DateTime(wrappedValue: createdAt) + self._expiresAt = DateTime(wrappedValue: expiresAt) + self._expiresIn = DecimalSerialized(wrappedValue: expiresIn) + self._id = DecimalSerialized(wrappedValue: id) + self.location = location + self.newRegistration = newRegistration + self.product = product + self.qr = qr + self.trusted = trusted } } } extension Operations.GetTokenResponseBody: Codable { enum CodingKeys: String, CodingKey { - case errors + case authToken + case clientIdentifier + case code + case createdAt + case expiresAt + case expiresIn + case id + case location + case newRegistration + case product + case qr + case trusted + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self.authToken = try container.decodeIfPresent(String.self, forKey: .authToken) + self.clientIdentifier = try container.decodeIfPresent(String.self, forKey: .clientIdentifier) + self.code = try container.decodeIfPresent(String.self, forKey: .code) + self._createdAt = try container.decodeIfPresent(DateTime.self, forKey: .createdAt) ?? DateTime(wrappedValue: nil) + self._expiresAt = try container.decodeIfPresent(DateTime.self, forKey: .expiresAt) ?? DateTime(wrappedValue: nil) + self._expiresIn = try container.decodeIfPresent(DecimalSerialized.self, forKey: .expiresIn) ?? DecimalSerialized(wrappedValue: nil) + self._id = try container.decodeIfPresent(DecimalSerialized.self, forKey: .id) ?? DecimalSerialized(wrappedValue: nil) + self.location = try container.decodeIfPresent(Operations.GetTokenLocation.self, forKey: .location) + self.newRegistration = try container.decodeIfPresent(String.self, forKey: .newRegistration) + self.product = try container.decodeIfPresent(String.self, forKey: .product) + self.qr = try container.decodeIfPresent(String.self, forKey: .qr) + self.trusted = try container.decodeIfPresent(Bool.self, forKey: .trusted) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encodeIfPresent(self.authToken, forKey: .authToken) + try container.encodeIfPresent(self.clientIdentifier, forKey: .clientIdentifier) + try container.encodeIfPresent(self.code, forKey: .code) + if self.createdAt != nil { + try container.encode(self._createdAt, forKey: .createdAt) + } + if self.expiresAt != nil { + try container.encode(self._expiresAt, forKey: .expiresAt) + } + if self.expiresIn != nil { + try container.encode(self._expiresIn, forKey: .expiresIn) + } + if self.id != nil { + try container.encode(self._id, forKey: .id) + } + try container.encodeIfPresent(self.location, forKey: .location) + try container.encodeIfPresent(self.newRegistration, forKey: .newRegistration) + try container.encodeIfPresent(self.product, forKey: .product) + try container.encodeIfPresent(self.qr, forKey: .qr) + try container.encodeIfPresent(self.trusted, forKey: .trusted) } } +extension Operations.GetTokenResponseBody { + var idWrapper: DecimalSerialized { + return _id + } + var expiresInWrapper: DecimalSerialized { + return _expiresIn + } + var createdAtWrapper: DateTime { + return _createdAt + } + var expiresAtWrapper: DateTime { + return _expiresAt + } +} diff --git a/Sources/Plexswift/models/operations/GetWatchlistErrors.swift b/Sources/Plexswift/models/operations/GetWatchlistErrors.swift new file mode 100644 index 0000000..9938e40 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetWatchlistErrors.swift @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetWatchlistErrors { + @DecimalSerialized + public private(set) var code: Double? + public let message: String? + @DecimalSerialized + public private(set) var status: Double? + + /// Creates an object with the specified parameters + /// + /// + public init(code: Double? = nil, message: String? = nil, status: Double? = nil) { + self._code = DecimalSerialized(wrappedValue: code) + self.message = message + self._status = DecimalSerialized(wrappedValue: status) + } + } +} + +extension Operations.GetWatchlistErrors: Codable { + enum CodingKeys: String, CodingKey { + case code + case message + case status + } + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + self._code = try container.decodeIfPresent(DecimalSerialized.self, forKey: .code) ?? DecimalSerialized(wrappedValue: nil) + self.message = try container.decodeIfPresent(String.self, forKey: .message) + self._status = try container.decodeIfPresent(DecimalSerialized.self, forKey: .status) ?? DecimalSerialized(wrappedValue: nil) + } + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + if self.code != nil { + try container.encode(self._code, forKey: .code) + } + try container.encodeIfPresent(self.message, forKey: .message) + if self.status != nil { + try container.encode(self._status, forKey: .status) + } + } +} + +extension Operations.GetWatchlistErrors { + var codeWrapper: DecimalSerialized { + return _code + } + var statusWrapper: DecimalSerialized { + return _status + } +} diff --git a/Sources/Plexswift/models/operations/GetWatchlistRequest.swift b/Sources/Plexswift/models/operations/GetWatchlistRequest.swift new file mode 100644 index 0000000..f3084fd --- /dev/null +++ b/Sources/Plexswift/models/operations/GetWatchlistRequest.swift @@ -0,0 +1,75 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct GetWatchlistRequest: APIValue { + /// Filter + public let filter: Operations.Filter + /// User Token + public let xPlexToken: String + /// include collections in the results + /// + public let includeCollections: Operations.IncludeCollections? + /// include external media in the results + /// + public let includeExternalMedia: Operations.IncludeExternalMedia? + /// The type of library to filter. Can be "movie" or "show", or all if not present. + /// + public let libtype: Operations.Libtype? + /// The number of items to return. If not specified, all items will be returned. + /// If the number of items exceeds the limit, the response will be paginated. + /// + public let maxresults: Int? + /// In the format "field:dir". Available fields are "watchlistedAt" (Added At), + /// "titleSort" (Title), "originallyAvailableAt" (Release Date), or "rating" (Critic Rating). + /// "dir" can be "asc" or "desc" + /// + public let sort: String? + /// The number of items to return. If not specified, all items will be returned. + /// If the number of items exceeds the limit, the response will be paginated. + /// + public let xPlexContainerSize: Int? + /// The index of the first item to return. If not specified, the first item will be returned. + /// If the number of items exceeds the limit, the response will be paginated. + /// + public let xPlexContainerStart: Int? + + /// Creates an object with the specified parameters + /// + /// - Parameter filter: Filter + /// - Parameter xPlexToken: User Token + /// - Parameter includeCollections: include collections in the results + /// + /// - Parameter includeExternalMedia: include external media in the results + /// + /// - Parameter libtype: The type of library to filter. Can be "movie" or "show", or all if not present. + /// + /// - Parameter maxresults: The number of items to return. If not specified, all items will be returned. + /// If the number of items exceeds the limit, the response will be paginated. + /// + /// - Parameter sort: In the format "field:dir". Available fields are "watchlistedAt" (Added At), + /// "titleSort" (Title), "originallyAvailableAt" (Release Date), or "rating" (Critic Rating). + /// "dir" can be "asc" or "desc" + /// + /// - Parameter xPlexContainerSize: The number of items to return. If not specified, all items will be returned. + /// If the number of items exceeds the limit, the response will be paginated. + /// + /// - Parameter xPlexContainerStart: The index of the first item to return. If not specified, the first item will be returned. + /// If the number of items exceeds the limit, the response will be paginated. + /// + /// + public init(filter: Operations.Filter, xPlexToken: String, includeCollections: Operations.IncludeCollections? = nil, includeExternalMedia: Operations.IncludeExternalMedia? = nil, libtype: Operations.Libtype? = nil, maxresults: Int? = nil, sort: String? = nil, xPlexContainerSize: Int? = nil, xPlexContainerStart: Int? = nil) { + self.filter = filter + self.xPlexToken = xPlexToken + self.includeCollections = includeCollections + self.includeExternalMedia = includeExternalMedia + self.libtype = libtype + self.maxresults = maxresults + self.sort = sort + self.xPlexContainerSize = xPlexContainerSize + self.xPlexContainerStart = xPlexContainerStart + } + } +} diff --git a/Sources/Plexswift/models/operations/GetWatchlistResponse.swift b/Sources/Plexswift/models/operations/GetWatchlistResponse.swift new file mode 100644 index 0000000..1869e5c --- /dev/null +++ b/Sources/Plexswift/models/operations/GetWatchlistResponse.swift @@ -0,0 +1,34 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A response model + public enum GetWatchlistResponse { + case empty + case twoHundredApplicationJsonObject(Operations.GetWatchlistResponseBody) + case fourHundredAndOneApplicationJsonObject(Operations.GetWatchlistWatchlistResponseBody) + + var isEmpty: Bool { + if case .empty = self { + return true + } else { + return false + } + } + + public func twoHundredApplicationJsonObject() throws -> Operations.GetWatchlistResponseBody { + guard case .twoHundredApplicationJsonObject(let value) = self else { + throw PlexswiftError.missingResponseData + } + return value + } + + public func fourHundredAndOneApplicationJsonObject() throws -> Operations.GetWatchlistWatchlistResponseBody { + guard case .fourHundredAndOneApplicationJsonObject(let value) = self else { + throw PlexswiftError.missingResponseData + } + return value + } + } +} diff --git a/Sources/Plexswift/models/operations/GetWatchlistResponseBody.swift b/Sources/Plexswift/models/operations/GetWatchlistResponseBody.swift new file mode 100644 index 0000000..4eca4fc --- /dev/null +++ b/Sources/Plexswift/models/operations/GetWatchlistResponseBody.swift @@ -0,0 +1,42 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// Watchlist Data + public struct GetWatchlistResponseBody { + public let identifier: String? + public let librarySectionID: String? + public let librarySectionTitle: String? + public let metadata: [Operations.Metadata]? + public let offset: Int? + public let size: Int? + public let totalSize: Int? + + /// Creates an object with the specified parameters + /// + /// + public init(identifier: String? = nil, librarySectionID: String? = nil, librarySectionTitle: String? = nil, metadata: [Operations.Metadata]? = nil, offset: Int? = nil, size: Int? = nil, totalSize: Int? = nil) { + self.identifier = identifier + self.librarySectionID = librarySectionID + self.librarySectionTitle = librarySectionTitle + self.metadata = metadata + self.offset = offset + self.size = size + self.totalSize = totalSize + } + } +} + +extension Operations.GetWatchlistResponseBody: Codable { + enum CodingKeys: String, CodingKey { + case identifier + case librarySectionID + case librarySectionTitle + case metadata = "Metadata" + case offset + case size + case totalSize + } +} + diff --git a/Sources/Plexswift/models/operations/GetWatchlistWatchlistResponseBody.swift b/Sources/Plexswift/models/operations/GetWatchlistWatchlistResponseBody.swift new file mode 100644 index 0000000..74b66a5 --- /dev/null +++ b/Sources/Plexswift/models/operations/GetWatchlistWatchlistResponseBody.swift @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// Unauthorized - Returned if the X-Plex-Token is missing from the header or query. + public struct GetWatchlistWatchlistResponseBody { + public let errors: [Operations.GetWatchlistErrors]? + + /// Creates an object with the specified parameters + /// + /// + public init(errors: [Operations.GetWatchlistErrors]? = nil) { + self.errors = errors + } + } +} + +extension Operations.GetWatchlistWatchlistResponseBody: Codable { + enum CodingKeys: String, CodingKey { + case errors + } +} + diff --git a/Sources/Plexswift/models/operations/Image.swift b/Sources/Plexswift/models/operations/Image.swift new file mode 100644 index 0000000..a61bc71 --- /dev/null +++ b/Sources/Plexswift/models/operations/Image.swift @@ -0,0 +1,30 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// A model object + public struct Image { + public let alt: String? + public let type: String? + public let url: String? + + /// Creates an object with the specified parameters + /// + /// + public init(alt: String? = nil, type: String? = nil, url: String? = nil) { + self.alt = alt + self.type = type + self.url = url + } + } +} + +extension Operations.Image: Codable { + enum CodingKeys: String, CodingKey { + case alt + case type + case url + } +} + diff --git a/Sources/Plexswift/models/operations/IncludeCollections.swift b/Sources/Plexswift/models/operations/IncludeCollections.swift new file mode 100644 index 0000000..93a9aa8 --- /dev/null +++ b/Sources/Plexswift/models/operations/IncludeCollections.swift @@ -0,0 +1,12 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// include collections in the results + /// + public enum IncludeCollections: Int, Codable, APIValue { + case one = 1 + case zero = 0 + } +} diff --git a/Sources/Plexswift/models/operations/IncludeExternalMedia.swift b/Sources/Plexswift/models/operations/IncludeExternalMedia.swift new file mode 100644 index 0000000..775d2cd --- /dev/null +++ b/Sources/Plexswift/models/operations/IncludeExternalMedia.swift @@ -0,0 +1,12 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// include external media in the results + /// + public enum IncludeExternalMedia: Int, Codable, APIValue { + case one = 1 + case zero = 0 + } +} diff --git a/Sources/Plexswift/models/operations/Libtype.swift b/Sources/Plexswift/models/operations/Libtype.swift new file mode 100644 index 0000000..dd16ea2 --- /dev/null +++ b/Sources/Plexswift/models/operations/Libtype.swift @@ -0,0 +1,12 @@ +// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. + +import Foundation + +extension Operations { + /// The type of library to filter. Can be "movie" or "show", or all if not present. + /// + public enum Libtype: String, Codable, APIValue { + case movie = "movie" + case show = "show" + } +} diff --git a/Sources/Plexswift/models/operations/Location.swift b/Sources/Plexswift/models/operations/Location.swift index 703207a..3a190c0 100644 --- a/Sources/Plexswift/models/operations/Location.swift +++ b/Sources/Plexswift/models/operations/Location.swift @@ -12,15 +12,14 @@ extension Operations { public let country: String? public let europeanUnionMember: Bool? public let inPrivacyRestrictedCountry: Bool? - @DecimalSerialized - public private(set) var postalCode: Double? + public let postalCode: String? public let subdivisions: String? public let timeZone: String? /// Creates an object with the specified parameters /// /// - public init(city: String? = nil, code: String? = nil, continentCode: String? = nil, coordinates: String? = nil, country: String? = nil, europeanUnionMember: Bool? = nil, inPrivacyRestrictedCountry: Bool? = nil, postalCode: Double? = nil, subdivisions: String? = nil, timeZone: String? = nil) { + public init(city: String? = nil, code: String? = nil, continentCode: String? = nil, coordinates: String? = nil, country: String? = nil, europeanUnionMember: Bool? = nil, inPrivacyRestrictedCountry: Bool? = nil, postalCode: String? = nil, subdivisions: String? = nil, timeZone: String? = nil) { self.city = city self.code = code self.continentCode = continentCode @@ -28,7 +27,7 @@ extension Operations { self.country = country self.europeanUnionMember = europeanUnionMember self.inPrivacyRestrictedCountry = inPrivacyRestrictedCountry - self._postalCode = DecimalSerialized(wrappedValue: postalCode) + self.postalCode = postalCode self.subdivisions = subdivisions self.timeZone = timeZone } @@ -48,40 +47,5 @@ extension Operations.Location: Codable { case subdivisions case timeZone = "time_zone" } - - public init(from decoder: Decoder) throws { - let container = try decoder.container(keyedBy: CodingKeys.self) - self.city = try container.decodeIfPresent(String.self, forKey: .city) - self.code = try container.decodeIfPresent(String.self, forKey: .code) - self.continentCode = try container.decodeIfPresent(String.self, forKey: .continentCode) - self.coordinates = try container.decodeIfPresent(String.self, forKey: .coordinates) - self.country = try container.decodeIfPresent(String.self, forKey: .country) - self.europeanUnionMember = try container.decodeIfPresent(Bool.self, forKey: .europeanUnionMember) - self.inPrivacyRestrictedCountry = try container.decodeIfPresent(Bool.self, forKey: .inPrivacyRestrictedCountry) - self._postalCode = try container.decodeIfPresent(DecimalSerialized.self, forKey: .postalCode) ?? DecimalSerialized(wrappedValue: nil) - self.subdivisions = try container.decodeIfPresent(String.self, forKey: .subdivisions) - self.timeZone = try container.decodeIfPresent(String.self, forKey: .timeZone) - } - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encodeIfPresent(self.city, forKey: .city) - try container.encodeIfPresent(self.code, forKey: .code) - try container.encodeIfPresent(self.continentCode, forKey: .continentCode) - try container.encodeIfPresent(self.coordinates, forKey: .coordinates) - try container.encodeIfPresent(self.country, forKey: .country) - try container.encodeIfPresent(self.europeanUnionMember, forKey: .europeanUnionMember) - try container.encodeIfPresent(self.inPrivacyRestrictedCountry, forKey: .inPrivacyRestrictedCountry) - if self.postalCode != nil { - try container.encode(self._postalCode, forKey: .postalCode) - } - try container.encodeIfPresent(self.subdivisions, forKey: .subdivisions) - try container.encodeIfPresent(self.timeZone, forKey: .timeZone) - } } -extension Operations.Location { - var postalCodeWrapper: DecimalSerialized { - return _postalCode - } -} diff --git a/Sources/Plexswift/models/operations/Metadata.swift b/Sources/Plexswift/models/operations/Metadata.swift index 29b1779..0b063cc 100644 --- a/Sources/Plexswift/models/operations/Metadata.swift +++ b/Sources/Plexswift/models/operations/Metadata.swift @@ -5,84 +5,84 @@ import Foundation extension Operations { /// A model object public struct Metadata { - @DecimalSerialized - public private(set) var addedAt: Double? - public let allowSync: Bool? + public let addedAt: Int? public let art: String? @DecimalSerialized public private(set) var audienceRating: Double? public let audienceRatingImage: String? - public let chapterSource: String? + public let availabilityId: String? + public let banner: String? + public let childCount: Int? public let contentRating: String? - public let country: [Operations.Country]? - public let director: [Operations.Director]? - @DecimalSerialized - public private(set) var duration: Double? - public let genre: [Operations.Genre]? + public let duration: Int? + public let expiresAt: Int? public let guid: String? + public let image: [Operations.Image]? + public let imdbRatingCount: Int? + public let isContinuingSeries: Bool? public let key: String? - @DecimalSerialized - public private(set) var librarySectionID: Double? - public let librarySectionTitle: String? - public let librarySectionUUID: String? - public let media: [Operations.Media]? - @DateTime + public let leafCount: Int? + @DateOnly public private(set) var originallyAvailableAt: Date? - public let primaryExtraKey: String? + public let originalTitle: String? + public let playableKey: String? + public let publicPagesURL: String? @DecimalSerialized public private(set) var rating: Double? public let ratingImage: String? - @DecimalSerialized - public private(set) var ratingKey: Double? - public let role: [Operations.Role]? + public let ratingKey: String? + public let skipChildren: Bool? + public let slug: String? + public let streamingMediaId: String? public let studio: String? - public let summary: String? + public let subtype: String? public let tagline: String? + public let theme: String? public let thumb: String? public let title: String? public let type: String? - @DecimalSerialized - public private(set) var updatedAt: Double? - public let writer: [Operations.Writer]? - @DecimalSerialized - public private(set) var year: Double? + public let userState: Bool? + public let year: Int? /// Creates an object with the specified parameters /// /// - public init(addedAt: Double? = nil, allowSync: Bool? = nil, art: String? = nil, audienceRating: Double? = nil, audienceRatingImage: String? = nil, chapterSource: String? = nil, contentRating: String? = nil, country: [Operations.Country]? = nil, director: [Operations.Director]? = nil, duration: Double? = nil, genre: [Operations.Genre]? = nil, guid: String? = nil, key: String? = nil, librarySectionID: Double? = nil, librarySectionTitle: String? = nil, librarySectionUUID: String? = nil, media: [Operations.Media]? = nil, originallyAvailableAt: Date? = nil, primaryExtraKey: String? = nil, rating: Double? = nil, ratingImage: String? = nil, ratingKey: Double? = nil, role: [Operations.Role]? = nil, studio: String? = nil, summary: String? = nil, tagline: String? = nil, thumb: String? = nil, title: String? = nil, type: String? = nil, updatedAt: Double? = nil, writer: [Operations.Writer]? = nil, year: Double? = nil) { - self._addedAt = DecimalSerialized(wrappedValue: addedAt) - self.allowSync = allowSync + public init(addedAt: Int? = nil, art: String? = nil, audienceRating: Double? = nil, audienceRatingImage: String? = nil, availabilityId: String? = nil, banner: String? = nil, childCount: Int? = nil, contentRating: String? = nil, duration: Int? = nil, expiresAt: Int? = nil, guid: String? = nil, image: [Operations.Image]? = nil, imdbRatingCount: Int? = nil, isContinuingSeries: Bool? = nil, key: String? = nil, leafCount: Int? = nil, originallyAvailableAt: Date? = nil, originalTitle: String? = nil, playableKey: String? = nil, publicPagesURL: String? = nil, rating: Double? = nil, ratingImage: String? = nil, ratingKey: String? = nil, skipChildren: Bool? = nil, slug: String? = nil, streamingMediaId: String? = nil, studio: String? = nil, subtype: String? = nil, tagline: String? = nil, theme: String? = nil, thumb: String? = nil, title: String? = nil, type: String? = nil, userState: Bool? = nil, year: Int? = nil) { + self.addedAt = addedAt self.art = art self._audienceRating = DecimalSerialized(wrappedValue: audienceRating) self.audienceRatingImage = audienceRatingImage - self.chapterSource = chapterSource + self.availabilityId = availabilityId + self.banner = banner + self.childCount = childCount self.contentRating = contentRating - self.country = country - self.director = director - self._duration = DecimalSerialized(wrappedValue: duration) - self.genre = genre + self.duration = duration + self.expiresAt = expiresAt self.guid = guid + self.image = image + self.imdbRatingCount = imdbRatingCount + self.isContinuingSeries = isContinuingSeries self.key = key - self._librarySectionID = DecimalSerialized(wrappedValue: librarySectionID) - self.librarySectionTitle = librarySectionTitle - self.librarySectionUUID = librarySectionUUID - self.media = media - self._originallyAvailableAt = DateTime(wrappedValue: originallyAvailableAt) - self.primaryExtraKey = primaryExtraKey + self.leafCount = leafCount + self._originallyAvailableAt = DateOnly(wrappedValue: originallyAvailableAt) + self.originalTitle = originalTitle + self.playableKey = playableKey + self.publicPagesURL = publicPagesURL self._rating = DecimalSerialized(wrappedValue: rating) self.ratingImage = ratingImage - self._ratingKey = DecimalSerialized(wrappedValue: ratingKey) - self.role = role + self.ratingKey = ratingKey + self.skipChildren = skipChildren + self.slug = slug + self.streamingMediaId = streamingMediaId self.studio = studio - self.summary = summary + self.subtype = subtype self.tagline = tagline + self.theme = theme self.thumb = thumb self.title = title self.type = type - self._updatedAt = DecimalSerialized(wrappedValue: updatedAt) - self.writer = writer - self._year = DecimalSerialized(wrappedValue: year) + self.userState = userState + self.year = year } } } @@ -90,136 +90,130 @@ extension Operations { extension Operations.Metadata: Codable { enum CodingKeys: String, CodingKey { case addedAt - case allowSync case art case audienceRating case audienceRatingImage - case chapterSource + case availabilityId + case banner + case childCount case contentRating - case country = "Country" - case director = "Director" case duration - case genre = "Genre" + case expiresAt case guid + case image = "Image" + case imdbRatingCount + case isContinuingSeries case key - case librarySectionID - case librarySectionTitle - case librarySectionUUID - case media = "Media" + case leafCount case originallyAvailableAt - case primaryExtraKey + case originalTitle + case playableKey + case publicPagesURL case rating case ratingImage case ratingKey - case role = "Role" + case skipChildren + case slug + case streamingMediaId case studio - case summary + case subtype case tagline + case theme case thumb case title case type - case updatedAt - case writer = "Writer" + case userState case year } public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) - self._addedAt = try container.decodeIfPresent(DecimalSerialized.self, forKey: .addedAt) ?? DecimalSerialized(wrappedValue: nil) - self.allowSync = try container.decodeIfPresent(Bool.self, forKey: .allowSync) + self.addedAt = try container.decodeIfPresent(Int.self, forKey: .addedAt) self.art = try container.decodeIfPresent(String.self, forKey: .art) self._audienceRating = try container.decodeIfPresent(DecimalSerialized.self, forKey: .audienceRating) ?? DecimalSerialized(wrappedValue: nil) self.audienceRatingImage = try container.decodeIfPresent(String.self, forKey: .audienceRatingImage) - self.chapterSource = try container.decodeIfPresent(String.self, forKey: .chapterSource) + self.availabilityId = try container.decodeIfPresent(String.self, forKey: .availabilityId) + self.banner = try container.decodeIfPresent(String.self, forKey: .banner) + self.childCount = try container.decodeIfPresent(Int.self, forKey: .childCount) self.contentRating = try container.decodeIfPresent(String.self, forKey: .contentRating) - self.country = try container.decodeIfPresent([Operations.Country].self, forKey: .country) - self.director = try container.decodeIfPresent([Operations.Director].self, forKey: .director) - self._duration = try container.decodeIfPresent(DecimalSerialized.self, forKey: .duration) ?? DecimalSerialized(wrappedValue: nil) - self.genre = try container.decodeIfPresent([Operations.Genre].self, forKey: .genre) + self.duration = try container.decodeIfPresent(Int.self, forKey: .duration) + self.expiresAt = try container.decodeIfPresent(Int.self, forKey: .expiresAt) self.guid = try container.decodeIfPresent(String.self, forKey: .guid) + self.image = try container.decodeIfPresent([Operations.Image].self, forKey: .image) + self.imdbRatingCount = try container.decodeIfPresent(Int.self, forKey: .imdbRatingCount) + self.isContinuingSeries = try container.decodeIfPresent(Bool.self, forKey: .isContinuingSeries) self.key = try container.decodeIfPresent(String.self, forKey: .key) - self._librarySectionID = try container.decodeIfPresent(DecimalSerialized.self, forKey: .librarySectionID) ?? DecimalSerialized(wrappedValue: nil) - self.librarySectionTitle = try container.decodeIfPresent(String.self, forKey: .librarySectionTitle) - self.librarySectionUUID = try container.decodeIfPresent(String.self, forKey: .librarySectionUUID) - self.media = try container.decodeIfPresent([Operations.Media].self, forKey: .media) - self._originallyAvailableAt = try container.decodeIfPresent(DateTime.self, forKey: .originallyAvailableAt) ?? DateTime(wrappedValue: nil) - self.primaryExtraKey = try container.decodeIfPresent(String.self, forKey: .primaryExtraKey) + self.leafCount = try container.decodeIfPresent(Int.self, forKey: .leafCount) + self._originallyAvailableAt = try container.decodeIfPresent(DateOnly.self, forKey: .originallyAvailableAt) ?? DateOnly(wrappedValue: nil) + self.originalTitle = try container.decodeIfPresent(String.self, forKey: .originalTitle) + self.playableKey = try container.decodeIfPresent(String.self, forKey: .playableKey) + self.publicPagesURL = try container.decodeIfPresent(String.self, forKey: .publicPagesURL) self._rating = try container.decodeIfPresent(DecimalSerialized.self, forKey: .rating) ?? DecimalSerialized(wrappedValue: nil) self.ratingImage = try container.decodeIfPresent(String.self, forKey: .ratingImage) - self._ratingKey = try container.decodeIfPresent(DecimalSerialized.self, forKey: .ratingKey) ?? DecimalSerialized(wrappedValue: nil) - self.role = try container.decodeIfPresent([Operations.Role].self, forKey: .role) + self.ratingKey = try container.decodeIfPresent(String.self, forKey: .ratingKey) + self.skipChildren = try container.decodeIfPresent(Bool.self, forKey: .skipChildren) + self.slug = try container.decodeIfPresent(String.self, forKey: .slug) + self.streamingMediaId = try container.decodeIfPresent(String.self, forKey: .streamingMediaId) self.studio = try container.decodeIfPresent(String.self, forKey: .studio) - self.summary = try container.decodeIfPresent(String.self, forKey: .summary) + self.subtype = try container.decodeIfPresent(String.self, forKey: .subtype) self.tagline = try container.decodeIfPresent(String.self, forKey: .tagline) + self.theme = try container.decodeIfPresent(String.self, forKey: .theme) self.thumb = try container.decodeIfPresent(String.self, forKey: .thumb) self.title = try container.decodeIfPresent(String.self, forKey: .title) self.type = try container.decodeIfPresent(String.self, forKey: .type) - self._updatedAt = try container.decodeIfPresent(DecimalSerialized.self, forKey: .updatedAt) ?? DecimalSerialized(wrappedValue: nil) - self.writer = try container.decodeIfPresent([Operations.Writer].self, forKey: .writer) - self._year = try container.decodeIfPresent(DecimalSerialized.self, forKey: .year) ?? DecimalSerialized(wrappedValue: nil) + self.userState = try container.decodeIfPresent(Bool.self, forKey: .userState) + self.year = try container.decodeIfPresent(Int.self, forKey: .year) } public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) - if self.addedAt != nil { - try container.encode(self._addedAt, forKey: .addedAt) - } - try container.encodeIfPresent(self.allowSync, forKey: .allowSync) + try container.encodeIfPresent(self.addedAt, forKey: .addedAt) try container.encodeIfPresent(self.art, forKey: .art) if self.audienceRating != nil { try container.encode(self._audienceRating, forKey: .audienceRating) } try container.encodeIfPresent(self.audienceRatingImage, forKey: .audienceRatingImage) - try container.encodeIfPresent(self.chapterSource, forKey: .chapterSource) + try container.encodeIfPresent(self.availabilityId, forKey: .availabilityId) + try container.encodeIfPresent(self.banner, forKey: .banner) + try container.encodeIfPresent(self.childCount, forKey: .childCount) try container.encodeIfPresent(self.contentRating, forKey: .contentRating) - try container.encodeIfPresent(self.country, forKey: .country) - try container.encodeIfPresent(self.director, forKey: .director) - if self.duration != nil { - try container.encode(self._duration, forKey: .duration) - } - try container.encodeIfPresent(self.genre, forKey: .genre) + try container.encodeIfPresent(self.duration, forKey: .duration) + try container.encodeIfPresent(self.expiresAt, forKey: .expiresAt) try container.encodeIfPresent(self.guid, forKey: .guid) + try container.encodeIfPresent(self.image, forKey: .image) + try container.encodeIfPresent(self.imdbRatingCount, forKey: .imdbRatingCount) + try container.encodeIfPresent(self.isContinuingSeries, forKey: .isContinuingSeries) try container.encodeIfPresent(self.key, forKey: .key) - if self.librarySectionID != nil { - try container.encode(self._librarySectionID, forKey: .librarySectionID) - } - try container.encodeIfPresent(self.librarySectionTitle, forKey: .librarySectionTitle) - try container.encodeIfPresent(self.librarySectionUUID, forKey: .librarySectionUUID) - try container.encodeIfPresent(self.media, forKey: .media) + try container.encodeIfPresent(self.leafCount, forKey: .leafCount) if self.originallyAvailableAt != nil { try container.encode(self._originallyAvailableAt, forKey: .originallyAvailableAt) } - try container.encodeIfPresent(self.primaryExtraKey, forKey: .primaryExtraKey) + try container.encodeIfPresent(self.originalTitle, forKey: .originalTitle) + try container.encodeIfPresent(self.playableKey, forKey: .playableKey) + try container.encodeIfPresent(self.publicPagesURL, forKey: .publicPagesURL) if self.rating != nil { try container.encode(self._rating, forKey: .rating) } try container.encodeIfPresent(self.ratingImage, forKey: .ratingImage) - if self.ratingKey != nil { - try container.encode(self._ratingKey, forKey: .ratingKey) - } - try container.encodeIfPresent(self.role, forKey: .role) + try container.encodeIfPresent(self.ratingKey, forKey: .ratingKey) + try container.encodeIfPresent(self.skipChildren, forKey: .skipChildren) + try container.encodeIfPresent(self.slug, forKey: .slug) + try container.encodeIfPresent(self.streamingMediaId, forKey: .streamingMediaId) try container.encodeIfPresent(self.studio, forKey: .studio) - try container.encodeIfPresent(self.summary, forKey: .summary) + try container.encodeIfPresent(self.subtype, forKey: .subtype) try container.encodeIfPresent(self.tagline, forKey: .tagline) + try container.encodeIfPresent(self.theme, forKey: .theme) try container.encodeIfPresent(self.thumb, forKey: .thumb) try container.encodeIfPresent(self.title, forKey: .title) try container.encodeIfPresent(self.type, forKey: .type) - if self.updatedAt != nil { - try container.encode(self._updatedAt, forKey: .updatedAt) - } - try container.encodeIfPresent(self.writer, forKey: .writer) - if self.year != nil { - try container.encode(self._year, forKey: .year) - } + try container.encodeIfPresent(self.userState, forKey: .userState) + try container.encodeIfPresent(self.year, forKey: .year) } } extension Operations.Metadata { - var librarySectionIDWrapper: DecimalSerialized { - return _librarySectionID - } - var ratingKeyWrapper: DecimalSerialized { - return _ratingKey + var originallyAvailableAtWrapper: DateOnly { + return _originallyAvailableAt } var ratingWrapper: DecimalSerialized { return _rating @@ -227,19 +221,4 @@ extension Operations.Metadata { var audienceRatingWrapper: DecimalSerialized { return _audienceRating } - var yearWrapper: DecimalSerialized { - return _year - } - var durationWrapper: DecimalSerialized { - return _duration - } - var originallyAvailableAtWrapper: DateTime { - return _originallyAvailableAt - } - var addedAtWrapper: DecimalSerialized { - return _addedAt - } - var updatedAtWrapper: DecimalSerialized { - return _updatedAt - } } diff --git a/Sources/plexswift/PlexswiftAPI.swift b/Sources/plexswift/PlexswiftAPI.swift index f919591..ee515d9 100644 --- a/Sources/plexswift/PlexswiftAPI.swift +++ b/Sources/plexswift/PlexswiftAPI.swift @@ -22,16 +22,17 @@ import Foundation /// - ``video`` /// - ``activities`` /// - ``butler`` +/// - ``plex`` /// - ``hubs`` /// - ``search`` /// - ``library`` /// - ``log`` -/// - ``plex`` /// - ``playlists`` /// - ``authentication`` /// - ``statistics`` /// - ``sessions`` /// - ``updater`` +/// - ``watchlist`` /// public protocol PlexswiftAPI { @@ -57,6 +58,9 @@ public protocol PlexswiftAPI { /// Butler is the task manager of the Plex Media Server Ecosystem. /// var butler: ButlerAPI { get } + /// API Calls that perform operations directly against https://Plex.tv + /// + var plex: PlexAPI { get } /// Hubs are a structured two-dimensional container for media, generally represented by multiple horizontal rows. /// var hubs: HubsAPI { get } @@ -69,9 +73,6 @@ public protocol PlexswiftAPI { /// Submit logs to the Log Handler for Plex Media Server /// var log: LogAPI { get } - /// API Calls that perform operations directly against https://Plex.tv - /// - var plex: PlexAPI { get } /// Playlists are ordered collections of media. They can be dumb (just a list of media) or smart (based on a media query, such as "all albums from 2017"). /// They can be organized in (optionally nesting) folders. /// Retrieving a playlist, or its items, will trigger a refresh of its metadata. @@ -91,6 +92,9 @@ public protocol PlexswiftAPI { /// Updates to the status can be observed via the Event API. /// var updater: UpdaterAPI { get } + /// API Calls that perform operations with Plex Media Server Watchlists + /// + var watchlist: WatchlistAPI { get } } // MARK: - ServerAPI @@ -322,6 +326,115 @@ public protocol ButlerAPI { func stopTask(request: Operations.StopTaskRequest) async throws -> Response } +// MARK: - PlexAPI +public enum PlexServers { + +/// Describes the available servers that can be used when making 'getPin' requests. +/// +/// Use this type when making calls to ``PlexAPI/getPin(request:server:)`` to customize the server which is used. + public enum GetPin: Servers, ServerConvertible { + /// Supported server value. + /// + /// Corresponds to `https://plex.tv/api/v2` + case server1 + + /// Defines the raw URL strings for each server option. + /// + /// > Note: You do not need to use these values directly. + /// + /// The available URL strings are defined as: + /// ```swift + /// public static let urlStrings = [ + /// "https://plex.tv/api/v2" + /// ] + /// ``` + public static let urlStrings = [ + "https://plex.tv/api/v2" + ] + + static func `default`() throws -> Server { + return try PlexServers.GetPin.server1.server() + } + + func server() throws -> Server { + switch self { + case .server1: + return try type(of: self).server(at: 0, substituting: nil) + } + } + } + +/// Describes the available servers that can be used when making 'getToken' requests. +/// +/// Use this type when making calls to ``PlexAPI/getToken(request:server:)`` to customize the server which is used. + public enum GetToken: Servers, ServerConvertible { + /// Supported server value. + /// + /// Corresponds to `https://plex.tv/api/v2` + case server1 + + /// Defines the raw URL strings for each server option. + /// + /// > Note: You do not need to use these values directly. + /// + /// The available URL strings are defined as: + /// ```swift + /// public static let urlStrings = [ + /// "https://plex.tv/api/v2" + /// ] + /// ``` + public static let urlStrings = [ + "https://plex.tv/api/v2" + ] + + static func `default`() throws -> Server { + return try PlexServers.GetToken.server1.server() + } + + func server() throws -> Server { + switch self { + case .server1: + return try type(of: self).server(at: 0, substituting: nil) + } + } + } +} + +/// API Calls that perform operations directly against https://Plex.tv +/// +/// +/// ## Topics +/// +/// ### API calls +/// +/// - ``getHomeData()`` +/// - ``getPin(request:server:)`` +/// - ``getToken(request:server:)`` +/// +public protocol PlexAPI { + /// Retrieves the home data for the authenticated user, including details like home ID, name, guest access information, and subscription status. + /// + /// - Returns: A ``Operations/GetHomeDataResponse`` object describing the result of the API operation + /// - Throws: An error of type ``PlexswiftError`` + func getHomeData() async throws -> Response + + /// Retrieve a Pin from Plex.tv for authentication flows + /// + /// - Parameter request: A ``Operations/GetPinRequest`` object describing the input to the API operation + /// - Parameter server: An optional server override to use for this operation + /// - Returns: A ``Operations/GetPinResponse`` object describing the result of the API operation + /// - Throws: An error of type ``PlexswiftError`` + func getPin(request: Operations.GetPinRequest, server: PlexServers.GetPin?) async throws -> Response + + /// Retrieve an Access Token from Plex.tv after the Pin has already been authenticated + /// + /// - Parameter request: A ``Operations/GetTokenRequest`` object describing the input to the API operation + /// - Parameter server: An optional server override to use for this operation + /// - Returns: A ``Operations/GetTokenResponse`` object describing the result of the API operation + /// - Throws: An error of type ``PlexswiftError`` + func getToken(request: Operations.GetTokenRequest, server: PlexServers.GetToken?) async throws -> Response +} + // MARK: - HubsAPI /// Hubs are a structured two-dimensional container for media, generally represented by multiple horizontal rows. @@ -646,108 +759,6 @@ public protocol LogAPI { func enablePaperTrail() async throws -> Response } -// MARK: - PlexAPI -public enum PlexServers { - -/// Describes the available servers that can be used when making 'getPin' requests. -/// -/// Use this type when making calls to ``PlexAPI/getPin(request:server:)`` to customize the server which is used. - public enum GetPin: Servers, ServerConvertible { - /// Supported server value. - /// - /// Corresponds to `https://plex.tv/api/v2` - case server1 - - /// Defines the raw URL strings for each server option. - /// - /// > Note: You do not need to use these values directly. - /// - /// The available URL strings are defined as: - /// ```swift - /// public static let urlStrings = [ - /// "https://plex.tv/api/v2" - /// ] - /// ``` - public static let urlStrings = [ - "https://plex.tv/api/v2" - ] - - static func `default`() throws -> Server { - return try PlexServers.GetPin.server1.server() - } - - func server() throws -> Server { - switch self { - case .server1: - return try type(of: self).server(at: 0, substituting: nil) - } - } - } - -/// Describes the available servers that can be used when making 'getToken' requests. -/// -/// Use this type when making calls to ``PlexAPI/getToken(request:server:)`` to customize the server which is used. - public enum GetToken: Servers, ServerConvertible { - /// Supported server value. - /// - /// Corresponds to `https://plex.tv/api/v2` - case server1 - - /// Defines the raw URL strings for each server option. - /// - /// > Note: You do not need to use these values directly. - /// - /// The available URL strings are defined as: - /// ```swift - /// public static let urlStrings = [ - /// "https://plex.tv/api/v2" - /// ] - /// ``` - public static let urlStrings = [ - "https://plex.tv/api/v2" - ] - - static func `default`() throws -> Server { - return try PlexServers.GetToken.server1.server() - } - - func server() throws -> Server { - switch self { - case .server1: - return try type(of: self).server(at: 0, substituting: nil) - } - } - } -} - -/// API Calls that perform operations directly against https://Plex.tv -/// -/// -/// ## Topics -/// -/// ### API calls -/// -/// - ``getPin(request:server:)`` -/// - ``getToken(request:server:)`` -/// -public protocol PlexAPI { - /// Retrieve a Pin from Plex.tv for authentication flows - /// - /// - Parameter request: A ``Operations/GetPinRequest`` object describing the input to the API operation - /// - Parameter server: An optional server override to use for this operation - /// - Returns: A ``Operations/GetPinResponse`` object describing the result of the API operation - /// - Throws: An error of type ``PlexswiftError`` - func getPin(request: Operations.GetPinRequest, server: PlexServers.GetPin?) async throws -> Response - - /// Retrieve an Access Token from Plex.tv after the Pin has already been authenticated - /// - /// - Parameter request: A ``Operations/GetTokenRequest`` object describing the input to the API operation - /// - Parameter server: An optional server override to use for this operation - /// - Returns: A ``Operations/GetTokenResponse`` object describing the result of the API operation - /// - Throws: An error of type ``PlexswiftError`` - func getToken(request: Operations.GetTokenRequest, server: PlexServers.GetToken?) async throws -> Response -} - // MARK: - PlaylistsAPI /// Playlists are ordered collections of media. They can be dumb (just a list of media) or smart (based on a media query, such as "all albums from 2017"). @@ -978,3 +989,61 @@ public protocol UpdaterAPI { /// - Throws: An error of type ``PlexswiftError`` func applyUpdates(request: Operations.ApplyUpdatesRequest) async throws -> Response } + +// MARK: - WatchlistAPI +public enum WatchlistServers { + +/// Describes the available servers that can be used when making 'getWatchlist' requests. +/// +/// Use this type when making calls to ``WatchlistAPI/getWatchlist(request:server:)`` to customize the server which is used. + public enum GetWatchlist: Servers, ServerConvertible { + /// Supported server value. + /// + /// Corresponds to `https://metadata.provider.plex.tv` + case server1 + + /// Defines the raw URL strings for each server option. + /// + /// > Note: You do not need to use these values directly. + /// + /// The available URL strings are defined as: + /// ```swift + /// public static let urlStrings = [ + /// "https://metadata.provider.plex.tv" + /// ] + /// ``` + public static let urlStrings = [ + "https://metadata.provider.plex.tv" + ] + + static func `default`() throws -> Server { + return try WatchlistServers.GetWatchlist.server1.server() + } + + func server() throws -> Server { + switch self { + case .server1: + return try type(of: self).server(at: 0, substituting: nil) + } + } + } +} + +/// API Calls that perform operations with Plex Media Server Watchlists +/// +/// +/// ## Topics +/// +/// ### API calls +/// +/// - ``getWatchlist(request:server:)`` +/// +public protocol WatchlistAPI { + /// Get User Watchlist + /// + /// - Parameter request: A ``Operations/GetWatchlistRequest`` object describing the input to the API operation + /// - Parameter server: An optional server override to use for this operation + /// - Returns: A ``Operations/GetWatchlistResponse`` object describing the result of the API operation + /// - Throws: An error of type ``PlexswiftError`` + func getWatchlist(request: Operations.GetWatchlistRequest, server: WatchlistServers.GetWatchlist?) async throws -> Response +} diff --git a/Sources/plexswift/internal/api/Client+PlexswiftAPI.swift b/Sources/plexswift/internal/api/Client+PlexswiftAPI.swift index a56505c..ddb8b17 100644 --- a/Sources/plexswift/internal/api/Client+PlexswiftAPI.swift +++ b/Sources/plexswift/internal/api/Client+PlexswiftAPI.swift @@ -27,6 +27,10 @@ extension Client: PlexswiftAPI { return _ButlerAPI(client: self) } + public var plex: PlexAPI { + return _PlexAPI(client: self) + } + public var hubs: HubsAPI { return _HubsAPI(client: self) } @@ -43,10 +47,6 @@ extension Client: PlexswiftAPI { return _LogAPI(client: self) } - public var plex: PlexAPI { - return _PlexAPI(client: self) - } - public var playlists: PlaylistsAPI { return _PlaylistsAPI(client: self) } @@ -66,6 +66,10 @@ extension Client: PlexswiftAPI { public var updater: UpdaterAPI { return _UpdaterAPI(client: self) } + + public var watchlist: WatchlistAPI { + return _WatchlistAPI(client: self) + } } // MARK: - Request Configuration diff --git a/Sources/plexswift/internal/client/URLRequestBuilder.swift b/Sources/plexswift/internal/client/URLRequestBuilder.swift index 7b68db4..068f46f 100644 --- a/Sources/plexswift/internal/client/URLRequestBuilder.swift +++ b/Sources/plexswift/internal/client/URLRequestBuilder.swift @@ -62,7 +62,7 @@ final class URLRequestBuilder: URLRequestConfiguration { urlRequest.setValue(contentType, forHTTPHeaderField: "Content-Type") } - urlRequest.setValue("speakeasy-sdk/swift 0.3.1 2.338.12 0.0.3 plexswift", forHTTPHeaderField: telemetryHeader.headerName) + urlRequest.setValue("speakeasy-sdk/swift 0.4.0 2.342.6 0.0.3 plexswift", forHTTPHeaderField: telemetryHeader.headerName) addSecurityParameters(to: &urlRequest) diff --git a/codeSamples.yaml b/codeSamples.yaml index c1bf09e..670604e 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -3,20 +3,50 @@ info: title: CodeSamples overlay for swift target version: 0.0.0 actions: - - target: $["paths"]["/:/scrobble"]["get"] + - target: $["paths"]["/video/:/transcode/universal/start.mpd"]["get"] update: x-codeSamples: - lang: swift - label: markPlayed + label: startUniversalTranscode + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.video.startUniversalTranscode(\n request: Operations.StartUniversalTranscodeRequest(\n hasMDE: 1, \n mediaIndex: 0, \n partIndex: 0, \n path: \"/library/metadata/23409\", \n `protocol`: \"hls\", \n addDebugOverlay: 0, \n audioBoost: 100, \n autoAdjustQuality: 0, \n directPlay: 0, \n directStream: 0, \n fastSeek: 0, \n location: \"lan\", \n mediaBufferSize: 102400, \n session: \"zvcage8b7rkioqcm8f4uns4c\", \n subtites: \"burn\", \n subtitleSize: 100\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/library/recentlyAdded"]["get"] + update: + x-codeSamples: + - lang: swift + label: getRecentlyAdded source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.media.markPlayed( - request: Operations.MarkPlayedRequest( - key: 59398 + let response = try await client.library.getRecentlyAdded() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/security/resources"]["get"] + update: + x-codeSamples: + - lang: swift + label: getSourceConnectionInformation + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.authentication.getSourceConnectionInformation( + request: Operations.GetSourceConnectionInformationRequest( + source: "server://client-identifier" ) ) @@ -28,24 +58,22 @@ actions: // Handle empty response break } - - target: $["paths"]["/video/:/transcode/universal/start.mpd"]["get"] + - target: $["paths"]["/transcode/sessions/{sessionKey}"]["delete"] update: x-codeSamples: - lang: swift - label: startUniversalTranscode - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.video.startUniversalTranscode(\n request: Operations.StartUniversalTranscodeRequest(\n hasMDE: 1, \n mediaIndex: 0, \n partIndex: 0, \n path: \"/library/metadata/23409\", \n `protocol`: \"hls\", \n addDebugOverlay: 0, \n audioBoost: 100, \n autoAdjustQuality: 0, \n directPlay: 0, \n directStream: 0, \n fastSeek: 0, \n location: \"lan\", \n mediaBufferSize: 102400, \n session: \"zvcage8b7rkioqcm8f4uns4c\", \n subtites: \"burn\", \n subtitleSize: 100\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/butler"]["post"] - update: - x-codeSamples: - - lang: swift - label: startAllTasks + label: stopTranscodeSession source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.butler.startAllTasks() + let response = try await client.sessions.stopTranscodeSession( + request: Operations.StopTranscodeSessionRequest( + sessionKey: "zz7llzqlx8w9vnrsbnwhbmep" + ) + ) switch response.data { case .object(let object): @@ -55,30 +83,24 @@ actions: // Handle empty response break } - - target: $["paths"]["/playlists"]["post"] + - target: $["paths"]["/updater/apply"]["put"] update: x-codeSamples: - lang: swift - label: createPlaylist - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.createPlaylist(\n request: Operations.CreatePlaylistRequest(\n smart: .one, \n title: \"\", \n type: .photo, \n uri: \"https://inborn-brochure.biz\", \n playQueueID: 3686.33\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/playlists/{playlistID}/items"]["put"] + label: applyUpdates + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.updater.applyUpdates(\n request: Operations.ApplyUpdatesRequest(\n skip: .one, \n tonight: .zero\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/activities"]["get"] update: x-codeSamples: - lang: swift - label: addPlaylistContents - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.addPlaylistContents(\n request: Operations.AddPlaylistContentsRequest(\n playlistID: 8502.01, \n uri: \"server://12345/com.plexapp.plugins.library/library/metadata/1\", \n playQueueID: 123\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/identity"]["get"] - update: - x-codeSamples: - - lang: swift - label: getServerIdentity + label: getServerActivities source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.server.getServerIdentity() + let response = try await client.activities.getServerActivities() switch response.data { case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): @@ -91,42 +113,22 @@ actions: // Handle empty response break } - - target: $["paths"]["/myplex/account"]["get"] + - target: $["paths"]["/library/sections/{sectionId}"]["delete"] update: x-codeSamples: - lang: swift - label: getMyPlexAccount + label: deleteLibrary source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.server.getMyPlexAccount() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/butler"]["delete"] - update: - x-codeSamples: - - lang: swift - label: stopAllTasks - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.butler.stopAllTasks() + let response = try await client.library.deleteLibrary( + request: Operations.DeleteLibraryRequest( + sectionId: 1000 + ) + ) switch response.data { case .object(let object): @@ -136,42 +138,18 @@ actions: // Handle empty response break } - - target: $["paths"]["/hubs/search/voice"]["get"] + - target: $["paths"]["/playlists/{playlistID}"]["put"] update: x-codeSamples: - lang: swift - label: performVoiceSearch - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.search.performVoiceSearch(\n request: Operations.PerformVoiceSearchRequest(\n query: \"dead+poop\", \n limit: 5, \n sectionId: 4094.8\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/library/onDeck"]["get"] + label: updatePlaylist + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.updatePlaylist(\n request: Operations.UpdatePlaylistRequest(\n playlistID: 3915, \n summary: \"\", \n title: \"\"\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/security/token"]["get"] update: x-codeSamples: - lang: swift - label: getOnDeck - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.library.getOnDeck() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/log"]["get"] - update: - x-codeSamples: - - lang: swift - label: logLine - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.log.logLine(\n request: Operations.LogLineRequest(\n level: .three, \n message: \"Test log message\", \n source: \"Postman\"\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + label: getTransientToken + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.authentication.getTransientToken(\n request: Operations.GetTransientTokenRequest(\n scope: .all, \n type: .delegation\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - target: $["paths"]["/playlists/{playlistID}"]["get"] update: x-codeSamples: @@ -200,56 +178,178 @@ actions: // Handle empty response break } - - target: $["paths"]["/library/sections/{sectionId}/search"]["get"] + - target: $["paths"]["/playlists/{playlistID}/items"]["get"] update: x-codeSamples: - lang: swift - label: searchLibrary - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.searchLibrary(\n request: Operations.SearchLibraryRequest(\n sectionId: 933505, \n type: .four\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/security/resources"]["get"] + label: getPlaylistContents + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.getPlaylistContents(\n request: Operations.GetPlaylistContentsRequest(\n playlistID: 5004.46, \n type: 9403.59\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/status/sessions"]["get"] update: x-codeSamples: - lang: swift - label: getSourceConnectionInformation + label: getSessions source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.authentication.getSourceConnectionInformation( - request: Operations.GetSourceConnectionInformationRequest( - source: "server://client-identifier" - ) - ) + let response = try await client.sessions.getSessions() switch response.data { - case .object(let object): + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): // Handle response break case .empty: // Handle empty response break } - - target: $["paths"]["/updater/check"]["put"] + - target: $["paths"]["/updater/status"]["get"] update: x-codeSamples: - lang: swift - label: checkForUpdates + label: getUpdateStatus source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.updater.checkForUpdates( - request: Operations.CheckForUpdatesRequest( - download: .one + let response = try await client.updater.getUpdateStatus() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/butler"]["get"] + update: + x-codeSamples: + - lang: swift + label: getButlerTasks + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.butler.getButlerTasks() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/library/sections/{sectionId}/{tag}"]["get"] + update: + x-codeSamples: + - lang: swift + label: getLibraryItems + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.getLibraryItems(\n request: Operations.GetLibraryItemsRequest(\n sectionId: AnyValue(\"\"), \n tag: .genre\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/library/metadata/{ratingKey}"]["get"] + update: + x-codeSamples: + - lang: swift + label: getMetadata + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.library.getMetadata( + request: Operations.GetMetadataRequest( + ratingKey: 8382.31 ) ) switch response.data { - case .object(let object): + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/playlists"]["post"] + update: + x-codeSamples: + - lang: swift + label: createPlaylist + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.createPlaylist(\n request: Operations.CreatePlaylistRequest(\n smart: .one, \n title: \"\", \n type: .photo, \n uri: \"https://inborn-brochure.biz\", \n playQueueID: 3686.33\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/:/timeline"]["get"] + update: + x-codeSamples: + - lang: swift + label: getTimeline + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.video.getTimeline(\n request: Operations.GetTimelineRequest(\n context: \"home:hub.continueWatching\", \n duration: 10000, \n hasMDE: 1, \n key: \"/library/metadata/23409\", \n playBackTime: 2000, \n playQueueItemID: 1, \n ratingKey: 23409, \n row: 1, \n state: .playing, \n time: 2000\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/myplex/account"]["get"] + update: + x-codeSamples: + - lang: swift + label: getMyPlexAccount + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.server.getMyPlexAccount() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/hubs/sections/{sectionId}"]["get"] + update: + x-codeSamples: + - lang: swift + label: getLibraryHubs + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.hubs.getLibraryHubs(\n request: Operations.GetLibraryHubsRequest(\n sectionId: 6728.76, \n count: 9010.22, \n onlyTransient: .zero\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/library/onDeck"]["get"] + update: + x-codeSamples: + - lang: swift + label: getOnDeck + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.library.getOnDeck() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): // Handle response break case .empty: @@ -281,18 +381,172 @@ actions: // Handle empty response break } - - target: $["paths"]["/activities"]["get"] + - target: $["paths"]["/library/sections/{sectionId}/search"]["get"] update: x-codeSamples: - lang: swift - label: getServerActivities + label: searchLibrary + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.searchLibrary(\n request: Operations.SearchLibraryRequest(\n sectionId: 933505, \n type: .four\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/playlists/{playlistID}/items"]["put"] + update: + x-codeSamples: + - lang: swift + label: addPlaylistContents + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.addPlaylistContents(\n request: Operations.AddPlaylistContentsRequest(\n playlistID: 8502.01, \n uri: \"server://12345/com.plexapp.plugins.library/library/metadata/1\", \n playQueueID: 123\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/library/hashes"]["get"] + update: + x-codeSamples: + - lang: swift + label: getFileHash + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.getFileHash(\n request: Operations.GetFileHashRequest(\n url: \"file://C:\\Image.png&type=13\", \n type: 4462.17\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/playlists/{playlistID}"]["delete"] + update: + x-codeSamples: + - lang: swift + label: deletePlaylist source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.activities.getServerActivities() + let response = try await client.playlists.deletePlaylist( + request: Operations.DeletePlaylistRequest( + playlistID: 216.22 + ) + ) + + switch response.data { + case .object(let object): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/:/prefs"]["get"] + update: + x-codeSamples: + - lang: swift + label: getServerPreferences + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.server.getServerPreferences() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/:/progress"]["post"] + update: + x-codeSamples: + - lang: swift + label: updatePlayProgress + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.media.updatePlayProgress(\n request: Operations.UpdatePlayProgressRequest(\n key: \"\", \n state: \"played\", \n time: 90000\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/pins"]["post"] + update: + x-codeSamples: + - lang: swift + label: getPin + source: "import Foundation\nimport Plexswift\n\nlet client = Client()\n\nlet response = try await client.plex.getPin(\n request: Operations.GetPinRequest(\n xPlexProduct: \"Postman\", \n strong: false, \n )\n)\n\nswitch response.data {\ncase .twoHundredAndOneApplicationJsonObject(let twoHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredApplicationJsonObject(let fourHundredApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/identity"]["get"] + update: + x-codeSamples: + - lang: swift + label: getServerIdentity + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.server.getServerIdentity() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/servers"]["get"] + update: + x-codeSamples: + - lang: swift + label: getServerList + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.server.getServerList() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/log"]["post"] + update: + x-codeSamples: + - lang: swift + label: logMultiLine + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.log.logMultiLine() + + switch response.data { + case .object(let object): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/library/sections/watchlist/{filter}"]["get"] + update: + x-codeSamples: + - lang: swift + label: getWatchlist + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.watchlist.getWatchlist(\n request: Operations.GetWatchlistRequest(\n filter: .released, \n xPlexToken: \"\", \n includeCollections: .one, \n includeExternalMedia: .one, \n libtype: .show, \n maxresults: 346553, \n sort: \"\", \n xPlexContainerSize: 406911, \n xPlexContainerStart: 958629\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/"]["get"] + update: + x-codeSamples: + - lang: swift + label: getServerCapabilities + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.server.getServerCapabilities() switch response.data { case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): @@ -329,24 +583,22 @@ actions: // Handle empty response break } - - target: $["paths"]["/playlists/upload"]["post"] + - target: $["paths"]["/library/metadata/{ratingKey}/children"]["get"] update: x-codeSamples: - lang: swift - label: uploadPlaylist - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.uploadPlaylist(\n request: Operations.UploadPlaylistRequest(\n force: .zero, \n path: \"/home/barkley/playlist.m3u\"\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/servers"]["get"] - update: - x-codeSamples: - - lang: swift - label: getServerList + label: getMetadataChildren source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.server.getServerList() + let response = try await client.library.getMetadataChildren( + request: Operations.GetMetadataChildrenRequest( + ratingKey: 1539.14 + ) + ) switch response.data { case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): @@ -359,56 +611,23 @@ actions: // Handle empty response break } - - target: $["paths"]["/activities/{activityUUID}"]["delete"] + - target: $["paths"]["/playlists/{playlistID}/items"]["delete"] update: x-codeSamples: - lang: swift - label: cancelServerActivities + label: clearPlaylistContents source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.activities.cancelServerActivities( - request: Operations.CancelServerActivitiesRequest( - activityUUID: "25b71ed5-0f9d-461c-baa7-d404e9e10d3e" + let response = try await client.playlists.clearPlaylistContents( + request: Operations.ClearPlaylistContentsRequest( + playlistID: 1893.18 ) ) - switch response.data { - case .object(let object): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/library/sections/{sectionId}/{tag}"]["get"] - update: - x-codeSamples: - - lang: swift - label: getLibraryItems - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.getLibraryItems(\n request: Operations.GetLibraryItemsRequest(\n sectionId: 1, \n tag: .genre\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/playlists"]["get"] - update: - x-codeSamples: - - lang: swift - label: getPlaylists - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.getPlaylists(\n request: Operations.GetPlaylistsRequest(\n playlistType: .audio, \n smart: .zero\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/log/networked"]["get"] - update: - x-codeSamples: - - lang: swift - label: enablePaperTrail - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.log.enablePaperTrail() - switch response.data { case .object(let object): // Handle response @@ -445,64 +664,18 @@ actions: // Handle empty response break } - - target: $["paths"]["/updater/status"]["get"] + - target: $["paths"]["/butler"]["post"] update: x-codeSamples: - lang: swift - label: getUpdateStatus + label: startAllTasks source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.updater.getUpdateStatus() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/pins/{pinID}"]["get"] - update: - x-codeSamples: - - lang: swift - label: getToken - source: "import Foundation\nimport Plexswift\n\nlet client = Client()\n\nlet response = try await client.plex.getToken(\n request: Operations.GetTokenRequest(\n pinID: \"\", \n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/playlists/{playlistID}/items"]["get"] - update: - x-codeSamples: - - lang: swift - label: getPlaylistContents - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.getPlaylistContents(\n request: Operations.GetPlaylistContentsRequest(\n playlistID: 5004.46, \n type: 9403.59\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/hubs/sections/{sectionId}"]["get"] - update: - x-codeSamples: - - lang: swift - label: getLibraryHubs - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.hubs.getLibraryHubs(\n request: Operations.GetLibraryHubsRequest(\n sectionId: 6728.76, \n count: 9010.22, \n onlyTransient: .zero\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/library/sections/{sectionId}"]["delete"] - update: - x-codeSamples: - - lang: swift - label: deleteLibrary - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.library.deleteLibrary( - request: Operations.DeleteLibraryRequest( - sectionId: 1000 - ) - ) + let response = try await client.butler.startAllTasks() switch response.data { case .object(let object): @@ -512,36 +685,6 @@ actions: // Handle empty response break } - - target: $["paths"]["/security/token"]["get"] - update: - x-codeSamples: - - lang: swift - label: getTransientToken - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.authentication.getTransientToken(\n request: Operations.GetTransientTokenRequest(\n scope: .all, \n type: .delegation\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/clients"]["get"] - update: - x-codeSamples: - - lang: swift - label: getAvailableClients - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.server.getAvailableClients() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - target: $["paths"]["/butler/{taskName}"]["post"] update: x-codeSamples: @@ -567,22 +710,18 @@ actions: // Handle empty response break } - - target: $["paths"]["/playlists/{playlistID}/items"]["delete"] + - target: $["paths"]["/log/networked"]["get"] update: x-codeSamples: - lang: swift - label: clearPlaylistContents + label: enablePaperTrail source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.playlists.clearPlaylistContents( - request: Operations.ClearPlaylistContentsRequest( - playlistID: 1893.18 - ) - ) + let response = try await client.log.enablePaperTrail() switch response.data { case .object(let object): @@ -592,6 +731,24 @@ actions: // Handle empty response break } + - target: $["paths"]["/playlists/upload"]["post"] + update: + x-codeSamples: + - lang: swift + label: uploadPlaylist + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.uploadPlaylist(\n request: Operations.UploadPlaylistRequest(\n force: .zero, \n path: \"/home/barkley/playlist.m3u\"\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/hubs"]["get"] + update: + x-codeSamples: + - lang: swift + label: getGlobalHubs + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.hubs.getGlobalHubs(\n request: Operations.GetGlobalHubsRequest(\n count: 1262.49, \n onlyTransient: .one\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/hubs/search/voice"]["get"] + update: + x-codeSamples: + - lang: swift + label: performVoiceSearch + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.search.performVoiceSearch(\n request: Operations.PerformVoiceSearchRequest(\n query: \"dead+poop\", \n limit: 5, \n sectionId: 4094.8\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - target: $["paths"]["/status/sessions/history/all"]["get"] update: x-codeSamples: @@ -616,20 +773,44 @@ actions: // Handle empty response break } - - target: $["paths"]["/transcode/sessions/{sessionKey}"]["delete"] + - target: $["paths"]["/clients"]["get"] update: x-codeSamples: - lang: swift - label: stopTranscodeSession + label: getAvailableClients source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.sessions.stopTranscodeSession( - request: Operations.StopTranscodeSessionRequest( - sessionKey: "zz7llzqlx8w9vnrsbnwhbmep" + let response = try await client.server.getAvailableClients() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/:/scrobble"]["get"] + update: + x-codeSamples: + - lang: swift + label: markPlayed + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.media.markPlayed( + request: Operations.MarkPlayedRequest( + key: 59398 ) ) @@ -641,92 +822,139 @@ actions: // Handle empty response break } - - target: $["paths"]["/hubs"]["get"] + - target: $["paths"]["/butler/{taskName}"]["delete"] update: x-codeSamples: - lang: swift - label: getGlobalHubs - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.hubs.getGlobalHubs(\n request: Operations.GetGlobalHubsRequest(\n count: 1262.49, \n onlyTransient: .one\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + label: stopTask + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.butler.stopTask( + request: Operations.StopTaskRequest( + taskName: .backupDatabase + ) + ) + + switch response.data { + case .object(let object): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/home"]["get"] + update: + x-codeSamples: + - lang: swift + label: getHomeData + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.plex.getHomeData() + + switch response.data { + case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): + // Handle response + break + case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/activities/{activityUUID}"]["delete"] + update: + x-codeSamples: + - lang: swift + label: cancelServerActivities + source: |- + import Foundation + import Plexswift + + let client = Client(security: .accessToken("")) + + let response = try await client.activities.cancelServerActivities( + request: Operations.CancelServerActivitiesRequest( + activityUUID: "25b71ed5-0f9d-461c-baa7-d404e9e10d3e" + ) + ) + + switch response.data { + case .object(let object): + // Handle response + break + case .empty: + // Handle empty response + break + } + - target: $["paths"]["/hubs/search"]["get"] + update: + x-codeSamples: + - lang: swift + label: performSearch + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.search.performSearch(\n request: Operations.PerformSearchRequest(\n query: \"dylan\", \n limit: 5, \n sectionId: 1516.53\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - target: $["paths"]["/library/sections/{sectionId}"]["get"] update: x-codeSamples: - lang: swift label: getLibrary source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.getLibrary(\n request: Operations.GetLibraryRequest(\n sectionId: 1000, \n includeDetails: .zero\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/pins"]["post"] + - target: $["paths"]["/log"]["get"] update: x-codeSamples: - lang: swift - label: getPin - source: "import Foundation\nimport Plexswift\n\nlet client = Client()\n\nlet response = try await client.plex.getPin(\n request: Operations.GetPinRequest(\n strong: false, \n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredApplicationJsonObject(let fourHundredApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/status/sessions"]["get"] + label: logLine + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.log.logLine(\n request: Operations.LogLineRequest(\n level: .three, \n message: \"Test log message\", \n source: \"Postman\"\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/butler"]["delete"] update: x-codeSamples: - lang: swift - label: getSessions + label: stopAllTasks source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.sessions.getSessions() + let response = try await client.butler.stopAllTasks() switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): + case .object(let object): // Handle response break case .empty: // Handle empty response break } - - target: $["paths"]["/:/prefs"]["get"] + - target: $["paths"]["/pins/{pinID}"]["get"] update: x-codeSamples: - lang: swift - label: getServerPreferences + label: getToken + source: "import Foundation\nimport Plexswift\n\nlet client = Client()\n\nlet response = try await client.plex.getToken(\n request: Operations.GetTokenRequest(\n pinID: \"\", \n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredApplicationJsonObject(let fourHundredApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/updater/check"]["put"] + update: + x-codeSamples: + - lang: swift + label: checkForUpdates source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.server.getServerPreferences() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/:/progress"]["post"] - update: - x-codeSamples: - - lang: swift - label: updatePlayProgress - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.media.updatePlayProgress(\n request: Operations.UpdatePlayProgressRequest(\n key: \"\", \n state: \"played\", \n time: 90000\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/library/sections/{sectionId}/refresh"]["get"] - update: - x-codeSamples: - - lang: swift - label: refreshLibrary - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.library.refreshLibrary( - request: Operations.RefreshLibraryRequest( - sectionId: 934.16 + let response = try await client.updater.checkForUpdates( + request: Operations.CheckForUpdatesRequest( + download: .one ) ) @@ -738,111 +966,30 @@ actions: // Handle empty response break } - - target: $["paths"]["/library/metadata/{ratingKey}"]["get"] + - target: $["paths"]["/photo/:/transcode"]["get"] update: x-codeSamples: - lang: swift - label: getMetadata + label: getResizedPhoto + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.server.getResizedPhoto(\n request: Operations.GetResizedPhotoRequest(\n blur: 20, \n height: 165, \n minSize: .one, \n opacity: 96541, \n upscale: .zero, \n url: \"/library/metadata/49564/thumb/1654258204\", \n width: 110\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/playlists"]["get"] + update: + x-codeSamples: + - lang: swift + label: getPlaylists + source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.getPlaylists(\n request: Operations.GetPlaylistsRequest(\n playlistType: .audio, \n smart: .zero\n )\n)\n\nswitch response.data {\ncase .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject):\n // Handle response\n break\ncase .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" + - target: $["paths"]["/transcode/sessions"]["get"] + update: + x-codeSamples: + - lang: swift + label: getTranscodeSessions source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.library.getMetadata( - request: Operations.GetMetadataRequest( - ratingKey: 8382.31 - ) - ) - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/playlists/{playlistID}"]["delete"] - update: - x-codeSamples: - - lang: swift - label: deletePlaylist - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.playlists.deletePlaylist( - request: Operations.DeletePlaylistRequest( - playlistID: 216.22 - ) - ) - - switch response.data { - case .object(let object): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/playlists/{playlistID}"]["put"] - update: - x-codeSamples: - - lang: swift - label: updatePlaylist - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.playlists.updatePlaylist(\n request: Operations.UpdatePlaylistRequest(\n playlistID: 3915, \n summary: \"\", \n title: \"\"\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/:/timeline"]["get"] - update: - x-codeSamples: - - lang: swift - label: getTimeline - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.video.getTimeline(\n request: Operations.GetTimelineRequest(\n context: \"home:hub.continueWatching\", \n duration: 10000, \n hasMDE: 1, \n key: \"/library/metadata/23409\", \n playBackTime: 2000, \n playQueueItemID: 1, \n ratingKey: 23409, \n row: 1, \n state: .playing, \n time: 2000\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/search"]["get"] - update: - x-codeSamples: - - lang: swift - label: getSearchResults - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.search.getSearchResults( - request: Operations.GetSearchResultsRequest( - query: "110" - ) - ) - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/"]["get"] - update: - x-codeSamples: - - lang: swift - label: getServerCapabilities - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.server.getServerCapabilities() + let response = try await client.sessions.getTranscodeSessions() switch response.data { case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): @@ -879,92 +1026,20 @@ actions: // Handle empty response break } - - target: $["paths"]["/photo/:/transcode"]["get"] + - target: $["paths"]["/search"]["get"] update: x-codeSamples: - lang: swift - label: getResizedPhoto - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.server.getResizedPhoto(\n request: Operations.GetResizedPhotoRequest(\n blur: 20, \n height: 165, \n minSize: .one, \n opacity: 96541, \n upscale: .zero, \n url: \"/library/metadata/49564/thumb/1654258204\", \n width: 110\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/hubs/search"]["get"] - update: - x-codeSamples: - - lang: swift - label: performSearch - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.search.performSearch(\n request: Operations.PerformSearchRequest(\n query: \"dylan\", \n limit: 5, \n sectionId: 1516.53\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/library/recentlyAdded"]["get"] - update: - x-codeSamples: - - lang: swift - label: getRecentlyAdded + label: getSearchResults source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.library.getRecentlyAdded() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/transcode/sessions"]["get"] - update: - x-codeSamples: - - lang: swift - label: getTranscodeSessions - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.sessions.getTranscodeSessions() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/updater/apply"]["put"] - update: - x-codeSamples: - - lang: swift - label: applyUpdates - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.updater.applyUpdates(\n request: Operations.ApplyUpdatesRequest(\n skip: .one, \n tonight: .zero\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/library/hashes"]["get"] - update: - x-codeSamples: - - lang: swift - label: getFileHash - source: "import Foundation\nimport Plexswift\n\nlet client = Client(security: .accessToken(\"\"))\n\nlet response = try await client.library.getFileHash(\n request: Operations.GetFileHashRequest(\n url: \"file://C:\\Image.png&type=13\", \n type: 4462.17\n )\n)\n\nswitch response.data {\ncase .object(let object):\n // Handle response\n break\ncase .empty:\n // Handle empty response\n break\n}" - - target: $["paths"]["/library/metadata/{ratingKey}/children"]["get"] - update: - x-codeSamples: - - lang: swift - label: getMetadataChildren - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.library.getMetadataChildren( - request: Operations.GetMetadataChildrenRequest( - ratingKey: 1539.14 + let response = try await client.search.getSearchResults( + request: Operations.GetSearchResultsRequest( + query: "110" ) ) @@ -979,65 +1054,20 @@ actions: // Handle empty response break } - - target: $["paths"]["/log"]["post"] + - target: $["paths"]["/library/sections/{sectionId}/refresh"]["get"] update: x-codeSamples: - lang: swift - label: logMultiLine + label: refreshLibrary source: |- import Foundation import Plexswift let client = Client(security: .accessToken("")) - let response = try await client.log.logMultiLine() - - switch response.data { - case .object(let object): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/butler"]["get"] - update: - x-codeSamples: - - lang: swift - label: getButlerTasks - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.butler.getButlerTasks() - - switch response.data { - case .twoHundredApplicationJsonObject(let twoHundredApplicationJsonObject): - // Handle response - break - case .fourHundredAndOneApplicationJsonObject(let fourHundredAndOneApplicationJsonObject): - // Handle response - break - case .empty: - // Handle empty response - break - } - - target: $["paths"]["/butler/{taskName}"]["delete"] - update: - x-codeSamples: - - lang: swift - label: stopTask - source: |- - import Foundation - import Plexswift - - let client = Client(security: .accessToken("")) - - let response = try await client.butler.stopTask( - request: Operations.StopTaskRequest( - taskName: .backupDatabase + let response = try await client.library.refreshLibrary( + request: Operations.RefreshLibraryRequest( + sectionId: 934.16 ) )