mirror of
https://github.com/lux-tel/session-ios.git
synced 2026-10-30 20:38:32 +00:00
• 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
49 lines
1.8 KiB
Swift
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
|
|
}
|
|
}
|
|
}
|