added KreeRequest as a dependency and adjusted the code to it
This commit is contained in:
@@ -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
|
||||
}()
|
||||
}
|
||||
Reference in New Issue
Block a user