Files
session-ios/SessionNetworkingKit/SessionPro/Requests/SetPaymentRefundRequestedResponse.swift
Morgan Pretty 92dc30ffcb Bunch of process on pro integration
• Added integration for new refund request
• Wired up the refunding states based on the new data
• Updated code to use strings from libSession instead of hardcoded values
• Updated the code to trigger a pro state refresh when the `proAccessExpiryTimestampMs` on the config changes (ie. another device made a change to the pro configuration)
• Updated logic to drive mocked pro states via the SessionProManager to make the code a bit cleaner
• Updated the handling of pro proofs to sync both active and expired proofs (instead of just active)
• Fixed a bunch of warnings
2025-11-26 14:38:29 +11:00

49 lines
1.8 KiB
Swift

// Copyright © 2025 Rangeproof Pty Ltd. All rights reserved.
import Foundation
import SessionUtil
import SessionUtilitiesKit
public extension Network.SessionPro {
struct SetPaymentRefundRequestedResponse: Decodable, Equatable {
public let header: ResponseHeader
public let version: UInt8
public let updated: Bool
public init(from decoder: any Decoder) throws {
let container: SingleValueDecodingContainer = try decoder.singleValueContainer()
let jsonData: Data
if let data: Data = try? container.decode(Data.self) {
jsonData = data
}
else if let jsonString: String = try? container.decode(String.self) {
guard let data: Data = jsonString.data(using: .utf8) else {
throw DecodingError.dataCorruptedError(
in: container,
debugDescription: "Invalid UTF-8 in JSON string" // stringlint:ignore
)
}
jsonData = data
}
else {
let anyValue: AnyCodable = try container.decode(AnyCodable.self)
jsonData = try JSONEncoder().encode(anyValue)
}
var result = jsonData.withUnsafeBytes { bytes in
session_pro_backend_set_payment_refund_requested_response_parse(
bytes.baseAddress?.assumingMemoryBound(to: CChar.self),
jsonData.count
)
}
defer { session_pro_backend_set_payment_refund_requested_response_free(&result) }
self.header = ResponseHeader(result.header)
self.version = result.version
self.updated = result.updated
}
}
}