added KreeRequest as a dependency and adjusted the code to it

This commit is contained in:
Wilhelm Oks
2024-12-20 21:58:06 +01:00
parent d9686dae32
commit d782a2fcf5
11 changed files with 31 additions and 226 deletions
@@ -0,0 +1,16 @@
/// Represents an error coming directly from the devrant API.
public struct DevRantApiError: Swift.Error {
let message: String
}
public extension DevRantApiError {
struct CodingData: Decodable, Swift.Error {
let error: String
}
}
public extension DevRantApiError.CodingData {
var decoded: DevRantApiError {
.init(message: error)
}
}
@@ -0,0 +1,5 @@
import KreeRequest
struct DevRantBackend: Backend {
let baseURL = "https://devrant.com/api/"
}
@@ -0,0 +1,18 @@
import Foundation
import KreeRequest
extension JSONEncoder {
static let devRant: JSONEncoder = {
let encoder = JSONEncoder()
encoder.dateEncodingStrategy = .iso8601
return encoder
}()
}
extension JSONDecoder {
static let devRant: JSONDecoder = {
let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .iso8601WithOptionalFractionalSeconds
return decoder
}()
}