Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
237 changes: 231 additions & 6 deletions appstoreserverlibrary/api_client.py

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions appstoreserverlibrary/models/BulletPoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.

from uuid import UUID

from attr import define
import attr

@define
class BulletPoint:
"""
The text and its bullet-point image to include in a retention message’s bulleted list.

https://developer.apple.com/documentation/retentionmessaging/bulletpoint
"""

text: str = attr.ib(validator=attr.validators.max_len(66))
"""
The text of the individual bullet point.

https://developer.apple.com/documentation/retentionmessaging/bulletpointtext
"""

imageIdentifier: UUID = attr.ib()
"""
The identifier of the image to use as the bullet point.

https://developer.apple.com/documentation/retentionmessaging/imageidentifier
"""

altText: str = attr.ib(validator=attr.validators.max_len(150))
"""
The alternative text you provide for the corresponding image of the bullet point.

https://developer.apple.com/documentation/retentionmessaging/alttext
"""
2 changes: 2 additions & 0 deletions appstoreserverlibrary/models/DefaultConfigurationRequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ class DefaultConfigurationRequest:
"""
The message identifier of the message to configure as a default message.

Note: In a future version, this field will become required.

https://developer.apple.com/documentation/retentionmessaging/messageidentifier
"""
21 changes: 21 additions & 0 deletions appstoreserverlibrary/models/DefaultConfigurationResponse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.

from uuid import UUID

from attr import define
import attr

@define
class DefaultConfigurationResponse:
"""
The response body that contains the default configuration information.

https://developer.apple.com/documentation/retentionmessaging/defaultconfigurationresponse
"""

messageIdentifier: UUID = attr.ib()
"""
The message identifier of the retention message you configured as a default.

https://developer.apple.com/documentation/retentionmessaging/messageidentifier
"""
13 changes: 13 additions & 0 deletions appstoreserverlibrary/models/GetImageListResponseItem.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from attr import define
import attr

from .ImageSize import ImageSize
from .ImageState import ImageState
from .LibraryUtility import AttrsRawValueAware

Expand Down Expand Up @@ -34,4 +35,16 @@ class GetImageListResponseItem(AttrsRawValueAware):
rawImageState: Optional[str] = ImageState.create_raw_attr('imageState')
"""
See imageState
"""

imageSize: Optional[ImageSize] = ImageSize.create_main_attr('rawImageSize')
"""
The size of the image.

https://developer.apple.com/documentation/retentionmessaging/imagesize
"""

rawImageSize: Optional[str] = ImageSize.create_raw_attr('imageSize')
"""
See imageSize
"""
14 changes: 14 additions & 0 deletions appstoreserverlibrary/models/HeaderPosition.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.

from enum import Enum

from .LibraryUtility import AppStoreServerLibraryEnumMeta

class HeaderPosition(str, Enum, metaclass=AppStoreServerLibraryEnumMeta):
"""
The position where the header text appears in a message.

https://developer.apple.com/documentation/retentionmessaging/headerposition
"""
ABOVE_BODY = "ABOVE_BODY"
ABOVE_IMAGE = "ABOVE_IMAGE"
14 changes: 14 additions & 0 deletions appstoreserverlibrary/models/ImageSize.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.

from enum import Enum

from .LibraryUtility import AppStoreServerLibraryEnumMeta

class ImageSize(str, Enum, metaclass=AppStoreServerLibraryEnumMeta):
"""
The size of an image.

https://developer.apple.com/documentation/retentionmessaging/imagesize
"""
FULL_SIZE = "FULL_SIZE"
BULLET_POINT = "BULLET_POINT"
49 changes: 49 additions & 0 deletions appstoreserverlibrary/models/PerformanceTestConfig.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.

from typing import Optional

from attr import define
import attr

@define
class PerformanceTestConfig:
"""
An object that enumerates the test configuration parameters.

https://developer.apple.com/documentation/retentionmessaging/performancetestconfig
"""

maxConcurrentRequests: Optional[int] = attr.ib(default=None)
"""
The maximum number of concurrent requests the API allows.

https://developer.apple.com/documentation/retentionmessaging/maxconcurrentrequests
"""

totalRequests: Optional[int] = attr.ib(default=None)
"""
The total number of requests to make during the test.

https://developer.apple.com/documentation/retentionmessaging/totalrequests
"""

totalDuration: Optional[int] = attr.ib(default=None)
"""
The total duration of the test in milliseconds.

https://developer.apple.com/documentation/retentionmessaging/totalduration
"""

responseTimeThreshold: Optional[int] = attr.ib(default=None)
"""
The maximum time your server has to respond when the system calls your Get Retention Message endpoint in the sandbox environment.

https://developer.apple.com/documentation/retentionmessaging/responsetimethreshold
"""

successRateThreshold: Optional[int] = attr.ib(default=None)
"""
The success rate threshold percentage.

https://developer.apple.com/documentation/retentionmessaging/successratethreshold
"""
19 changes: 19 additions & 0 deletions appstoreserverlibrary/models/PerformanceTestRequest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.

from attr import define
import attr

@define
class PerformanceTestRequest:
"""
The request object you provide for a performance test that contains an original transaction identifier.

https://developer.apple.com/documentation/retentionmessaging/performancetestrequest
"""

originalTransactionId: str = attr.ib()
"""
The original transaction identifier of an In-App Purchase you initiate in the sandbox environment, to use as the purchase for this test.

https://developer.apple.com/documentation/retentionmessaging/originaltransactionid
"""
30 changes: 30 additions & 0 deletions appstoreserverlibrary/models/PerformanceTestResponse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.

from typing import Optional

from attr import define
import attr

from .PerformanceTestConfig import PerformanceTestConfig

@define
class PerformanceTestResponse:
"""
The performance test response object.

https://developer.apple.com/documentation/retentionmessaging/performancetestresponse
"""

config: Optional[PerformanceTestConfig] = attr.ib(default=None)
"""
The performance test configuration object.

https://developer.apple.com/documentation/retentionmessaging/performancetestconfig
"""

requestId: Optional[str] = attr.ib(default=None)
"""
The performance test request identifier.

https://developer.apple.com/documentation/retentionmessaging/requestid
"""
49 changes: 49 additions & 0 deletions appstoreserverlibrary/models/PerformanceTestResponseTimes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.

from typing import Optional

from attr import define
import attr

@define
class PerformanceTestResponseTimes:
"""
An object that describes test response times.

https://developer.apple.com/documentation/retentionmessaging/performancetestresponsetimes
"""

average: Optional[int] = attr.ib(default=None)
"""
Average response time in milliseconds.

https://developer.apple.com/documentation/retentionmessaging/average
"""

p50: Optional[int] = attr.ib(default=None)
"""
The 50th percentile response time in milliseconds.

https://developer.apple.com/documentation/retentionmessaging/p50
"""

p90: Optional[int] = attr.ib(default=None)
"""
The 90th percentile response time in milliseconds.

https://developer.apple.com/documentation/retentionmessaging/p90
"""

p95: Optional[int] = attr.ib(default=None)
"""
The 95th percentile response time in milliseconds.

https://developer.apple.com/documentation/retentionmessaging/p95
"""

p99: Optional[int] = attr.ib(default=None)
"""
The 99th percentile response time in milliseconds.

https://developer.apple.com/documentation/retentionmessaging/p99
"""
96 changes: 96 additions & 0 deletions appstoreserverlibrary/models/PerformanceTestResultResponse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.

from typing import Dict, Optional

from attr import define, Attribute
import attr

from .LibraryUtility import AttrsRawValueAware, metadata_key, metadata_type_key
from .PerformanceTestConfig import PerformanceTestConfig
from .PerformanceTestResponseTimes import PerformanceTestResponseTimes
from .PerformanceTestStatus import PerformanceTestStatus
from .SendAttemptResult import SendAttemptResult

def _failures_value_set(self, _: Attribute, value: Optional[Dict[SendAttemptResult, int]]):
new_raw = {k.value: v for k, v in value.items()} if value is not None else None
if new_raw != getattr(self, 'rawFailures'):
object.__setattr__(self, 'rawFailures', new_raw)
return value

def _raw_failures_value_set(self, _: Attribute, value: Optional[Dict[str, int]]):
new_typed = {}
if value is not None:
for k, v in value.items():
if k in SendAttemptResult:
new_typed[SendAttemptResult(k)] = v
new_typed = new_typed if new_typed else None
if new_typed != getattr(self, 'failures'):
object.__setattr__(self, 'failures', new_typed)
return value

@define
class PerformanceTestResultResponse(AttrsRawValueAware):
"""
An object the API returns that describes the performance test results.

https://developer.apple.com/documentation/retentionmessaging/performancetestresultresponse
"""

config: Optional[PerformanceTestConfig] = attr.ib(default=None)
"""
A PerformanceTestConfig object that enumerates the test parameters.

https://developer.apple.com/documentation/retentionmessaging/performancetestconfig
"""

target: Optional[str] = attr.ib(default=None)
"""
The target URL for the performance test.

https://developer.apple.com/documentation/retentionmessaging/target
"""

result: Optional[PerformanceTestStatus] = PerformanceTestStatus.create_main_attr('rawResult')
"""
A PerformanceTestStatus object that describes the overall result of the test.

https://developer.apple.com/documentation/retentionmessaging/performanceteststatus
"""

rawResult: Optional[str] = PerformanceTestStatus.create_raw_attr('result')
"""
See result
"""

successRate: Optional[int] = attr.ib(default=None)
"""
An integer that describes he success rate percentage of the performance test.

https://developer.apple.com/documentation/retentionmessaging/successrate
"""

numPending: Optional[int] = attr.ib(default=None)
"""
An integer that describes the number of pending requests in the performance test.

https://developer.apple.com/documentation/retentionmessaging/numpending
"""

responseTimes: Optional[PerformanceTestResponseTimes] = attr.ib(default=None)
"""
A PerformanceTestResponseTimes object that enumerates the response times measured during the test.

https://developer.apple.com/documentation/retentionmessaging/performancetestresponsetimes
"""

failures: Optional[Dict[SendAttemptResult, int]] = attr.ib(default=None, on_setattr=_failures_value_set, metadata={metadata_key: 'rawFailures', metadata_type_key: 'main'})
"""
A map of server-to-server notification failure reasons and counts that represent the number of failures encountered during the performance test.

https://developer.apple.com/documentation/retentionmessaging/failures
"""

rawFailures: Optional[Dict[str, int]] = attr.ib(default=None, kw_only=True, on_setattr=_raw_failures_value_set, metadata={metadata_key: 'failures', metadata_type_key: 'raw'})
"""
See failures
"""
15 changes: 15 additions & 0 deletions appstoreserverlibrary/models/PerformanceTestStatus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (c) 2026 Apple Inc. Licensed under MIT License.

from enum import Enum

from .LibraryUtility import AppStoreServerLibraryEnumMeta

class PerformanceTestStatus(str, Enum, metaclass=AppStoreServerLibraryEnumMeta):
"""
The status of the performance test.

https://developer.apple.com/documentation/retentionmessaging/performanceteststatus
"""
PENDING = "PENDING"
PASS = "PASS"
FAIL = "FAIL"
Loading