@@ -366,6 +366,62 @@ const printInput = (inputType) => {
366366 lines . push ( '' ) ;
367367 return ;
368368 }
369+ // Custom Decodable for DiscountOfferInputIOS to handle String -> Double conversion
370+ if ( inputType . name === 'DiscountOfferInputIOS' ) {
371+ addDocComment ( lines , inputType . description ) ;
372+ lines . push ( 'public struct DiscountOfferInputIOS: Codable {' ) ;
373+ lines . push ( ' public var identifier: String' ) ;
374+ lines . push ( ' public var keyIdentifier: String' ) ;
375+ lines . push ( ' public var nonce: String' ) ;
376+ lines . push ( ' public var signature: String' ) ;
377+ lines . push ( ' public var timestamp: Double' ) ;
378+ lines . push ( '' ) ;
379+ lines . push ( ' public init(identifier: String, keyIdentifier: String, nonce: String, signature: String, timestamp: Double) {' ) ;
380+ lines . push ( ' self.identifier = identifier' ) ;
381+ lines . push ( ' self.keyIdentifier = keyIdentifier' ) ;
382+ lines . push ( ' self.nonce = nonce' ) ;
383+ lines . push ( ' self.signature = signature' ) ;
384+ lines . push ( ' self.timestamp = timestamp' ) ;
385+ lines . push ( ' }' ) ;
386+ lines . push ( '' ) ;
387+ lines . push ( ' private enum CodingKeys: String, CodingKey {' ) ;
388+ lines . push ( ' case identifier, keyIdentifier, nonce, signature, timestamp' ) ;
389+ lines . push ( ' }' ) ;
390+ lines . push ( '' ) ;
391+ lines . push ( ' public init(from decoder: Decoder) throws {' ) ;
392+ lines . push ( ' let container = try decoder.container(keyedBy: CodingKeys.self)' ) ;
393+ lines . push ( ' identifier = try container.decode(String.self, forKey: .identifier)' ) ;
394+ lines . push ( ' keyIdentifier = try container.decode(String.self, forKey: .keyIdentifier)' ) ;
395+ lines . push ( ' nonce = try container.decode(String.self, forKey: .nonce)' ) ;
396+ lines . push ( ' signature = try container.decode(String.self, forKey: .signature)' ) ;
397+ lines . push ( '' ) ;
398+ lines . push ( ' // Flexible timestamp decoding: accept Double or String' ) ;
399+ lines . push ( ' if let timestampDouble = try? container.decode(Double.self, forKey: .timestamp) {' ) ;
400+ lines . push ( ' timestamp = timestampDouble' ) ;
401+ lines . push ( ' } else if let timestampString = try? container.decode(String.self, forKey: .timestamp),' ) ;
402+ lines . push ( ' let timestampDouble = Double(timestampString) {' ) ;
403+ lines . push ( ' timestamp = timestampDouble' ) ;
404+ lines . push ( ' } else {' ) ;
405+ lines . push ( ' throw DecodingError.dataCorruptedError(' ) ;
406+ lines . push ( ' forKey: .timestamp,' ) ;
407+ lines . push ( ' in: container,' ) ;
408+ lines . push ( ' debugDescription: "timestamp must be a number or numeric string"' ) ;
409+ lines . push ( ' )' ) ;
410+ lines . push ( ' }' ) ;
411+ lines . push ( ' }' ) ;
412+ lines . push ( '' ) ;
413+ lines . push ( ' public func encode(to encoder: Encoder) throws {' ) ;
414+ lines . push ( ' var container = encoder.container(keyedBy: CodingKeys.self)' ) ;
415+ lines . push ( ' try container.encode(identifier, forKey: .identifier)' ) ;
416+ lines . push ( ' try container.encode(keyIdentifier, forKey: .keyIdentifier)' ) ;
417+ lines . push ( ' try container.encode(nonce, forKey: .nonce)' ) ;
418+ lines . push ( ' try container.encode(signature, forKey: .signature)' ) ;
419+ lines . push ( ' try container.encode(timestamp, forKey: .timestamp)' ) ;
420+ lines . push ( ' }' ) ;
421+ lines . push ( '}' ) ;
422+ lines . push ( '' ) ;
423+ return ;
424+ }
369425 if ( inputType . name === 'RequestPurchaseProps' ) {
370426 addDocComment ( lines , inputType . description ) ;
371427 lines . push ( 'public struct RequestPurchaseProps: Codable {' ) ;
0 commit comments