macOS widgets

This commit is contained in:
Hillel Coren 2023-06-22 12:46:27 +03:00
parent 4fc3f73080
commit 161fe8a773
1 changed files with 19 additions and 11 deletions

View File

@ -52,7 +52,7 @@ struct Provider: IntentTimelineProvider {
var token = company?.token
if (token == "" && !(widgetData?.companies.isEmpty)!) {
print("## WARNING using first token")
print("## WARNING: using first token")
let company = widgetData?.companies.values.first;
token = company?.token ?? ""
}
@ -286,7 +286,7 @@ struct Expenses: Codable {
struct ApiService {
static func post(urlString: String, apiToken: String) async throws -> [String: ApiResult] {
static func post(urlString: String, apiToken: String) async throws -> [String: ApiResult]? {
let url = URL(string: urlString)!
@ -306,7 +306,9 @@ struct ApiService {
print("Error: Failed to serialize data - \(error)")
}
do {
let (data, _) = try await URLSession.shared.data(for: request)
// process data
//print("## Details: \(String(describing: String(data: data, encoding: .utf8)))")
@ -316,6 +318,12 @@ struct ApiService {
return result
} catch {
print("Error: \(error)")
}
return nil
}
static func fixData(data: Data) throws -> Data {