mirror of
https://github.com/LukeHagar/plexswift.git
synced 2025-12-06 12:47:44 +00:00
Regeneration
This commit is contained in:
60
Sources/Plexswift/internal/api/_StatisticsAPI.swift
Normal file
60
Sources/Plexswift/internal/api/_StatisticsAPI.swift
Normal 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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user