Regeneration

This commit is contained in:
Luke Hagar
2024-04-11 11:10:38 -05:00
parent 5c1a849e2e
commit d4c7b32e80
502 changed files with 25175 additions and 22 deletions

View File

@@ -0,0 +1,74 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Client: PlexswiftAPI {
// MARK: - Root operations
// MARK: - Scoped API operations
public var server: ServerAPI {
return _ServerAPI(client: self)
}
public var media: MediaAPI {
return _MediaAPI(client: self)
}
public var video: VideoAPI {
return _VideoAPI(client: self)
}
public var activities: ActivitiesAPI {
return _ActivitiesAPI(client: self)
}
public var butler: ButlerAPI {
return _ButlerAPI(client: self)
}
public var hubs: HubsAPI {
return _HubsAPI(client: self)
}
public var search: SearchAPI {
return _SearchAPI(client: self)
}
public var library: LibraryAPI {
return _LibraryAPI(client: self)
}
public var log: LogAPI {
return _LogAPI(client: self)
}
public var plex: PlexAPI {
return _PlexAPI(client: self)
}
public var playlists: PlaylistsAPI {
return _PlaylistsAPI(client: self)
}
public var authentication: AuthenticationAPI {
return _AuthenticationAPI(client: self)
}
public var statistics: StatisticsAPI {
return _StatisticsAPI(client: self)
}
public var sessions: SessionsAPI {
return _SessionsAPI(client: self)
}
public var updater: UpdaterAPI {
return _UpdaterAPI(client: self)
}
}
// MARK: - Request Configuration
// MARK: - Response Handlers

View File

@@ -0,0 +1,93 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _ActivitiesAPI: ActivitiesAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func getServerActivities() async throws -> Response<Operations.GetServerActivitiesResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetServerActivitiesRequest(with: configuration)
},
handleResponse: handleGetServerActivitiesResponse
)
}
public func cancelServerActivities(request: Operations.CancelServerActivitiesRequest) async throws -> Response<Operations.CancelServerActivitiesResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureCancelServerActivitiesRequest(with: configuration, request: request)
},
handleResponse: handleCancelServerActivitiesResponse
)
}
}
// MARK: - Request Configuration
private func configureGetServerActivitiesRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/activities"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
private func configureCancelServerActivitiesRequest(with configuration: URLRequestConfiguration, request: Operations.CancelServerActivitiesRequest) throws {
configuration.path = "/activities/{activityUUID}"
configuration.method = .delete
configuration.pathParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handleGetServerActivitiesResponse(response: Client.APIResponse) throws -> Operations.GetServerActivitiesResponse {
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.GetServerActivitiesResponseBody.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.GetServerActivitiesActivitiesResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleCancelServerActivitiesResponse(response: Client.APIResponse) throws -> Operations.CancelServerActivitiesResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.CancelServerActivitiesResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,86 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _AuthenticationAPI: AuthenticationAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func getTransientToken(request: Operations.GetTransientTokenRequest) async throws -> Response<Operations.GetTransientTokenResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetTransientTokenRequest(with: configuration, request: request)
},
handleResponse: handleGetTransientTokenResponse
)
}
public func getSourceConnectionInformation(request: Operations.GetSourceConnectionInformationRequest) async throws -> Response<Operations.GetSourceConnectionInformationResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetSourceConnectionInformationRequest(with: configuration, request: request)
},
handleResponse: handleGetSourceConnectionInformationResponse
)
}
}
// MARK: - Request Configuration
private func configureGetTransientTokenRequest(with configuration: URLRequestConfiguration, request: Operations.GetTransientTokenRequest) throws {
configuration.path = "/security/token"
configuration.method = .get
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureGetSourceConnectionInformationRequest(with configuration: URLRequestConfiguration, request: Operations.GetSourceConnectionInformationRequest) throws {
configuration.path = "/security/resources"
configuration.method = .get
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handleGetTransientTokenResponse(response: Client.APIResponse) throws -> Operations.GetTransientTokenResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.GetTransientTokenResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetSourceConnectionInformationResponse(response: Client.APIResponse) throws -> Operations.GetSourceConnectionInformationResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.GetSourceConnectionInformationResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,193 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _ButlerAPI: ButlerAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func getButlerTasks() async throws -> Response<Operations.GetButlerTasksResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetButlerTasksRequest(with: configuration)
},
handleResponse: handleGetButlerTasksResponse
)
}
public func startAllTasks() async throws -> Response<Operations.StartAllTasksResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureStartAllTasksRequest(with: configuration)
},
handleResponse: handleStartAllTasksResponse
)
}
public func stopAllTasks() async throws -> Response<Operations.StopAllTasksResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureStopAllTasksRequest(with: configuration)
},
handleResponse: handleStopAllTasksResponse
)
}
public func startTask(request: Operations.StartTaskRequest) async throws -> Response<Operations.StartTaskResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureStartTaskRequest(with: configuration, request: request)
},
handleResponse: handleStartTaskResponse
)
}
public func stopTask(request: Operations.StopTaskRequest) async throws -> Response<Operations.StopTaskResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureStopTaskRequest(with: configuration, request: request)
},
handleResponse: handleStopTaskResponse
)
}
}
// MARK: - Request Configuration
private func configureGetButlerTasksRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/butler"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
private func configureStartAllTasksRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/butler"
configuration.method = .post
configuration.telemetryHeader = .userAgent
}
private func configureStopAllTasksRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/butler"
configuration.method = .delete
configuration.telemetryHeader = .userAgent
}
private func configureStartTaskRequest(with configuration: URLRequestConfiguration, request: Operations.StartTaskRequest) throws {
configuration.path = "/butler/{taskName}"
configuration.method = .post
configuration.pathParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureStopTaskRequest(with configuration: URLRequestConfiguration, request: Operations.StopTaskRequest) throws {
configuration.path = "/butler/{taskName}"
configuration.method = .delete
configuration.pathParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handleGetButlerTasksResponse(response: Client.APIResponse) throws -> Operations.GetButlerTasksResponse {
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.GetButlerTasksResponseBody.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.GetButlerTasksButlerResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleStartAllTasksResponse(response: Client.APIResponse) throws -> Operations.StartAllTasksResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.StartAllTasksResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleStopAllTasksResponse(response: Client.APIResponse) throws -> Operations.StopAllTasksResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.StopAllTasksResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleStartTaskResponse(response: Client.APIResponse) throws -> Operations.StartTaskResponse {
let httpResponse = response.httpResponse
if [200, 202, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.StartTaskResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleStopTaskResponse(response: Client.APIResponse) throws -> Operations.StopTaskResponse {
let httpResponse = response.httpResponse
if [200, 400, 404].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.StopTaskResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,103 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _HubsAPI: HubsAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func getGlobalHubs(request: Operations.GetGlobalHubsRequest) async throws -> Response<Operations.GetGlobalHubsResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetGlobalHubsRequest(with: configuration, request: request)
},
handleResponse: handleGetGlobalHubsResponse
)
}
public func getLibraryHubs(request: Operations.GetLibraryHubsRequest) async throws -> Response<Operations.GetLibraryHubsResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetLibraryHubsRequest(with: configuration, request: request)
},
handleResponse: handleGetLibraryHubsResponse
)
}
}
// MARK: - Request Configuration
private func configureGetGlobalHubsRequest(with configuration: URLRequestConfiguration, request: Operations.GetGlobalHubsRequest) throws {
configuration.path = "/hubs"
configuration.method = .get
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureGetLibraryHubsRequest(with configuration: URLRequestConfiguration, request: Operations.GetLibraryHubsRequest) throws {
configuration.path = "/hubs/sections/{sectionId}"
configuration.method = .get
configuration.pathParameterSerializable = request
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handleGetGlobalHubsResponse(response: Client.APIResponse) throws -> Operations.GetGlobalHubsResponse {
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.GetGlobalHubsResponseBody.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.GetGlobalHubsHubsResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetLibraryHubsResponse(response: Client.APIResponse) throws -> Operations.GetLibraryHubsResponse {
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.GetLibraryHubsResponseBody.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.GetLibraryHubsHubsResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,435 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _LibraryAPI: LibraryAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func getFileHash(request: Operations.GetFileHashRequest) async throws -> Response<Operations.GetFileHashResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetFileHashRequest(with: configuration, request: request)
},
handleResponse: handleGetFileHashResponse
)
}
public func getRecentlyAdded() async throws -> Response<Operations.GetRecentlyAddedResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetRecentlyAddedRequest(with: configuration)
},
handleResponse: handleGetRecentlyAddedResponse
)
}
public func getLibraries() async throws -> Response<Operations.GetLibrariesResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetLibrariesRequest(with: configuration)
},
handleResponse: handleGetLibrariesResponse
)
}
public func getLibrary(request: Operations.GetLibraryRequest) async throws -> Response<Operations.GetLibraryResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetLibraryRequest(with: configuration, request: request)
},
handleResponse: handleGetLibraryResponse
)
}
public func deleteLibrary(request: Operations.DeleteLibraryRequest) async throws -> Response<Operations.DeleteLibraryResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureDeleteLibraryRequest(with: configuration, request: request)
},
handleResponse: handleDeleteLibraryResponse
)
}
public func getLibraryItems(request: Operations.GetLibraryItemsRequest) async throws -> Response<Operations.GetLibraryItemsResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetLibraryItemsRequest(with: configuration, request: request)
},
handleResponse: handleGetLibraryItemsResponse
)
}
public func refreshLibrary(request: Operations.RefreshLibraryRequest) async throws -> Response<Operations.RefreshLibraryResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureRefreshLibraryRequest(with: configuration, request: request)
},
handleResponse: handleRefreshLibraryResponse
)
}
public func searchLibrary(request: Operations.SearchLibraryRequest) async throws -> Response<Operations.SearchLibraryResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureSearchLibraryRequest(with: configuration, request: request)
},
handleResponse: handleSearchLibraryResponse
)
}
public func getMetadata(request: Operations.GetMetadataRequest) async throws -> Response<Operations.GetMetadataResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetMetadataRequest(with: configuration, request: request)
},
handleResponse: handleGetMetadataResponse
)
}
public func getMetadataChildren(request: Operations.GetMetadataChildrenRequest) async throws -> Response<Operations.GetMetadataChildrenResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetMetadataChildrenRequest(with: configuration, request: request)
},
handleResponse: handleGetMetadataChildrenResponse
)
}
public func getOnDeck() async throws -> Response<Operations.GetOnDeckResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetOnDeckRequest(with: configuration)
},
handleResponse: handleGetOnDeckResponse
)
}
}
// MARK: - Request Configuration
private func configureGetFileHashRequest(with configuration: URLRequestConfiguration, request: Operations.GetFileHashRequest) throws {
configuration.path = "/library/hashes"
configuration.method = .get
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureGetRecentlyAddedRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/library/recentlyAdded"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
private func configureGetLibrariesRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/library/sections"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
private func configureGetLibraryRequest(with configuration: URLRequestConfiguration, request: Operations.GetLibraryRequest) throws {
configuration.path = "/library/sections/{sectionId}"
configuration.method = .get
configuration.pathParameterSerializable = request
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureDeleteLibraryRequest(with configuration: URLRequestConfiguration, request: Operations.DeleteLibraryRequest) throws {
configuration.path = "/library/sections/{sectionId}"
configuration.method = .delete
configuration.pathParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureGetLibraryItemsRequest(with configuration: URLRequestConfiguration, request: Operations.GetLibraryItemsRequest) throws {
configuration.path = "/library/sections/{sectionId}/{tag}"
configuration.method = .get
configuration.pathParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureRefreshLibraryRequest(with configuration: URLRequestConfiguration, request: Operations.RefreshLibraryRequest) throws {
configuration.path = "/library/sections/{sectionId}/refresh"
configuration.method = .get
configuration.pathParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureSearchLibraryRequest(with configuration: URLRequestConfiguration, request: Operations.SearchLibraryRequest) throws {
configuration.path = "/library/sections/{sectionId}/search"
configuration.method = .get
configuration.pathParameterSerializable = request
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureGetMetadataRequest(with configuration: URLRequestConfiguration, request: Operations.GetMetadataRequest) throws {
configuration.path = "/library/metadata/{ratingKey}"
configuration.method = .get
configuration.pathParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureGetMetadataChildrenRequest(with configuration: URLRequestConfiguration, request: Operations.GetMetadataChildrenRequest) throws {
configuration.path = "/library/metadata/{ratingKey}/children"
configuration.method = .get
configuration.pathParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureGetOnDeckRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/library/onDeck"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handleGetFileHashResponse(response: Client.APIResponse) throws -> Operations.GetFileHashResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.GetFileHashResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetRecentlyAddedResponse(response: Client.APIResponse) throws -> Operations.GetRecentlyAddedResponse {
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.GetRecentlyAddedResponseBody.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.GetRecentlyAddedLibraryResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetLibrariesResponse(response: Client.APIResponse) throws -> Operations.GetLibrariesResponse {
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.GetLibrariesResponseBody.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.GetLibrariesLibraryResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetLibraryResponse(response: Client.APIResponse) throws -> Operations.GetLibraryResponse {
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.GetLibraryResponseBody.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.GetLibraryLibraryResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleDeleteLibraryResponse(response: Client.APIResponse) throws -> Operations.DeleteLibraryResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.DeleteLibraryResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetLibraryItemsResponse(response: Client.APIResponse) throws -> Operations.GetLibraryItemsResponse {
let httpResponse = response.httpResponse
if httpResponse.statusCode == 200 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.GetLibraryItemsResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleRefreshLibraryResponse(response: Client.APIResponse) throws -> Operations.RefreshLibraryResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.RefreshLibraryResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleSearchLibraryResponse(response: Client.APIResponse) throws -> Operations.SearchLibraryResponse {
let httpResponse = response.httpResponse
if httpResponse.statusCode == 200 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.SearchLibraryResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetMetadataResponse(response: Client.APIResponse) throws -> Operations.GetMetadataResponse {
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.GetMetadataResponseBody.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.GetMetadataLibraryResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetMetadataChildrenResponse(response: Client.APIResponse) throws -> Operations.GetMetadataChildrenResponse {
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.GetMetadataChildrenResponseBody.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.GetMetadataChildrenLibraryResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetOnDeckResponse(response: Client.APIResponse) throws -> Operations.GetOnDeckResponse {
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.GetOnDeckResponseBody.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.GetOnDeckLibraryResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,123 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _LogAPI: LogAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func logLine(request: Operations.LogLineRequest) async throws -> Response<Operations.LogLineResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureLogLineRequest(with: configuration, request: request)
},
handleResponse: handleLogLineResponse
)
}
public func logMultiLine(request: String) async throws -> Response<Operations.LogMultiLineResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureLogMultiLineRequest(with: configuration, request: request)
},
handleResponse: handleLogMultiLineResponse
)
}
public func enablePaperTrail() async throws -> Response<Operations.EnablePaperTrailResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureEnablePaperTrailRequest(with: configuration)
},
handleResponse: handleEnablePaperTrailResponse
)
}
}
// MARK: - Request Configuration
private func configureLogLineRequest(with configuration: URLRequestConfiguration, request: Operations.LogLineRequest) throws {
configuration.path = "/log"
configuration.method = .get
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureLogMultiLineRequest(with configuration: URLRequestConfiguration, request: String) throws {
configuration.path = "/log"
configuration.method = .post
configuration.contentType = "text/plain"
configuration.body = request.data(using: .utf8)
if configuration.body == nil {
throw SerializationError.missingRequiredRequestBody
}
configuration.telemetryHeader = .userAgent
}
private func configureEnablePaperTrailRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/log/networked"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handleLogLineResponse(response: Client.APIResponse) throws -> Operations.LogLineResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.LogLineResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleLogMultiLineResponse(response: Client.APIResponse) throws -> Operations.LogMultiLineResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.LogMultiLineResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleEnablePaperTrailResponse(response: Client.APIResponse) throws -> Operations.EnablePaperTrailResponse {
let httpResponse = response.httpResponse
if [200, 400, 403].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.EnablePaperTrailResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,120 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _MediaAPI: MediaAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func markPlayed(request: Operations.MarkPlayedRequest) async throws -> Response<Operations.MarkPlayedResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureMarkPlayedRequest(with: configuration, request: request)
},
handleResponse: handleMarkPlayedResponse
)
}
public func markUnplayed(request: Operations.MarkUnplayedRequest) async throws -> Response<Operations.MarkUnplayedResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureMarkUnplayedRequest(with: configuration, request: request)
},
handleResponse: handleMarkUnplayedResponse
)
}
public func updatePlayProgress(request: Operations.UpdatePlayProgressRequest) async throws -> Response<Operations.UpdatePlayProgressResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureUpdatePlayProgressRequest(with: configuration, request: request)
},
handleResponse: handleUpdatePlayProgressResponse
)
}
}
// MARK: - Request Configuration
private func configureMarkPlayedRequest(with configuration: URLRequestConfiguration, request: Operations.MarkPlayedRequest) throws {
configuration.path = "/:/scrobble"
configuration.method = .get
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureMarkUnplayedRequest(with configuration: URLRequestConfiguration, request: Operations.MarkUnplayedRequest) throws {
configuration.path = "/:/unscrobble"
configuration.method = .get
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureUpdatePlayProgressRequest(with configuration: URLRequestConfiguration, request: Operations.UpdatePlayProgressRequest) throws {
configuration.path = "/:/progress"
configuration.method = .post
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handleMarkPlayedResponse(response: Client.APIResponse) throws -> Operations.MarkPlayedResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.MarkPlayedResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleMarkUnplayedResponse(response: Client.APIResponse) throws -> Operations.MarkUnplayedResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.MarkUnplayedResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleUpdatePlayProgressResponse(response: Client.APIResponse) throws -> Operations.UpdatePlayProgressResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.UpdatePlayProgressResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,367 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _PlaylistsAPI: PlaylistsAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func createPlaylist(request: Operations.CreatePlaylistRequest) async throws -> Response<Operations.CreatePlaylistResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureCreatePlaylistRequest(with: configuration, request: request)
},
handleResponse: handleCreatePlaylistResponse
)
}
public func getPlaylists(request: Operations.GetPlaylistsRequest) async throws -> Response<Operations.GetPlaylistsResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetPlaylistsRequest(with: configuration, request: request)
},
handleResponse: handleGetPlaylistsResponse
)
}
public func getPlaylist(request: Operations.GetPlaylistRequest) async throws -> Response<Operations.GetPlaylistResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetPlaylistRequest(with: configuration, request: request)
},
handleResponse: handleGetPlaylistResponse
)
}
public func deletePlaylist(request: Operations.DeletePlaylistRequest) async throws -> Response<Operations.DeletePlaylistResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureDeletePlaylistRequest(with: configuration, request: request)
},
handleResponse: handleDeletePlaylistResponse
)
}
public func updatePlaylist(request: Operations.UpdatePlaylistRequest) async throws -> Response<Operations.UpdatePlaylistResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureUpdatePlaylistRequest(with: configuration, request: request)
},
handleResponse: handleUpdatePlaylistResponse
)
}
public func getPlaylistContents(request: Operations.GetPlaylistContentsRequest) async throws -> Response<Operations.GetPlaylistContentsResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetPlaylistContentsRequest(with: configuration, request: request)
},
handleResponse: handleGetPlaylistContentsResponse
)
}
public func clearPlaylistContents(request: Operations.ClearPlaylistContentsRequest) async throws -> Response<Operations.ClearPlaylistContentsResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureClearPlaylistContentsRequest(with: configuration, request: request)
},
handleResponse: handleClearPlaylistContentsResponse
)
}
public func addPlaylistContents(request: Operations.AddPlaylistContentsRequest) async throws -> Response<Operations.AddPlaylistContentsResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureAddPlaylistContentsRequest(with: configuration, request: request)
},
handleResponse: handleAddPlaylistContentsResponse
)
}
public func uploadPlaylist(request: Operations.UploadPlaylistRequest) async throws -> Response<Operations.UploadPlaylistResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureUploadPlaylistRequest(with: configuration, request: request)
},
handleResponse: handleUploadPlaylistResponse
)
}
}
// MARK: - Request Configuration
private func configureCreatePlaylistRequest(with configuration: URLRequestConfiguration, request: Operations.CreatePlaylistRequest) throws {
configuration.path = "/playlists"
configuration.method = .post
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureGetPlaylistsRequest(with configuration: URLRequestConfiguration, request: Operations.GetPlaylistsRequest) throws {
configuration.path = "/playlists"
configuration.method = .get
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureGetPlaylistRequest(with configuration: URLRequestConfiguration, request: Operations.GetPlaylistRequest) throws {
configuration.path = "/playlists/{playlistID}"
configuration.method = .get
configuration.pathParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureDeletePlaylistRequest(with configuration: URLRequestConfiguration, request: Operations.DeletePlaylistRequest) throws {
configuration.path = "/playlists/{playlistID}"
configuration.method = .delete
configuration.pathParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureUpdatePlaylistRequest(with configuration: URLRequestConfiguration, request: Operations.UpdatePlaylistRequest) throws {
configuration.path = "/playlists/{playlistID}"
configuration.method = .put
configuration.pathParameterSerializable = request
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureGetPlaylistContentsRequest(with configuration: URLRequestConfiguration, request: Operations.GetPlaylistContentsRequest) throws {
configuration.path = "/playlists/{playlistID}/items"
configuration.method = .get
configuration.pathParameterSerializable = request
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureClearPlaylistContentsRequest(with configuration: URLRequestConfiguration, request: Operations.ClearPlaylistContentsRequest) throws {
configuration.path = "/playlists/{playlistID}/items"
configuration.method = .delete
configuration.pathParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureAddPlaylistContentsRequest(with configuration: URLRequestConfiguration, request: Operations.AddPlaylistContentsRequest) throws {
configuration.path = "/playlists/{playlistID}/items"
configuration.method = .put
configuration.pathParameterSerializable = request
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureUploadPlaylistRequest(with configuration: URLRequestConfiguration, request: Operations.UploadPlaylistRequest) throws {
configuration.path = "/playlists/upload"
configuration.method = .post
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handleCreatePlaylistResponse(response: Client.APIResponse) throws -> Operations.CreatePlaylistResponse {
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.CreatePlaylistResponseBody.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.CreatePlaylistPlaylistsResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetPlaylistsResponse(response: Client.APIResponse) throws -> Operations.GetPlaylistsResponse {
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.GetPlaylistsResponseBody.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.GetPlaylistsPlaylistsResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetPlaylistResponse(response: Client.APIResponse) throws -> Operations.GetPlaylistResponse {
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.GetPlaylistResponseBody.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.GetPlaylistPlaylistsResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleDeletePlaylistResponse(response: Client.APIResponse) throws -> Operations.DeletePlaylistResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.DeletePlaylistResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleUpdatePlaylistResponse(response: Client.APIResponse) throws -> Operations.UpdatePlaylistResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.UpdatePlaylistResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetPlaylistContentsResponse(response: Client.APIResponse) throws -> Operations.GetPlaylistContentsResponse {
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.GetPlaylistContentsResponseBody.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.GetPlaylistContentsPlaylistsResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleClearPlaylistContentsResponse(response: Client.APIResponse) throws -> Operations.ClearPlaylistContentsResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.ClearPlaylistContentsResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleAddPlaylistContentsResponse(response: Client.APIResponse) throws -> Operations.AddPlaylistContentsResponse {
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.AddPlaylistContentsResponseBody.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.AddPlaylistContentsPlaylistsResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleUploadPlaylistResponse(response: Client.APIResponse) throws -> Operations.UploadPlaylistResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.UploadPlaylistResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,96 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _PlexAPI: PlexAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func getPin(request: Operations.GetPinRequest, server: PlexServers.GetPin?) async throws -> Response<Operations.GetPinResponse> {
return try await client.makeRequest(
with: try server?.server() ?? PlexServers.GetPin.default(),
configureRequest: { configuration in
try configureGetPinRequest(with: configuration, request: request)
},
handleResponse: handleGetPinResponse
)
}
public func getToken(request: Operations.GetTokenRequest, server: PlexServers.GetToken?) async throws -> Response<Operations.GetTokenResponse> {
return try await client.makeRequest(
with: try server?.server() ?? PlexServers.GetToken.default(),
configureRequest: { configuration in
try configureGetTokenRequest(with: configuration, request: request)
},
handleResponse: handleGetTokenResponse
)
}
}
// MARK: - Request Configuration
private func configureGetPinRequest(with configuration: URLRequestConfiguration, request: Operations.GetPinRequest) throws {
configuration.path = "/pins"
configuration.method = .post
configuration.queryParameterSerializable = request
configuration.headerParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureGetTokenRequest(with configuration: URLRequestConfiguration, request: Operations.GetTokenRequest) throws {
configuration.path = "/pins/{pinID}"
configuration.method = .get
configuration.pathParameterSerializable = request
configuration.headerParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handleGetPinResponse(response: Client.APIResponse) throws -> Operations.GetPinResponse {
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))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
} else if httpResponse.statusCode == 400 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .fourHundredApplicationJsonObject(try JSONDecoder().decode(Operations.GetPinPlexResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetTokenResponse(response: Client.APIResponse) throws -> Operations.GetTokenResponse {
let httpResponse = response.httpResponse
if httpResponse.statusCode == 200 {
return .empty
} 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))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,128 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _SearchAPI: SearchAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func performSearch(request: Operations.PerformSearchRequest) async throws -> Response<Operations.PerformSearchResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configurePerformSearchRequest(with: configuration, request: request)
},
handleResponse: handlePerformSearchResponse
)
}
public func performVoiceSearch(request: Operations.PerformVoiceSearchRequest) async throws -> Response<Operations.PerformVoiceSearchResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configurePerformVoiceSearchRequest(with: configuration, request: request)
},
handleResponse: handlePerformVoiceSearchResponse
)
}
public func getSearchResults(request: Operations.GetSearchResultsRequest) async throws -> Response<Operations.GetSearchResultsResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetSearchResultsRequest(with: configuration, request: request)
},
handleResponse: handleGetSearchResultsResponse
)
}
}
// MARK: - Request Configuration
private func configurePerformSearchRequest(with configuration: URLRequestConfiguration, request: Operations.PerformSearchRequest) throws {
configuration.path = "/hubs/search"
configuration.method = .get
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configurePerformVoiceSearchRequest(with configuration: URLRequestConfiguration, request: Operations.PerformVoiceSearchRequest) throws {
configuration.path = "/hubs/search/voice"
configuration.method = .get
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureGetSearchResultsRequest(with configuration: URLRequestConfiguration, request: Operations.GetSearchResultsRequest) throws {
configuration.path = "/search"
configuration.method = .get
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handlePerformSearchResponse(response: Client.APIResponse) throws -> Operations.PerformSearchResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.PerformSearchResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handlePerformVoiceSearchResponse(response: Client.APIResponse) throws -> Operations.PerformVoiceSearchResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.PerformVoiceSearchResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetSearchResultsResponse(response: Client.APIResponse) throws -> Operations.GetSearchResultsResponse {
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.GetSearchResultsResponseBody.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.GetSearchResultsSearchResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,339 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _ServerAPI: ServerAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func getServerCapabilities() async throws -> Response<Operations.GetServerCapabilitiesResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetServerCapabilitiesRequest(with: configuration)
},
handleResponse: handleGetServerCapabilitiesResponse
)
}
public func getServerPreferences() async throws -> Response<Operations.GetServerPreferencesResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetServerPreferencesRequest(with: configuration)
},
handleResponse: handleGetServerPreferencesResponse
)
}
public func getAvailableClients() async throws -> Response<Operations.GetAvailableClientsResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetAvailableClientsRequest(with: configuration)
},
handleResponse: handleGetAvailableClientsResponse
)
}
public func getDevices() async throws -> Response<Operations.GetDevicesResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetDevicesRequest(with: configuration)
},
handleResponse: handleGetDevicesResponse
)
}
public func getServerIdentity() async throws -> Response<Operations.GetServerIdentityResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetServerIdentityRequest(with: configuration)
},
handleResponse: handleGetServerIdentityResponse
)
}
public func getMyPlexAccount() async throws -> Response<Operations.GetMyPlexAccountResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetMyPlexAccountRequest(with: configuration)
},
handleResponse: handleGetMyPlexAccountResponse
)
}
public func getResizedPhoto(request: Operations.GetResizedPhotoRequest) async throws -> Response<Operations.GetResizedPhotoResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetResizedPhotoRequest(with: configuration, request: request)
},
handleResponse: handleGetResizedPhotoResponse
)
}
public func getServerList() async throws -> Response<Operations.GetServerListResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetServerListRequest(with: configuration)
},
handleResponse: handleGetServerListResponse
)
}
}
// MARK: - Request Configuration
private func configureGetServerCapabilitiesRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
private func configureGetServerPreferencesRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/:/prefs"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
private func configureGetAvailableClientsRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/clients"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
private func configureGetDevicesRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/devices"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
private func configureGetServerIdentityRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/identity"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
private func configureGetMyPlexAccountRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/myplex/account"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
private func configureGetResizedPhotoRequest(with configuration: URLRequestConfiguration, request: Operations.GetResizedPhotoRequest) throws {
configuration.path = "/photo/:/transcode"
configuration.method = .get
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureGetServerListRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/servers"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handleGetServerCapabilitiesResponse(response: Client.APIResponse) throws -> Operations.GetServerCapabilitiesResponse {
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.GetServerCapabilitiesResponseBody.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.GetServerCapabilitiesServerResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetServerPreferencesResponse(response: Client.APIResponse) throws -> Operations.GetServerPreferencesResponse {
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.GetServerPreferencesResponseBody.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.GetServerPreferencesServerResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetAvailableClientsResponse(response: Client.APIResponse) throws -> Operations.GetAvailableClientsResponse {
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.GetAvailableClientsResponseBody.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.GetAvailableClientsServerResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetDevicesResponse(response: Client.APIResponse) throws -> Operations.GetDevicesResponse {
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.GetDevicesResponseBody.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.GetDevicesServerResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetServerIdentityResponse(response: Client.APIResponse) throws -> Operations.GetServerIdentityResponse {
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.GetServerIdentityResponseBody.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.GetServerIdentityServerResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetMyPlexAccountResponse(response: Client.APIResponse) throws -> Operations.GetMyPlexAccountResponse {
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.GetMyPlexAccountResponseBody.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.GetMyPlexAccountServerResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetResizedPhotoResponse(response: Client.APIResponse) throws -> Operations.GetResizedPhotoResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.GetResizedPhotoResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetServerListResponse(response: Client.APIResponse) throws -> Operations.GetServerListResponse {
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.GetServerListResponseBody.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.GetServerListServerResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,175 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _SessionsAPI: SessionsAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func getSessions() async throws -> Response<Operations.GetSessionsResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetSessionsRequest(with: configuration)
},
handleResponse: handleGetSessionsResponse
)
}
public func getSessionHistory() async throws -> Response<Operations.GetSessionHistoryResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetSessionHistoryRequest(with: configuration)
},
handleResponse: handleGetSessionHistoryResponse
)
}
public func getTranscodeSessions() async throws -> Response<Operations.GetTranscodeSessionsResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetTranscodeSessionsRequest(with: configuration)
},
handleResponse: handleGetTranscodeSessionsResponse
)
}
public func stopTranscodeSession(request: Operations.StopTranscodeSessionRequest) async throws -> Response<Operations.StopTranscodeSessionResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureStopTranscodeSessionRequest(with: configuration, request: request)
},
handleResponse: handleStopTranscodeSessionResponse
)
}
}
// MARK: - Request Configuration
private func configureGetSessionsRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/status/sessions"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
private func configureGetSessionHistoryRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/status/sessions/history/all"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
private func configureGetTranscodeSessionsRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/transcode/sessions"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
private func configureStopTranscodeSessionRequest(with configuration: URLRequestConfiguration, request: Operations.StopTranscodeSessionRequest) throws {
configuration.path = "/transcode/sessions/{sessionKey}"
configuration.method = .delete
configuration.pathParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handleGetSessionsResponse(response: Client.APIResponse) throws -> Operations.GetSessionsResponse {
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.GetSessionsResponseBody.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.GetSessionsSessionsResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetSessionHistoryResponse(response: Client.APIResponse) throws -> Operations.GetSessionHistoryResponse {
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.GetSessionHistoryResponseBody.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.GetSessionHistorySessionsResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleGetTranscodeSessionsResponse(response: Client.APIResponse) throws -> Operations.GetTranscodeSessionsResponse {
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.GetTranscodeSessionsResponseBody.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.GetTranscodeSessionsSessionsResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleStopTranscodeSessionResponse(response: Client.APIResponse) throws -> Operations.StopTranscodeSessionResponse {
let httpResponse = response.httpResponse
if [204, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.StopTranscodeSessionResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,60 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _StatisticsAPI: StatisticsAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func getStatistics(request: Operations.GetStatisticsRequest) async throws -> Response<Operations.GetStatisticsResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetStatisticsRequest(with: configuration, request: request)
},
handleResponse: handleGetStatisticsResponse
)
}
}
// MARK: - Request Configuration
private func configureGetStatisticsRequest(with configuration: URLRequestConfiguration, request: Operations.GetStatisticsRequest) throws {
configuration.path = "/statistics/media"
configuration.method = .get
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handleGetStatisticsResponse(response: Client.APIResponse) throws -> Operations.GetStatisticsResponse {
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.GetStatisticsResponseBody.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.GetStatisticsStatisticsResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,127 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _UpdaterAPI: UpdaterAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func getUpdateStatus() async throws -> Response<Operations.GetUpdateStatusResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetUpdateStatusRequest(with: configuration)
},
handleResponse: handleGetUpdateStatusResponse
)
}
public func checkForUpdates(request: Operations.CheckForUpdatesRequest) async throws -> Response<Operations.CheckForUpdatesResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureCheckForUpdatesRequest(with: configuration, request: request)
},
handleResponse: handleCheckForUpdatesResponse
)
}
public func applyUpdates(request: Operations.ApplyUpdatesRequest) async throws -> Response<Operations.ApplyUpdatesResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureApplyUpdatesRequest(with: configuration, request: request)
},
handleResponse: handleApplyUpdatesResponse
)
}
}
// MARK: - Request Configuration
private func configureGetUpdateStatusRequest(with configuration: URLRequestConfiguration) throws {
configuration.path = "/updater/status"
configuration.method = .get
configuration.telemetryHeader = .userAgent
}
private func configureCheckForUpdatesRequest(with configuration: URLRequestConfiguration, request: Operations.CheckForUpdatesRequest) throws {
configuration.path = "/updater/check"
configuration.method = .put
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureApplyUpdatesRequest(with configuration: URLRequestConfiguration, request: Operations.ApplyUpdatesRequest) throws {
configuration.path = "/updater/apply"
configuration.method = .put
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handleGetUpdateStatusResponse(response: Client.APIResponse) throws -> Operations.GetUpdateStatusResponse {
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.GetUpdateStatusResponseBody.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.GetUpdateStatusUpdaterResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleCheckForUpdatesResponse(response: Client.APIResponse) throws -> Operations.CheckForUpdatesResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.CheckForUpdatesResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleApplyUpdatesResponse(response: Client.APIResponse) throws -> Operations.ApplyUpdatesResponse {
let httpResponse = response.httpResponse
if [200, 400, 500].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.ApplyUpdatesResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,86 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
class _VideoAPI: VideoAPI {
private let client: Client
init(client: Client) {
self.client = client
}
public func getTimeline(request: Operations.GetTimelineRequest) async throws -> Response<Operations.GetTimelineResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureGetTimelineRequest(with: configuration, request: request)
},
handleResponse: handleGetTimelineResponse
)
}
public func startUniversalTranscode(request: Operations.StartUniversalTranscodeRequest) async throws -> Response<Operations.StartUniversalTranscodeResponse> {
return try await client.makeRequest(
configureRequest: { configuration in
try configureStartUniversalTranscodeRequest(with: configuration, request: request)
},
handleResponse: handleStartUniversalTranscodeResponse
)
}
}
// MARK: - Request Configuration
private func configureGetTimelineRequest(with configuration: URLRequestConfiguration, request: Operations.GetTimelineRequest) throws {
configuration.path = "/:/timeline"
configuration.method = .get
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
private func configureStartUniversalTranscodeRequest(with configuration: URLRequestConfiguration, request: Operations.StartUniversalTranscodeRequest) throws {
configuration.path = "/video/:/transcode/universal/start.mpd"
configuration.method = .get
configuration.queryParameterSerializable = request
configuration.telemetryHeader = .userAgent
}
// MARK: - Response Handlers
private func handleGetTimelineResponse(response: Client.APIResponse) throws -> Operations.GetTimelineResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.GetTimelineResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}
private func handleStartUniversalTranscodeResponse(response: Client.APIResponse) throws -> Operations.StartUniversalTranscodeResponse {
let httpResponse = response.httpResponse
if [200, 400].contains(httpResponse.statusCode) {
return .empty
} else if httpResponse.statusCode == 401 {
if httpResponse.contentType.matchContentType(pattern: "application/json"), let data = response.data {
do {
return .object(try JSONDecoder().decode(Operations.StartUniversalTranscodeResponseBody.self, from: data))
} catch {
throw ResponseHandlerError.failedToDecodeJSON(error)
}
}
}
return .empty
}

View File

@@ -0,0 +1,121 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
#if os(Linux)
import FoundationNetworking
#endif
/// Describes any header values returned as part of a response to a call made to the API.
///
/// As per the HTTP RFCs, header values can be queried in a case-insensitive manner.
public struct ResponseHeaders {
private let httpResponse: HTTPURLResponse
init(httpResponse: HTTPURLResponse) {
self.httpResponse = httpResponse
}
public func value(forHeaderNamed name: String) -> String? {
return httpResponse.value(forHTTPHeaderField: name)
}
public subscript(name: String) -> String? {
return value(forHeaderNamed: name)
}
}
/// Describes the result of making a request to the API.
///
/// This type is returned by all functions which make calls to the API. It returns information about the response
/// and is parameterised by `T` over the type of data which is returned by the API operation.
public struct Response<T>: ResponseFields {
/// The HTTP status code returned by the server.
///
/// This property contains the HTTP status code returned by the server in response to the underlying network request
/// made to fulfill the given API operation.
public var statusCode: Int {
return httpResponse.statusCode
}
/// The media type returned by the server.
///
/// This property contains the media type returned by the server in response to the underlying network request
/// made to fulfill the given API operation.
public var contentType: String {
return httpResponse.contentType
}
/// The raw HTTP response object.
///
/// This property contains the [HTTPURLResponse](https://developer.apple.com/documentation/foundation/httpurlresponse) object
/// returned from making the underlying network request to fulfill the given API operation.
public let httpResponse: HTTPURLResponse
/// The response data.
///
/// This property contains any response data associated with the API operation.
public let data: T
public init(httpResponse: HTTPURLResponse, data: T) {
self.httpResponse = httpResponse
self.data = data
}
}
/// Describes the result of making a request to the API which can contain resulting response header fields.
///
/// This type is returned by all functions which make calls to the API. It returns information about the response
/// and is parameterised by `T` over the type of data which is returned by the API operation.
public struct ResponseWithHeaders<T>: ResponseFields {
/// The HTTP status code returned by the server.
///
/// This property contains the HTTP status code returned by the server in response to the underlying network request
/// made to fulfill the given API operation.
public var statusCode: Int {
return httpResponse.statusCode
}
/// The media type returned by the server.
///
/// This property contains the media type returned by the server in response to the underlying network request
/// made to fulfill the given API operation.
public var contentType: String {
return httpResponse.contentType
}
/// The raw HTTP response object.
///
/// This property contains the [HTTPURLResponse](https://developer.apple.com/documentation/foundation/httpurlresponse) object
/// returned from making the underlying network request to fulfill the given API operation.
public let httpResponse: HTTPURLResponse
/// Any response headers returned by the underlying network request made to fulfill the given API operation.
public let headers: ResponseHeaders?
/// The response data.
///
/// This property contains any response data associated with the API operation.
public let data: T
public init(httpResponse: HTTPURLResponse, data: T) {
self.httpResponse = httpResponse
self.data = data
self.headers = ResponseHeaders(httpResponse: httpResponse)
}
}
/// Describes the fields which are included in all responses to requests made to the API.
///
/// This protocol is adopted by ``Response`` and ``ResponseWithHeaders`` depending on the individual API operation.
public protocol ResponseFields {
associatedtype T;
var statusCode: Int { get }
var contentType: String { get }
var httpResponse: HTTPURLResponse { get }
var data: T { get }
init(httpResponse: HTTPURLResponse, data: T)
}

View File

@@ -0,0 +1,60 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
struct Server {
public let urlString: String
}
protocol Servers {
static var urlStrings: [String] { get }
static func `default`() throws -> Server
static func server(at index: Int) throws -> Server
static func server(at index: Int, substituting parameters: [String: String]?) throws -> Server
}
protocol ServerConvertible {
func server() throws -> Server
}
enum ServerConversionError: Swift.Error {
case `internal`
case missingDefaultServer(serverType: String)
case invalidServerIndex(serverType: String, index: Int)
case missingServerParameterSubstitutionKey(_ key: String, serverString: String)
}
extension Servers {
static func `default`() throws -> Server {
guard urlStrings.count > 0 else {
throw ServerConversionError.missingDefaultServer(serverType: String(describing: self))
}
return Server(urlString: urlStrings[0])
}
static func server(at index: Int) throws -> Server {
return try server(at: index, substituting: nil)
}
static func server(at index: Int, substituting parameters: [String: String]?) throws -> Server {
guard index >= 0 && index < urlStrings.count else {
throw ServerConversionError.invalidServerIndex(serverType: String(describing: self), index: index)
}
if let parameters = parameters {
do {
return Server(urlString: try urlStrings[index].substituteComponents { key in parameters[key] })
} catch let error as StringSubstitutionError {
switch error {
case .internal:
throw ServerConversionError.internal
case .missingParameter(named: let name, in: let string):
throw ServerConversionError.missingServerParameterSubstitutionKey(name, serverString: string)
}
}
} else {
return Server(urlString: urlStrings[index])
}
}
}

View File

@@ -0,0 +1,154 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
#if os(Linux)
import FoundationNetworking
#endif
enum URLRequestBuilderError: Swift.Error {
case internalError
case invalidURL(String)
case missingPathParameterSubstitutionKey(_ key: String, path: String)
}
final class URLRequestBuilder: URLRequestConfiguration {
private let baseURL: URL
private let parameterDefaults: ParameterDefaults?
private let defaultSecurityParameterProviding: SecurityParameterProviding?
var path: String = ""
var method: URLRequestHTTPMethod = .get
var contentType: String?
var securityParameterProviding: SecurityParameterProviding?
var pathParameterSerializable: PathParameterSerializable?
var queryParameterSerializable: QueryParameterSerializable?
var headerParameterSerializable: HeaderParameterSerializable?
var body: Data?
var telemetryHeader: TelemetryHeader = .userAgent
init(baseURL: URL, parameterDefaults: ParameterDefaults?, defaultSecurityParameterProviding: SecurityParameterProviding?) {
self.baseURL = baseURL
self.parameterDefaults = parameterDefaults
self.defaultSecurityParameterProviding = defaultSecurityParameterProviding
}
func build() throws -> URLRequest {
guard var urlComponents = URLComponents(url: baseURL, resolvingAgainstBaseURL: true) else {
throw URLRequestBuilderError.invalidURL(baseURL.absoluteString)
}
try buildPathComponents(in: &urlComponents)
guard let url = urlComponents.url else {
throw URLRequestBuilderError.invalidURL(baseURL.absoluteString)
}
var urlRequest = URLRequest(url: url)
if let headerParameterSerializable {
for header in try headerParameterSerializable.serializedHeaderParameters() {
urlRequest.setValue(header.serialized, forHTTPHeaderField: header.name)
}
}
urlRequest.httpMethod = method.rawValue
urlRequest.httpBody = body
if let contentType {
urlRequest.setValue(contentType, forHTTPHeaderField: "Content-Type")
}
urlRequest.setValue("speakeasy-sdk/swift 0.1.2 2.302.1 0.0.3 plexswift", forHTTPHeaderField: telemetryHeader.headerName)
addSecurityParameters(to: &urlRequest)
return urlRequest
}
// MARK: - Private
private func buildPathComponents(in urlComponents: inout URLComponents) throws {
let (path, fragment) = parsePath(path)
if let pathParameterSerializable {
urlComponents.path = (urlComponents.path as NSString).appendingPathComponent(
try substitutePathParameters(in: path, with: pathParameterSerializable, parameterDefaults: parameterDefaults)
)
} else {
urlComponents.path = (urlComponents.path as NSString).appendingPathComponent(path)
}
if let queryParameterSerializable {
urlComponents.percentEncodedQuery = queryString(
from: try queryParameterSerializable.serializedQueryParameters(with: parameterDefaults, formatOverride: nil)
)
}
urlComponents.fragment = fragment
}
private func parsePath(_ path: String) -> (path: String, fragment: String?) {
let components = path.components(separatedBy: "#")
guard let first = components.first else {
return (path: "", fragment: nil)
}
return (path: first, fragment: components.count > 1 ? components[1] : nil)
}
private func addSecurityParameters(to request: inout URLRequest) {
guard let securityParameterProviding = securityParameterProviding ?? defaultSecurityParameterProviding else { return }
let parameters = securityParameterProviding.securityParameters()
for parameter in parameters {
switch parameter {
case .httpBasic(username: let username, password: let password):
if let username, let password, let encoded = "\(username):\(password)".data(using: .utf8)?.base64EncodedString() {
request.addValue("Basic \(encoded)", forHTTPHeaderField: "Authorization")
}
case .httpBearer(value: let value):
if let value {
let headerValue = value.range(of: "Bearer ")?.lowerBound == value.startIndex ? value : "Bearer \(value)"
request.addValue(headerValue, forHTTPHeaderField: "Authorization")
}
case .apiKey(name: let name, value: let value), .oauth2(name: let name, value: let value), .openIdConnect(name: let name, value: let value):
if let value {
request.addValue(value, forHTTPHeaderField: name)
}
}
}
}
}
// Substitute path parameters and rethrow `StringSubstitutionError`s as `URLRequestBuilderError`s.
fileprivate func substitutePathParameters(
in path: String,
with pathParameterSerializable: PathParameterSerializable,
parameterDefaults: ParameterDefaults?
) throws -> String {
do {
let parameters = try pathParameterSerializable.serializedPathParameters(formatOverride: nil)
return try path.substituteComponents { key in
return try parameters[key] ?? parameterDefaults?.defaultSerializedPathParameter(for: key)
}
} catch let error as StringSubstitutionError {
switch error {
case .internal:
throw URLRequestBuilderError.internalError
case .missingParameter(named: let name, in: let string):
throw URLRequestBuilderError.missingPathParameterSubstitutionKey(name, path: string)
}
}
}
fileprivate extension TelemetryHeader {
var headerName: String {
switch self {
case .userAgent: return "User-Agent"
case .speakeasyUserAgent: return "X-Speakeasy-User-Agent"
}
}
}

View File

@@ -0,0 +1,35 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
enum URLRequestHTTPMethod: String {
case get = "GET"
case post = "POST"
case put = "PUT"
case patch = "PATCH"
case delete = "DELETE"
case head = "HEAD"
case options = "OPTIONS"
case trace = "TRACE"
}
enum TelemetryHeader {
case userAgent
case speakeasyUserAgent
}
protocol URLRequestConfiguration: AnyObject {
var path: String { get set }
var method: URLRequestHTTPMethod { get set }
var contentType: String? { get set }
var securityParameterProviding: SecurityParameterProviding? { get set }
var pathParameterSerializable: PathParameterSerializable? { get set }
var queryParameterSerializable: QueryParameterSerializable? { get set }
var headerParameterSerializable: HeaderParameterSerializable? { get set }
var body: Data? { get set }
var telemetryHeader: TelemetryHeader { get set }
}

View File

@@ -0,0 +1,12 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
#if os(Linux)
import FoundationNetworking
#endif
extension HTTPURLResponse {
var contentType: String {
return value(forHTTPHeaderField: "Content-Type") ?? "application/octet-stream"
}
}

View File

@@ -0,0 +1,25 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension String {
func matchContentType(pattern: String) -> Bool {
// Match wildcard types
if pattern == "*" || pattern == "*/*" {
return true
}
// Match content type of the format 'application/json; charset=UTF-8'
let contentTypeComponents = pattern.components(separatedBy: ";").map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
guard let mediaType = contentTypeComponents.first else { return false }
if mediaType == pattern {
return true
}
// Match wildcard parts on the media type
let mediaTypeComponents = mediaType.components(separatedBy: "/")
guard mediaTypeComponents.count == 2 else { return false }
return pattern == "\(mediaTypeComponents[0])/*" || pattern == "*/\(mediaTypeComponents[1])"
}
}

View File

@@ -0,0 +1,37 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
enum StringSubstitutionError: Swift.Error {
case `internal`
case missingParameter(named: String, in: String)
}
extension String {
typealias SubstitutionHandler = (_ key: String) throws -> String?
func substituteComponents(using substitutionHandler: SubstitutionHandler) throws -> String {
let regex = try NSRegularExpression(pattern: "\\{([^}]+)\\}")
let range = NSRange(startIndex..<endIndex, in: self)
let matches = regex.matches(in: self, range: range)
var substitutedPath = self
// Reverse matches so that we can replace substrings in place.
for match in matches.reversed() {
let templateRange = match.range
guard let keyRange = Range(match.range(at: 1), in: self) else {
throw StringSubstitutionError.internal
}
let key = String(self[keyRange])
guard let serializedParameter = try substitutionHandler(key) else {
throw StringSubstitutionError.missingParameter(named: key, in: self)
}
let startIndex = substitutedPath.index(substitutedPath.startIndex, offsetBy: templateRange.location)
let endIndex = substitutedPath.index(startIndex, offsetBy: templateRange.length)
substitutedPath.replaceSubrange(startIndex..<endIndex, with: serializedParameter)
}
return substitutedPath
}
}

View File

@@ -0,0 +1,40 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.AddPlaylistContentsRequest: 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.AddPlaylistContentsRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.AddPlaylistContentsRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"playlistID": try playlistIDWrapper.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}
extension Operations.AddPlaylistContentsRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: uri, named: "uri", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
if playQueueID != nil {
try builder.addQueryParameters(from: playQueueIDWrapper, named: "playQueueID", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
return builder.build()
}
}

View File

@@ -0,0 +1,28 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.ApplyUpdatesRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.ApplyUpdatesRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.ApplyUpdatesRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: skip, named: "skip", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: tonight, named: "tonight", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,23 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.CancelServerActivitiesRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .path:
return try serializePathParameterSerializable(self, with: format)
case .query, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.CancelServerActivitiesRequest", format: format.formatDescription)
}
}
}
extension Operations.CancelServerActivitiesRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"activityUUID": try activityUUID.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}

View File

@@ -0,0 +1,27 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.CheckForUpdatesRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.CheckForUpdatesRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.CheckForUpdatesRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: download, named: "download", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,23 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.ClearPlaylistContentsRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .path:
return try serializePathParameterSerializable(self, with: format)
case .query, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.ClearPlaylistContentsRequest", format: format.formatDescription)
}
}
}
extension Operations.ClearPlaylistContentsRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"playlistID": try playlistIDWrapper.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}

View File

@@ -0,0 +1,33 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.CreatePlaylistRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.CreatePlaylistRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.CreatePlaylistRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: smart, named: "smart", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: title, named: "title", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: type, named: "type", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: uri, named: "uri", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
if playQueueID != nil {
try builder.addQueryParameters(from: playQueueIDWrapper, named: "playQueueID", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
return builder.build()
}
}

View File

@@ -0,0 +1,23 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.DeleteLibraryRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .path:
return try serializePathParameterSerializable(self, with: format)
case .query, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.DeleteLibraryRequest", format: format.formatDescription)
}
}
}
extension Operations.DeleteLibraryRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"sectionId": try sectionIdWrapper.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}

View File

@@ -0,0 +1,23 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.DeletePlaylistRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .path:
return try serializePathParameterSerializable(self, with: format)
case .query, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.DeletePlaylistRequest", format: format.formatDescription)
}
}
}
extension Operations.DeletePlaylistRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"playlistID": try playlistIDWrapper.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.Download: 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))]
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.Force: 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))]
}
}

View File

@@ -0,0 +1,30 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetFileHashRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetFileHashRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.GetFileHashRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: url, named: "url", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
if type != nil {
try builder.addQueryParameters(from: typeWrapper, named: "type", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
return builder.build()
}
}

View File

@@ -0,0 +1,30 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetGlobalHubsRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetGlobalHubsRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.GetGlobalHubsRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
if count != nil {
try builder.addQueryParameters(from: countWrapper, named: "count", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
try builder.addQueryParameters(from: onlyTransient, named: "onlyTransient", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,40 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetLibraryHubsRequest: 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.GetLibraryHubsRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.GetLibraryHubsRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"sectionId": try sectionIdWrapper.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}
extension Operations.GetLibraryHubsRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
if count != nil {
try builder.addQueryParameters(from: countWrapper, named: "count", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
try builder.addQueryParameters(from: onlyTransient, named: "onlyTransient", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,24 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetLibraryItemsRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .path:
return try serializePathParameterSerializable(self, with: format)
case .query, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetLibraryItemsRequest", format: format.formatDescription)
}
}
}
extension Operations.GetLibraryItemsRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"sectionId": try sectionId.serialize(with: formatOverride ?? .path(explode: false)),
"tag": try tag.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}

View File

@@ -0,0 +1,37 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetLibraryRequest: 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.GetLibraryRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.GetLibraryRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"sectionId": try sectionIdWrapper.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}
extension Operations.GetLibraryRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: includeDetails, named: "includeDetails", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,23 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetMetadataChildrenRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .path:
return try serializePathParameterSerializable(self, with: format)
case .query, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetMetadataChildrenRequest", format: format.formatDescription)
}
}
}
extension Operations.GetMetadataChildrenRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"ratingKey": try ratingKeyWrapper.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}

View File

@@ -0,0 +1,23 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetMetadataRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .path:
return try serializePathParameterSerializable(self, with: format)
case .query, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetMetadataRequest", format: format.formatDescription)
}
}
}
extension Operations.GetMetadataRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"ratingKey": try ratingKeyWrapper.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}

View File

@@ -0,0 +1,37 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetPinRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .header:
return serializeModel(with: try serializedHeaderParameters(), format: format)
case .path, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetPinRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.GetPinRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: strong, named: "strong", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}
extension Operations.GetPinRequest: HeaderParameterSerializable {
func serializedHeaderParameters() throws -> [SerializedParameter] {
return [
SerializedParameter(name: "X-Plex-Client-Identifier", serialized: try xPlexClientIdentifier?.serialize(with: .header(explode: false)))
]
}
}

View File

@@ -0,0 +1,37 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetPlaylistContentsRequest: 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.GetPlaylistContentsRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.GetPlaylistContentsRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"playlistID": try playlistIDWrapper.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}
extension Operations.GetPlaylistContentsRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: typeWrapper, named: "type", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,23 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetPlaylistRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .path:
return try serializePathParameterSerializable(self, with: format)
case .query, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetPlaylistRequest", format: format.formatDescription)
}
}
}
extension Operations.GetPlaylistRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"playlistID": try playlistIDWrapper.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}

View File

@@ -0,0 +1,28 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetPlaylistsRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetPlaylistsRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.GetPlaylistsRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: playlistType, named: "playlistType", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: smart, named: "smart", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,33 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetResizedPhotoRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetResizedPhotoRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.GetResizedPhotoRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: blurWrapper, named: "blur", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: heightWrapper, named: "height", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: minSize, named: "minSize", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: opacity, named: "opacity", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: upscale, named: "upscale", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: url, named: "url", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: widthWrapper, named: "width", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,27 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetSearchResultsRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetSearchResultsRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.GetSearchResultsRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: query, named: "query", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,27 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetSourceConnectionInformationRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetSourceConnectionInformationRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.GetSourceConnectionInformationRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: source, named: "source", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,27 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetStatisticsRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetStatisticsRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.GetStatisticsRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: timespan, named: "Timespan", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,36 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetTimelineRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetTimelineRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.GetTimelineRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: context, named: "context", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: durationWrapper, named: "duration", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: hasMDEWrapper, named: "hasMDE", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: key, named: "key", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: playBackTimeWrapper, named: "playBackTime", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: playQueueItemIDWrapper, named: "playQueueItemID", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: ratingKeyWrapper, named: "ratingKey", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: rowWrapper, named: "row", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: state, named: "state", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: timeWrapper, named: "time", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,33 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetTokenRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .path:
return try serializePathParameterSerializable(self, with: format)
case .header:
return serializeModel(with: try serializedHeaderParameters(), format: format)
case .query, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetTokenRequest", format: format.formatDescription)
}
}
}
extension Operations.GetTokenRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"pinID": try pinID.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}
extension Operations.GetTokenRequest: HeaderParameterSerializable {
func serializedHeaderParameters() throws -> [SerializedParameter] {
return [
SerializedParameter(name: "X-Plex-Client-Identifier", serialized: try xPlexClientIdentifier?.serialize(with: .header(explode: false)))
]
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetTransientTokenQueryParamType: 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))]
}
}

View File

@@ -0,0 +1,28 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.GetTransientTokenRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.GetTransientTokenRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.GetTransientTokenRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: scope, named: "scope", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: type, named: "type", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.IncludeDetails: 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))]
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.Level: 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))]
}
}

View File

@@ -0,0 +1,29 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.LogLineRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.LogLineRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.LogLineRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: level, named: "level", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: message, named: "message", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: source, named: "source", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,27 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.MarkPlayedRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.MarkPlayedRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.MarkPlayedRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: keyWrapper, named: "key", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,27 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.MarkUnplayedRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.MarkUnplayedRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.MarkUnplayedRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: keyWrapper, named: "key", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.MinSize: 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))]
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.OnlyTransient: 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))]
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.PathParamTaskName: 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))]
}
}

View File

@@ -0,0 +1,33 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.PerformSearchRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.PerformSearchRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.PerformSearchRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: query, named: "query", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
if limit != nil {
try builder.addQueryParameters(from: limitWrapper, named: "limit", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
if sectionId != nil {
try builder.addQueryParameters(from: sectionIdWrapper, named: "sectionId", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
return builder.build()
}
}

View File

@@ -0,0 +1,33 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.PerformVoiceSearchRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.PerformVoiceSearchRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.PerformVoiceSearchRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: query, named: "query", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
if limit != nil {
try builder.addQueryParameters(from: limitWrapper, named: "limit", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
if sectionId != nil {
try builder.addQueryParameters(from: sectionIdWrapper, named: "sectionId", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
return builder.build()
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.PlaylistType: 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))]
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.QueryParamOnlyTransient: 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))]
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.QueryParamSmart: 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))]
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.QueryParamType: 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))]
}
}

View File

@@ -0,0 +1,23 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.RefreshLibraryRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .path:
return try serializePathParameterSerializable(self, with: format)
case .query, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.RefreshLibraryRequest", format: format.formatDescription)
}
}
}
extension Operations.RefreshLibraryRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"sectionId": try sectionIdWrapper.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.Scope: 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))]
}
}

View File

@@ -0,0 +1,37 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.SearchLibraryRequest: 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.SearchLibraryRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.SearchLibraryRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"sectionId": try sectionId.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}
extension Operations.SearchLibraryRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: type, named: "type", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,13 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Shared.Security: SecurityParameterProviding {
func securityParameters() -> [SecurityParameter] {
switch self {
case .accessToken(let value):
return [.apiKey(name: "X-Plex-Token", value: value)]
}
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.Skip: 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))]
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.Smart: 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))]
}
}

View File

@@ -0,0 +1,23 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.StartTaskRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .path:
return try serializePathParameterSerializable(self, with: format)
case .query, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.StartTaskRequest", format: format.formatDescription)
}
}
}
extension Operations.StartTaskRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"taskName": try taskName.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}

View File

@@ -0,0 +1,58 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.StartUniversalTranscodeRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.StartUniversalTranscodeRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.StartUniversalTranscodeRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: hasMDEWrapper, named: "hasMDE", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: mediaIndexWrapper, named: "mediaIndex", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: partIndexWrapper, named: "partIndex", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: path, named: "path", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: `protocol`, named: "protocol", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
if addDebugOverlay != nil {
try builder.addQueryParameters(from: addDebugOverlayWrapper, named: "addDebugOverlay", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
if audioBoost != nil {
try builder.addQueryParameters(from: audioBoostWrapper, named: "audioBoost", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
if autoAdjustQuality != nil {
try builder.addQueryParameters(from: autoAdjustQualityWrapper, named: "autoAdjustQuality", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
if directPlay != nil {
try builder.addQueryParameters(from: directPlayWrapper, named: "directPlay", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
if directStream != nil {
try builder.addQueryParameters(from: directStreamWrapper, named: "directStream", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
if fastSeek != nil {
try builder.addQueryParameters(from: fastSeekWrapper, named: "fastSeek", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
try builder.addQueryParameters(from: location, named: "location", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
if mediaBufferSize != nil {
try builder.addQueryParameters(from: mediaBufferSizeWrapper, named: "mediaBufferSize", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
try builder.addQueryParameters(from: session, named: "session", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: subtites, named: "subtites", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
if subtitleSize != nil {
try builder.addQueryParameters(from: subtitleSizeWrapper, named: "subtitleSize", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
}
return builder.build()
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.State: 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))]
}
}

View File

@@ -0,0 +1,23 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.StopTaskRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .path:
return try serializePathParameterSerializable(self, with: format)
case .query, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.StopTaskRequest", format: format.formatDescription)
}
}
}
extension Operations.StopTaskRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"taskName": try taskName.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}

View File

@@ -0,0 +1,23 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.StopTranscodeSessionRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .path:
return try serializePathParameterSerializable(self, with: format)
case .query, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.StopTranscodeSessionRequest", format: format.formatDescription)
}
}
}
extension Operations.StopTranscodeSessionRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"sessionKey": try sessionKey.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.Tag: 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))]
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.TaskName: 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))]
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.Tonight: 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))]
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.TypeModel: 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))]
}
}

View File

@@ -0,0 +1,29 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.UpdatePlayProgressRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.UpdatePlayProgressRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.UpdatePlayProgressRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: key, named: "key", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: state, named: "state", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: timeWrapper, named: "time", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,38 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.UpdatePlaylistRequest: 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.UpdatePlaylistRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.UpdatePlaylistRequest: PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String] {
return [
"playlistID": try playlistIDWrapper.serialize(with: formatOverride ?? .path(explode: false)),
].compactMapValues { $0 }
}
}
extension Operations.UpdatePlaylistRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: summary, named: "summary", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: title, named: "title", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,28 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.UploadPlaylistRequest: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
switch format {
case .query:
return try serializeQueryParameterSerializable(self, with: format)
case .path, .header, .multipart, .form:
throw SerializationError.invalidSerializationParameter(type: "Operations.UploadPlaylistRequest", format: format.formatDescription)
}
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try serializedQueryParameters(with: nil, formatOverride: format)
}
}
extension Operations.UploadPlaylistRequest: QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter] {
let builder = QueryParameterBuilder()
try builder.addQueryParameters(from: force, named: "force", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
try builder.addQueryParameters(from: path, named: "path", format: formatOverride ?? .query(style: .form, explode: true), parameterDefaults: parameterDefaults)
return builder.build()
}
}

View File

@@ -0,0 +1,14 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
extension Operations.Upscale: 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))]
}
}

View File

@@ -0,0 +1,58 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
func multipartContentType(with boundary: String) -> String {
return "multipart/form-data; boundary=\(boundary)"
}
func serializeMultipartFormData(with multipartFormBodySerializable: MultipartFormBodySerializable) throws -> (boundary: String, data: Data) {
let boundary = UUID().uuidString
var data = Data()
let parameters = try multipartFormBodySerializable.serializedMultipartFormParameters(formatOverride: nil)
parameters.forEach { parameter in
switch parameter {
case .value(name: let name, serialized: let serialized):
guard let serialized else { return }
data.append(utf8String: "--\(boundary)\r\n")
data.append(utf8String: "Content-Disposition: multipart/form-data; name=\"\(name)\"\r\n")
data.append(utf8String: "Content-Type: text/plain\r\n\r\n")
data.append(utf8String: "\(serialized)\r\n")
case .file(name: let name, filename: let filename, data: let content):
guard let filename, let content, let contentString = String(data: content, encoding: .ascii) else { return }
data.append(utf8String: "--\(boundary)\r\n")
data.append(utf8String: "Content-Disposition: multipart/form-data; name=\"\(name)\"; filename=\"\(filename)\"\r\n")
data.append(utf8String: "Content-Type: text/plain\r\n\r\n")
data.append(utf8String: "\(contentString)\r\n")
}
}
data.append(utf8String: "--\(boundary)--")
return (boundary: boundary, data: data)
}
func serializeFormData(with formBodySerializable: FormBodySerializable) throws -> Data? {
let encoded = (try formBodySerializable.serializedFormParameters(formatOverride: nil))
.compactMap { parameter -> (String, String)? in
guard let serialized = parameter.serialized else { return nil }
return (parameter.name, serialized)
}
.map { (name, serialized) in
return "\(name)=\(serialized)"
}
.joined(separator: "&")
return encoded.data(using: .utf8)
}
fileprivate extension Data {
mutating func append(utf8String: String) {
if let data = utf8String.data(using: .utf8) {
append(data)
}
}
}

View File

@@ -0,0 +1,17 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
func jsonEncoder() -> JSONEncoder {
let jsonEncoder = JSONEncoder()
// Sort keys to make this easier to test resulting JSON.
jsonEncoder.outputFormatting = [.sortedKeys]
return jsonEncoder
}
func serializeEncodable(_ encodable: Encodable?) throws -> String? {
guard let encodable else { return nil }
let data = try jsonEncoder().encode(encodable)
return String(data: data, encoding: .utf8)
}

View File

@@ -0,0 +1,7 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
func namedQueryParameters(from serializable: Serializable, name: String, format: SerializableFormat) throws -> [QueryParameter] {
return try serializable.serializeQueryParameters(with: format).mapKeys { _ in [name] }
}

View File

@@ -0,0 +1,102 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
struct SerializedParameter {
let name: String
let serialized: String?
}
protocol ParameterDefaults {
func defaultSerializedPathParameter(for key: String) throws -> String?
func defaultQueryParameter(for key: String) -> AnyValue?
}
// MARK: - Serialization Types
protocol PathParameterSerializable {
func serializedPathParameters(formatOverride: SerializableFormat?) throws -> [String: String]
}
protocol QueryParameterSerializable {
func serializedQueryParameters(with parameterDefaults: ParameterDefaults?, formatOverride: SerializableFormat?) throws -> [QueryParameter]
}
protocol HeaderParameterSerializable {
func serializedHeaderParameters() throws -> [SerializedParameter]
}
enum MultipartFormParameter {
case value(name: String, serialized: String?)
case file(name: String, filename: String?, data: Data?)
}
protocol MultipartFormBodySerializable {
func serializedMultipartFormParameters(formatOverride: SerializableFormat?) throws -> [MultipartFormParameter]
}
protocol FormBodySerializable {
func serializedFormParameters(formatOverride: SerializableFormat?) throws -> [SerializedParameter]
}
// MARK: - Models
func serializePathParameterSerializable(
_ pathParameterSerializable: PathParameterSerializable,
with format: SerializableFormat
) throws -> String {
let fields = try pathParameterSerializable
.serializedPathParameters(formatOverride: format)
.map { (key, value) in
SerializedParameter(name: key, serialized: value)
}
.sorted { a, b in
a.name < b.name
}
return serializeModel(with: fields, format: format)
}
func serializeQueryParameterSerializable(
_ queryParameterSerializable: QueryParameterSerializable,
with format: SerializableFormat
) throws -> String {
let fields = try queryParameterSerializable
.serializedQueryParameters(with: nil, formatOverride: format)
.compactMap { queryParameter -> SerializedParameter? in
guard let key = queryParameter.key.last else { return nil }
return SerializedParameter(name: key, serialized: queryParameter.serialized)
}
return serializeModel(with: fields, format: format)
}
func serializeModel(
with fields: [SerializedParameter],
format: SerializableFormat
) -> String {
return fields.map { field in
guard let serialized = field.serialized else { return nil }
if format.explode {
return "\(field.name)=\(serialized)"
} else {
return "\(field.name)\(format.separator)\(serialized)"
}
}.compactMap { $0 }.joined(separator: format.separator)
}
// MARK: - Maps
extension Dictionary: MultipartFormBodySerializable where Key == String, Value: Serializable {
func serializedMultipartFormParameters(formatOverride: SerializableFormat?) throws -> [MultipartFormParameter] {
return try map { key, value in
return .value(name: key, serialized: try value.serialize(with: formatOverride ?? .multipart))
}
}
}
extension Dictionary: FormBodySerializable where Key == String, Value: Serializable {
func serializedFormParameters(formatOverride: SerializableFormat?) throws -> [SerializedParameter] {
return try map { key, value in
return SerializedParameter(name: key, serialized: try value.serialize(with: formatOverride ?? .form(explode: false)))
}
}
}

View File

@@ -0,0 +1,232 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
// MARK: - Wrappers
/// An internal type used to aid in serializing request data and deserializing response data.
///
/// > Important: This type should not be used directly.
@propertyWrapper public struct DecimalSerialized<Value>: Codable, Serializable where Value: DoubleConvertible {
// This property wrapper ensures that we (de)serialize values as Decimals to avoid floating-point rounding errors.
public var wrappedValue: Value
public init(wrappedValue: Value) {
self.wrappedValue = wrappedValue
}
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
wrappedValue = try Value.decodeValue(with: container)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
if let double = wrappedValue.toDouble() {
try container.encode(Decimal(double))
}
}
// MARK: - Serializable
func serialize(with format: SerializableFormat) throws -> String {
return wrappedValue.toDouble().map { String($0) } ?? ""
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return [QueryParameter(key: [], serialized: try serialize(with: format))]
}
}
extension DecimalSerialized: CustomStringConvertible where Value: CustomStringConvertible {
public var description: String {
return wrappedValue.description
}
}
/// An internal type used to aid in serializing request data and deserializing response data.
///
/// > Important: This type should not be used directly.
@propertyWrapper public struct DateTime<Value>: Codable, Serializable where Value: DateConvertible {
// This property wrapper ensures that we (de)serialize Swift Dates in the correct datetime format.
public var wrappedValue: Value
public init(wrappedValue: Value) {
self.wrappedValue = wrappedValue
}
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
wrappedValue = try Value.decodeValue(with: container, formatter: dateTimeFormatter)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
if let formatted = wrappedValue.formattedString(with: dateTimeFormatter) {
try container.encode(formatted)
}
}
// MARK: - Serializable
func serialize(with format: SerializableFormat) throws -> String {
return wrappedValue.formattedString(with: dateTimeFormatter) ?? ""
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return [QueryParameter(key: [], serialized: try serialize(with: format))]
}
}
extension DateTime: CustomStringConvertible where Value: CustomStringConvertible {
public var description: String {
return wrappedValue.description
}
}
/// An internal type used to aid in serializing request data and deserializing response data.
///
/// > Important: This type should not be used directly.
@propertyWrapper public struct DateOnly<Value>: Codable, Serializable where Value: DateConvertible {
// This property wrapper ensures that we (de)serialize dates in the date-only format, as Date doesn't distinguish between these types.
public var wrappedValue: Value
public init(wrappedValue: Value) {
self.wrappedValue = wrappedValue
}
public init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
wrappedValue = try Value.decodeValue(with: container, formatter: dateOnlyFormatter)
}
public func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
if let formatted = wrappedValue.formattedString(with: dateOnlyFormatter) {
try container.encode(formatted)
}
}
// MARK: - Serializable
func serialize(with format: SerializableFormat) throws -> String {
return wrappedValue.formattedString(with: dateOnlyFormatter) ?? ""
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return [QueryParameter(key: [], serialized: try serialize(with: format))]
}
}
extension DateOnly: CustomStringConvertible where Value: CustomStringConvertible {
public var description: String {
return wrappedValue.description
}
}
// MARK: - Formatters
private let dateTimeFormatter = {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
return dateFormatter
}()
private let dateOnlyFormatter = {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
return dateFormatter
}()
// MARK: - Helpers
/// An internal type used to aid in serializing request data.
///
/// > Important: This type should not be used directly.
public protocol DoubleConvertible {
func toDouble() -> Double?
static func decodeValue(with container: SingleValueDecodingContainer) throws -> Self
}
extension Double: DoubleConvertible {
public static func decodeValue(with container: SingleValueDecodingContainer) throws -> Double {
return try container.decode(Double.self)
}
public func toDouble() -> Double? {
return self
}
}
extension Optional: DoubleConvertible where Wrapped == Double {
public static func decodeValue(with container: SingleValueDecodingContainer) throws -> Optional<Double> {
if container.decodeNil() {
return nil
} else {
return try container.decode(Double.self)
}
}
public func toDouble() -> Double? {
return self
}
}
/// An internal type used to aid in serializing request data.
///
/// > Important: This type should not be used directly.
public protocol DateConvertible {
func toDate() -> Date?
func formattedString(with formatter: DateFormatter) -> String?
static func decodeValue(with container: SingleValueDecodingContainer, formatter: DateFormatter) throws -> Self
}
extension Date: DateConvertible {
public static func decodeValue(with container: SingleValueDecodingContainer, formatter: DateFormatter) throws -> Date {
let string = try container.decode(String.self)
guard let date = formatter.date(from: string) else {
throw DecodingError.dataCorruptedError(
in: container,
debugDescription: "Invalid date string value '\(string)'"
)
}
return date
}
public func toDate() -> Date? {
return self
}
public func formattedString(with formatter: DateFormatter) -> String? {
return formatter.string(from: self)
}
}
extension Optional: DateConvertible where Wrapped == Date {
public static func decodeValue(with container: SingleValueDecodingContainer, formatter: DateFormatter) throws -> Optional<Date> {
if container.decodeNil() {
return nil
} else {
let string = try container.decode(String.self)
guard let date = formatter.date(from: string) else {
throw DecodingError.dataCorruptedError(
in: container,
debugDescription: "Invalid date string value '\(string)'"
)
}
return date
}
}
public func toDate() -> Date? {
return self
}
public func formattedString(with formatter: DateFormatter) -> String? {
return self.map { formatter.string(from: $0) }
}
}

View File

@@ -0,0 +1,78 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
func queryString(from queryParameters: [QueryParameter]) -> String {
return queryParameters
.sorted { qp1, qp2 in
if qp1.key == qp2.key {
return qp1.index < qp2.index
}
// Lexicographically sort components.
for (c1, c2) in zip(qp1.key, qp2.key) {
if c1 < c2 { return true }
else if c1 > c2 { return false }
}
return true
}.compactMap { queryParam in
guard
let encodedName = percentEncode(string: queryParameterName(from: queryParam.key)),
let encodedValue = percentEncode(string: queryParam.serialized)
else { return nil }
return "\(encodedName)=\(encodedValue)"
}.joined(separator: "&")
}
// Helps build nested and exploded query parameters.
class QueryParameterBuilder {
private var queryParameters: [QueryParameter] = []
func addQueryParameters(from serializable: Serializable?, named name: String, format: SerializableFormat, parameterDefaults: ParameterDefaults?) throws {
guard let serializable = serializable ?? parameterDefaults?.defaultQueryParameter(for: name) else { return }
if format.explode {
queryParameters.append(
contentsOf: try serializable
.serializeQueryParameters(with: format)
.mapKeys { parameterKey(from: $0, nameOverride: name, with: format) }
)
} else {
queryParameters.append(QueryParameter(key: [name], serialized: try serializable.serialize(with: format)))
}
}
func addJSONQueryParameter(named name: String, with encodable: Encodable?) throws {
guard let encodable, let encoded = try serializeEncodable(encodable) else { return }
queryParameters.append(QueryParameter(key: [name], serialized: encoded))
}
func build() -> [QueryParameter] {
return queryParameters
}
}
extension Array where Element == QueryParameter {
func mapKeys(_ f: ([String]) -> [String]) -> [QueryParameter] {
return map { QueryParameter(key: f($0.key), serialized: $0.serialized, index: $0.index) }
}
}
private func parameterKey(from key: [String], nameOverride: String, with format: SerializableFormat) -> [String] {
if format.isDeep {
return [nameOverride] + key
} else {
return key.isEmpty ? [nameOverride] : key
}
}
private let allowedPercentEncodingCharacters = CharacterSet.alphanumerics.union(CharacterSet(charactersIn: "-."))
private func percentEncode(string: String) -> String? {
return string.addingPercentEncoding(withAllowedCharacters: allowedPercentEncodingCharacters)
}
private func queryParameterName(from key: [String]) -> String {
guard let first = key.first else { return "" }
let rest = key.dropFirst()
return "\(first)\(rest.map { "[\($0)]" }.joined())"
}

View File

@@ -0,0 +1,15 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
enum SecurityParameter {
case httpBasic(username: String?, password: String?)
case httpBearer(value: String?)
case apiKey(name: String, value: String?)
case oauth2(name: String, value: String?)
case openIdConnect(name: String, value: String?)
}
protocol SecurityParameterProviding {
func securityParameters() -> [SecurityParameter]
}

View File

@@ -0,0 +1,213 @@
// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
import Foundation
enum QueryParameterSerializableStyle {
case form
case pipeDelimited
case deepObject
}
enum SerializableFormat {
case path(explode: Bool)
case query(style: QueryParameterSerializableStyle, explode: Bool)
case header(explode: Bool)
case multipart
case form(explode: Bool)
var explode: Bool {
switch self {
case .path(let explode), .query(_, let explode), .header(let explode), .form(let explode):
return explode
case .multipart:
return false
}
}
var isDeep: Bool {
switch self {
case .path, .header, .multipart, .form:
return false
case .query(let style, _):
switch style {
case .form, .pipeDelimited:
return false
case .deepObject:
return true
}
}
}
}
struct QueryParameter {
let key: [String]
let serialized: String
let index: Int
init(key: [String], serialized: String) {
self.key = key
self.serialized = serialized
self.index = 0
}
init(key: [String], serialized: String, index: Int) {
self.key = key
self.serialized = serialized
self.index = index
}
}
enum SerializationError: Swift.Error {
case failedToSerializeData
case missingRequiredRequestBody
case invalidSerializationParameter(type: String, format: String)
}
protocol Serializable {
func serialize(with format: SerializableFormat) throws -> String
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter]
}
extension Serializable {
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return []
}
}
// MARK: - Primitives
extension NSNull: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
return "null"
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return [QueryParameter(key: [], serialized: try serialize(with: format))]
}
}
extension String: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
return self
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return [QueryParameter(key: [], serialized: try serialize(with: format))]
}
}
extension Int: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
return String(self)
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return [QueryParameter(key: [], serialized: try serialize(with: format))]
}
}
extension Double: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
return String(self)
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return [QueryParameter(key: [], serialized: try serialize(with: format))]
}
}
extension Bool: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
return String(self)
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return [QueryParameter(key: [], serialized: try serialize(with: format))]
}
}
extension Data: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
guard let string = String(data: self, encoding: .ascii) else {
throw SerializationError.failedToSerializeData
}
return string
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return [QueryParameter(key: [], serialized: try serialize(with: format))]
}
}
extension Optional: Serializable where Wrapped: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
return try self?.serialize(with: format) ?? ""
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
return try self?.serializeQueryParameters(with: format) ?? []
}
}
// MARK: - Collections
extension Array: Serializable where Element: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
return try map { try $0.serialize(with: format) }.joined(separator: format.separator)
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
if format.explode {
return try enumerated().map { index, value in
QueryParameter(key: [], serialized: try value.serialize(with: format), index: index)
}
} else {
return [QueryParameter(key: [], serialized: try serialize(with: format))]
}
}
}
extension Dictionary: Serializable where Key == String, Value: Serializable {
func serialize(with format: SerializableFormat) throws -> String {
// Sort by keys first to make serialization deterministic.
return try map { key, value in
(key, value)
}.sorted {
$0.0 < $1.0
}.map { (key, value) in
if format.explode {
return "\(key)=\(try value.serialize(with: format))"
} else {
return "\(key)\(format.separator)\(try value.serialize(with: format))"
}
}.joined(separator: format.separator)
}
func serializeQueryParameters(with format: SerializableFormat) throws -> [QueryParameter] {
if format.explode {
return try flatMap { key, value in
try value.serializeQueryParameters(with: format).mapKeys { _ in [key] }
}
} else {
return [QueryParameter(key: [], serialized: try serialize(with: format))]
}
}
}
// MARK: - Extensions
extension SerializableFormat {
var separator: String {
switch self {
case .path, .header, .multipart, .form:
return ","
case .query(let style, _):
switch style {
case .form, .deepObject:
return ","
case .pipeDelimited:
return "|"
}
}
}
}