fix: formatting code using swiftlint and added env example
This commit is contained in:
parent
a11d671942
commit
d1d0292045
6 changed files with 18 additions and 14 deletions
|
@ -17,15 +17,15 @@ public enum TGHTTPMediaType: String, Equatable {
|
|||
private struct TGEmptyParams: Encodable {}
|
||||
|
||||
public final class VaporTGClient: TGClientPrtcl {
|
||||
|
||||
|
||||
public typealias HTTPMediaType = SwiftTelegramSdk.HTTPMediaType
|
||||
public var log: Logging.Logger = .init(label: "VaporTGClient")
|
||||
private let client: Vapor.Client
|
||||
|
||||
|
||||
public init(client: Vapor.Client) {
|
||||
self.client = client
|
||||
}
|
||||
|
||||
|
||||
@discardableResult
|
||||
public func post<Params: Encodable, Response: Decodable>
|
||||
(
|
||||
|
@ -66,12 +66,12 @@ public final class VaporTGClient: TGClientPrtcl {
|
|||
let telegramContainer: TGTelegramContainer = try clientResponse.content.decode(TGTelegramContainer<Response>.self)
|
||||
return try processContainer(telegramContainer)
|
||||
}
|
||||
|
||||
|
||||
@discardableResult
|
||||
public func post<Response: Decodable>(_ url: URL) async throws -> Response {
|
||||
try await post(url, params: TGEmptyParams(), as: nil)
|
||||
}
|
||||
|
||||
|
||||
private func processContainer<T: Decodable>(_ container: TGTelegramContainer<T>) throws -> T {
|
||||
guard container.ok else {
|
||||
let desc = """
|
||||
|
@ -86,7 +86,7 @@ public final class VaporTGClient: TGClientPrtcl {
|
|||
log.error(error.logMessage)
|
||||
throw error
|
||||
}
|
||||
|
||||
|
||||
guard let result = container.result else {
|
||||
let error = BotError(
|
||||
type: .server,
|
||||
|
@ -95,14 +95,14 @@ public final class VaporTGClient: TGClientPrtcl {
|
|||
log.error(error.logMessage)
|
||||
throw error
|
||||
}
|
||||
|
||||
|
||||
let logString = """
|
||||
|
||||
|
||||
Response:
|
||||
Code: \(container.errorCode ?? 0)
|
||||
Status OK: \(container.ok)
|
||||
Description: \(container.description ?? "Empty")
|
||||
|
||||
|
||||
"""
|
||||
log.trace(logString.logMessage)
|
||||
return result
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/*
|
||||
import Vapor
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue