1+ # Copyright (c) 2023 Apple Inc. Licensed under MIT License.
2+
3+ from typing import Optional , Dict , Any
4+ from attr import define
5+ import attr
6+ from .Message import Message
7+ from .AlternateProduct import AlternateProduct
8+ from .PromotionalOffer import PromotionalOffer
9+
10+ @define
11+ class RealtimeResponseBody :
12+ """
13+ A response you provide to choose, in real time, a retention message the system displays to the customer.
14+
15+ Note: The fields in RealtimeResponseBody are mutually exclusive. Choose the type of retention message
16+ to display, and respond using only the field that represents that message type.
17+
18+ https://developer.apple.com/documentation/retentionmessaging/realtimeresponsebody
19+ """
20+
21+ message : Optional [Message ] = attr .ib (default = None )
22+ """
23+ A retention message that's text-based and can include an optional image.
24+ If you supply this field, don't include the other fields.
25+
26+ https://developer.apple.com/documentation/retentionmessaging/message
27+ """
28+
29+ alternateProduct : Optional [AlternateProduct ] = attr .ib (default = None )
30+ """
31+ A retention message with a switch-plan option.
32+ If you supply this field, don't include the other fields.
33+
34+ https://developer.apple.com/documentation/retentionmessaging/alternateproduct
35+ """
36+
37+ promotionalOffer : Optional [PromotionalOffer ] = attr .ib (default = None )
38+ """
39+ A retention message that includes a promotional offer.
40+ If you supply this field, don't include the other fields.
41+
42+ https://developer.apple.com/documentation/retentionmessaging/promotionaloffer
43+ """
44+
45+ def to_json_dict (self ) -> Dict [str , Any ]:
46+ """
47+ Convert to a dictionary suitable for JSON serialization.
48+ Omits None values to maintain mutual exclusivity of fields.
49+
50+ Example:
51+ response = RealtimeResponseBody(
52+ message=Message(messageIdentifier="msg123")
53+ )
54+ json_data = json.dumps(response.to_json_dict())
55+ # Result: {"message": {"messageIdentifier": "msg123"}}
56+
57+ :return: Dictionary representation suitable for JSON encoding
58+ """
59+ from .LibraryUtility import _get_retention_response_converter
60+ converter = _get_retention_response_converter ()
61+ return converter .unstructure (self )
0 commit comments