|
|
|
|
@ -88,6 +88,7 @@ public class Services { |
|
|
|
|
) async throws -> V { |
|
|
|
|
let debugURL = request.url?.absoluteString ?? "" |
|
|
|
|
// print("Run \(request.httpMethod ?? "") \(debugURL)") |
|
|
|
|
let date = Date() |
|
|
|
|
let task: (Data, URLResponse) = try await URLSession.shared.data(for: request) |
|
|
|
|
print("\(apiCall.method.rawValue) \(String(describing: T.self)) => \(String(data: task.0, encoding: .utf8) ?? "")") |
|
|
|
|
|
|
|
|
|
@ -99,7 +100,7 @@ public class Services { |
|
|
|
|
try await StoreCenter.main.deleteApiCallById(type: T.self, id: apiCall.id) |
|
|
|
|
|
|
|
|
|
if T.self == GetSyncData.self { |
|
|
|
|
StoreCenter.main.synchronizeContent(task.0) |
|
|
|
|
StoreCenter.main.synchronizeContent(task.0, date: date) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
default: // error |
|
|
|
|
@ -370,6 +371,8 @@ public class Services { |
|
|
|
|
/// - request: The synchronization request |
|
|
|
|
fileprivate func _runGetSyncLogRequest(_ request: URLRequest) async throws { |
|
|
|
|
let debugURL = request.url?.absoluteString ?? "" |
|
|
|
|
let date = Date() |
|
|
|
|
|
|
|
|
|
// print("Run \(request.httpMethod ?? "") \(debugURL)") |
|
|
|
|
let task: (Data, URLResponse) = try await URLSession.shared.data(for: request) |
|
|
|
|
print("\(request.httpMethod ?? "") \(debugURL) => \(String(data: task.0, encoding: .utf8) ?? "")") |
|
|
|
|
@ -379,7 +382,7 @@ public class Services { |
|
|
|
|
print("\(debugURL) ended, status code = \(statusCode)") |
|
|
|
|
switch statusCode { |
|
|
|
|
case 200..<300: // success |
|
|
|
|
StoreCenter.main.synchronizeContent(task.0) |
|
|
|
|
StoreCenter.main.synchronizeContent(task.0, date: date) |
|
|
|
|
default: // error |
|
|
|
|
Logger.log( |
|
|
|
|
"Failed Run \(request.httpMethod ?? "") \(request.url?.absoluteString ?? "")") |
|
|
|
|
|