Skip to content

Commit c9e596e

Browse files
Merge pull request #160 from alexanderjordanbaker/RetentionMessaging1.1
Add support for the Retention Messaging API 1.0-1.1 https://developer…
2 parents b89da2e + fae5c2c commit c9e596e

27 files changed

+1330
-69
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Apple App Store Server Python Library
2-
The [Python](https://github.com/apple/app-store-server-library-python) server library for the [App Store Server API](https://developer.apple.com/documentation/appstoreserverapi) and [App Store Server Notifications](https://developer.apple.com/documentation/appstoreservernotifications). Also available in [Swift](https://github.com/apple/app-store-server-library-swift), [Node.js](https://github.com/apple/app-store-server-library-node), and [Java](https://github.com/apple/app-store-server-library-java).
2+
The [Python](https://github.com/apple/app-store-server-library-python) server library for the [App Store Server API](https://developer.apple.com/documentation/appstoreserverapi), [App Store Server Notifications](https://developer.apple.com/documentation/appstoreservernotifications), and [Retention Messaging API](https://developer.apple.com/documentation/retentionmessaging). Also available in [Swift](https://github.com/apple/app-store-server-library-swift), [Node.js](https://github.com/apple/app-store-server-library-node), and [Java](https://github.com/apple/app-store-server-library-java).
33

44
## Table of Contents
55
1. [Installation](#installation)

appstoreserverlibrary/api_client.py

Lines changed: 326 additions & 40 deletions
Large diffs are not rendered by default.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2025 Apple Inc. Licensed under MIT License.
2+
from typing import Optional
3+
from uuid import UUID
4+
5+
from attr import define
6+
import attr
7+
8+
@define
9+
class AlternateProduct:
10+
"""
11+
A switch-plan message and product ID you provide in a real-time response to your Get Retention Message endpoint.
12+
13+
https://developer.apple.com/documentation/retentionmessaging/alternateproduct
14+
"""
15+
16+
messageIdentifier: Optional[UUID] = attr.ib(default=None)
17+
"""
18+
The message identifier of the text to display in the switch-plan retention message.
19+
20+
https://developer.apple.com/documentation/retentionmessaging/messageidentifier
21+
"""
22+
23+
productId: Optional[str] = attr.ib(default=None)
24+
"""
25+
The product identifier of the subscription the retention message suggests for your customer to switch to.
26+
27+
https://developer.apple.com/documentation/retentionmessaging/productid
28+
"""
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Copyright (c) 2025 Apple Inc. Licensed under MIT License.
2+
3+
from typing import Optional
4+
from uuid import UUID
5+
6+
from attr import define
7+
import attr
8+
9+
from .Environment import Environment
10+
from .LibraryUtility import AttrsRawValueAware
11+
12+
@define
13+
class DecodedRealtimeRequestBody(AttrsRawValueAware):
14+
"""
15+
The decoded request body the App Store sends to your server to request a real-time retention message.
16+
17+
https://developer.apple.com/documentation/retentionmessaging/decodedrealtimerequestbody
18+
"""
19+
20+
originalTransactionId: str = attr.ib()
21+
"""
22+
The original transaction identifier of the customer's subscription.
23+
24+
https://developer.apple.com/documentation/retentionmessaging/originaltransactionid
25+
"""
26+
27+
appAppleId: int = attr.ib()
28+
"""
29+
The unique identifier of the app in the App Store.
30+
31+
https://developer.apple.com/documentation/retentionmessaging/appappleid
32+
"""
33+
34+
productId: str = attr.ib()
35+
"""
36+
The unique identifier of the auto-renewable subscription.
37+
38+
https://developer.apple.com/documentation/retentionmessaging/productid
39+
"""
40+
41+
userLocale: str = attr.ib()
42+
"""
43+
The device's locale.
44+
45+
https://developer.apple.com/documentation/retentionmessaging/locale
46+
"""
47+
48+
requestIdentifier: UUID = attr.ib()
49+
"""
50+
A UUID the App Store server creates to uniquely identify each request.
51+
52+
https://developer.apple.com/documentation/retentionmessaging/requestidentifier
53+
"""
54+
55+
signedDate: int = attr.ib()
56+
"""
57+
The UNIX time, in milliseconds, that the App Store signed the JSON Web Signature (JWS) data.
58+
59+
https://developer.apple.com/documentation/retentionmessaging/signeddate
60+
"""
61+
62+
environment: Optional[Environment] = Environment.create_main_attr('rawEnvironment', raw_required=True)
63+
"""
64+
The server environment, either sandbox or production.
65+
66+
https://developer.apple.com/documentation/retentionmessaging/environment
67+
"""
68+
69+
rawEnvironment: str = Environment.create_raw_attr('environment', required=True)
70+
"""
71+
See environment
72+
"""
73+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Copyright (c) 2025 Apple Inc. Licensed under MIT License.
2+
3+
from typing import Optional
4+
from uuid import UUID
5+
6+
from attr import define
7+
import attr
8+
9+
@define
10+
class DefaultConfigurationRequest:
11+
"""
12+
The request body that contains the default configuration information.
13+
14+
https://developer.apple.com/documentation/retentionmessaging/defaultconfigurationrequest
15+
"""
16+
17+
messageIdentifier: Optional[UUID] = attr.ib(default=None)
18+
"""
19+
The message identifier of the message to configure as a default message.
20+
21+
https://developer.apple.com/documentation/retentionmessaging/messageidentifier
22+
"""
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 2025 Apple Inc. Licensed under MIT License.
2+
3+
from typing import Optional, List
4+
5+
from attr import define
6+
import attr
7+
8+
from .GetImageListResponseItem import GetImageListResponseItem
9+
10+
@define
11+
class GetImageListResponse:
12+
"""
13+
A response that contains status information for all images.
14+
15+
https://developer.apple.com/documentation/retentionmessaging/getimagelistresponse
16+
"""
17+
18+
imageIdentifiers: Optional[List[GetImageListResponseItem]] = attr.ib(default=None)
19+
"""
20+
An array of all image identifiers and their image state.
21+
22+
https://developer.apple.com/documentation/retentionmessaging/getimagelistresponseitem
23+
"""
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (c) 2025 Apple Inc. Licensed under MIT License.
2+
3+
from typing import Optional
4+
from uuid import UUID
5+
6+
from attr import define
7+
import attr
8+
9+
from .ImageState import ImageState
10+
from .LibraryUtility import AttrsRawValueAware
11+
12+
@define
13+
class GetImageListResponseItem(AttrsRawValueAware):
14+
"""
15+
An image identifier and state information for an image.
16+
17+
https://developer.apple.com/documentation/retentionmessaging/getimagelistresponseitem
18+
"""
19+
20+
imageIdentifier: Optional[UUID] = attr.ib(default=None)
21+
"""
22+
The identifier of the image.
23+
24+
https://developer.apple.com/documentation/retentionmessaging/imageidentifier
25+
"""
26+
27+
imageState: Optional[ImageState] = ImageState.create_main_attr('rawImageState')
28+
"""
29+
The current state of the image.
30+
31+
https://developer.apple.com/documentation/retentionmessaging/imagestate
32+
"""
33+
34+
rawImageState: Optional[str] = ImageState.create_raw_attr('imageState')
35+
"""
36+
See imageState
37+
"""
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright (c) 2025 Apple Inc. Licensed under MIT License.
2+
3+
from typing import Optional, List
4+
5+
from attr import define
6+
import attr
7+
8+
from .GetMessageListResponseItem import GetMessageListResponseItem
9+
10+
@define
11+
class GetMessageListResponse:
12+
"""
13+
A response that contains status information for all messages.
14+
15+
https://developer.apple.com/documentation/retentionmessaging/getmessagelistresponse
16+
"""
17+
18+
messageIdentifiers: Optional[List[GetMessageListResponseItem]] = attr.ib(default=None)
19+
"""
20+
An array of all message identifiers and their message state.
21+
22+
https://developer.apple.com/documentation/retentionmessaging/getmessagelistresponseitem
23+
"""
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (c) 2025 Apple Inc. Licensed under MIT License.
2+
3+
from typing import Optional
4+
from uuid import UUID
5+
6+
from attr import define
7+
import attr
8+
9+
from .MessageState import MessageState
10+
from .LibraryUtility import AttrsRawValueAware
11+
12+
@define
13+
class GetMessageListResponseItem(AttrsRawValueAware):
14+
"""
15+
A message identifier and status information for a message.
16+
17+
https://developer.apple.com/documentation/retentionmessaging/getmessagelistresponseitem
18+
"""
19+
20+
messageIdentifier: Optional[UUID] = attr.ib(default=None)
21+
"""
22+
The identifier of the message.
23+
24+
https://developer.apple.com/documentation/retentionmessaging/messageidentifier
25+
"""
26+
27+
messageState: Optional[MessageState] = MessageState.create_main_attr('rawMessageState')
28+
"""
29+
The current state of the message.
30+
31+
https://developer.apple.com/documentation/retentionmessaging/messageState
32+
"""
33+
34+
rawMessageState: Optional[str] = MessageState.create_raw_attr('messageState')
35+
"""
36+
See messageState
37+
"""
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2025 Apple Inc. Licensed under MIT License.
2+
3+
from enum import Enum
4+
5+
from .LibraryUtility import AppStoreServerLibraryEnumMeta
6+
7+
class ImageState(str, Enum, metaclass=AppStoreServerLibraryEnumMeta):
8+
"""
9+
The approval state of an image.
10+
11+
https://developer.apple.com/documentation/retentionmessaging/imagestate
12+
"""
13+
PENDING = "PENDING"
14+
APPROVED = "APPROVED"
15+
REJECTED = "REJECTED"

0 commit comments

Comments
 (0)