From f1cc08c4c3bfbc844047dd7b6b68bc6fab9baedf Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Wed, 24 Apr 2024 01:57:08 -0600 Subject: initial commit --- Sources/LichessClient/LichessClient.swift | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Sources/LichessClient/LichessClient.swift (limited to 'Sources/LichessClient/LichessClient.swift') diff --git a/Sources/LichessClient/LichessClient.swift b/Sources/LichessClient/LichessClient.swift new file mode 100644 index 0000000..d398538 --- /dev/null +++ b/Sources/LichessClient/LichessClient.swift @@ -0,0 +1,29 @@ +import Foundation +import OpenAPIRuntime +import OpenAPIURLSession + +public struct LichessClient { + // Lichess has a separate endpoint for its tablebase server + internal let underlyingClient: any APIProtocol + internal let underlyingTablebaseClient: any APIProtocol + + internal init(underlyingClient: any APIProtocol, underlyingTablebaseClient: any APIProtocol) { + self.underlyingClient = underlyingClient + self.underlyingTablebaseClient = underlyingTablebaseClient + } + + public init() { + self.init( + underlyingClient: Client( + serverURL: URL(string: "https://lichess.org")!, transport: URLSessionTransport()), + underlyingTablebaseClient: Client( + serverURL: URL(string: "https://tablebase.lichess.ovh")!, transport: URLSessionTransport()) + ) + } + + enum LichessClientError: Error { + case undocumentedResponse(statusCode: Int) + case parsingError(error: Error) + } + +} -- cgit v1.2.3