Model+Pending.swift (1439B)
1 /* 2 * This file is part of GNU Taler, ©2022-25 Taler Systems S.A. 3 * See LICENSE.md 4 */ 5 /** 6 * @author Marc Stibane 7 */ 8 import Foundation 9 import AnyCodable 10 import taler_swift 11 import SymLog 12 13 // MARK: - 14 /// A request to list the backend's currently pending operations. 15 fileprivate struct GetPendingOperations: WalletBackendFormattedRequest { 16 func operation() -> String { "getPendingOperations" } 17 func args() -> Args { Args() } 18 19 struct Args: Encodable {} 20 21 struct Response: Decodable { 22 var pendingOperations: [PendingOperation] 23 } 24 } 25 // MARK: - 26 struct PendingOperation: Codable, Hashable { 27 var type: String 28 var exchangeBaseUrl: String? 29 var id: String 30 var isLongpolling: Bool 31 var givesLifeness: Bool 32 var isDue: Bool 33 var timestampDue: Timestamp 34 35 public func hash(into hasher: inout Hasher) { 36 hasher.combine(type) 37 hasher.combine(exchangeBaseUrl) 38 hasher.combine(id) 39 hasher.combine(isLongpolling) 40 hasher.combine(givesLifeness) 41 hasher.combine(isDue) 42 hasher.combine(timestampDue) 43 } 44 } 45 // MARK: - 46 extension WalletModel { 47 nonisolated func getPendingOperations4711(viewHandles: Bool = false) 48 async throws -> [PendingOperation] { // M for MainActor 49 let request = GetPendingOperations() 50 let response = try await sendRequest(request, viewHandles: viewHandles) 51 return response.pendingOperations 52 } 53 }