Skip to content

Commit 29123bf

Browse files
Merge pull request #6 from tbenhamou/fix-typing-issue
Models: Fix typing issue for optional fields.
2 parents 0203268 + 10ea038 commit 29123bf

27 files changed

+166
-146
lines changed

appstoreserverlibrary/models/AppTransaction.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) 2023 Apple Inc. Licensed under MIT License.
2+
from typing import Optional
23

34
from attr import define
45
import attr
@@ -13,77 +14,77 @@ class AppTransaction:
1314
https://developer.apple.com/documentation/storekit/apptransaction
1415
"""
1516

16-
receiptType: Environment = attr.ib(default=None)
17+
receiptType: Optional[Environment] = attr.ib(default=None)
1718
"""
1819
The server environment that signs the app transaction.
1920
2021
https://developer.apple.com/documentation/storekit/apptransaction/3963901-environment
2122
"""
2223

23-
appAppleId: int = attr.ib(default=None)
24+
appAppleId: Optional[int] = attr.ib(default=None)
2425
"""
2526
The unique identifier the App Store uses to identify the app.
2627
2728
https://developer.apple.com/documentation/storekit/apptransaction/3954436-appid
2829
"""
2930

30-
bundleId: str = attr.ib(default=None)
31+
bundleId: Optional[str] = attr.ib(default=None)
3132
"""
3233
The bundle identifier that the app transaction applies to.
3334
3435
https://developer.apple.com/documentation/storekit/apptransaction/3954439-bundleid
3536
"""
3637

37-
applicationVersion: str = attr.ib(default=None)
38+
applicationVersion: Optional[str] = attr.ib(default=None)
3839
"""
3940
The app version that the app transaction applies to.
4041
4142
https://developer.apple.com/documentation/storekit/apptransaction/3954437-appversion
4243
"""
4344

44-
versionExternalIdentifier: int = attr.ib(default=None)
45+
versionExternalIdentifier: Optional[int] = attr.ib(default=None)
4546
"""
4647
The version external identifier of the app
4748
4849
https://developer.apple.com/documentation/storekit/apptransaction/3954438-appversionid
4950
"""
5051

51-
receiptCreationDate: int = attr.ib(default=None)
52+
receiptCreationDate: Optional[int] = attr.ib(default=None)
5253
"""
5354
The date that the App Store signed the JWS app transaction.
5455
5556
https://developer.apple.com/documentation/storekit/apptransaction/3954449-signeddate
5657
"""
5758

58-
originalPurchaseDate: int = attr.ib(default=None)
59+
originalPurchaseDate: Optional[int] = attr.ib(default=None)
5960
"""
6061
The date the user originally purchased the app from the App Store.
6162
6263
https://developer.apple.com/documentation/storekit/apptransaction/3954448-originalpurchasedate
6364
"""
6465

65-
originalApplicationVersion: str = attr.ib(default=None)
66+
originalApplicationVersion: Optional[str] = attr.ib(default=None)
6667
"""
6768
The app version that the user originally purchased from the App Store.
6869
6970
https://developer.apple.com/documentation/storekit/apptransaction/3954447-originalappversion
7071
"""
7172

72-
deviceVerification: str = attr.ib(default=None)
73+
deviceVerification: Optional[str] = attr.ib(default=None)
7374
"""
7475
The Base64 device verification value to use to verify whether the app transaction belongs to the device.
7576
7677
https://developer.apple.com/documentation/storekit/apptransaction/3954441-deviceverification
7778
"""
7879

79-
deviceVerificationNonce: str = attr.ib(default=None)
80+
deviceVerificationNonce: Optional[str] = attr.ib(default=None)
8081
"""
8182
The UUID used to compute the device verification value.
8283
8384
https://developer.apple.com/documentation/storekit/apptransaction/3954442-deviceverificationnonce
8485
"""
8586

86-
preorderDate: int = attr.ib(default=None)
87+
preorderDate: Optional[int] = attr.ib(default=None)
8788
"""
8889
The date the customer placed an order for the app before it's available in the App Store.
8990

appstoreserverlibrary/models/CheckTestNotificationResponse.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) 2023 Apple Inc. Licensed under MIT License.
2+
from typing import List, Optional
23

34
from attr import define
45
import attr
@@ -13,14 +14,14 @@ class CheckTestNotificationResponse:
1314
https://developer.apple.com/documentation/appstoreserverapi/checktestnotificationresponse
1415
"""
1516

16-
signedPayload: str = attr.ib(default=None)
17+
signedPayload: Optional[str] = attr.ib(default=None)
1718
"""
1819
A cryptographically signed payload, in JSON Web Signature (JWS) format, containing the response body for a version 2 notification.
1920
2021
https://developer.apple.com/documentation/appstoreservernotifications/signedpayload
2122
"""
2223

23-
sendAttempts: "list[SendAttemptItem]" = attr.ib(default=None)
24+
sendAttempts: Optional[List[SendAttemptItem]] = attr.ib(default=None)
2425
"""
2526
An array of information the App Store server records for its attempts to send the TEST notification to your server. The array may contain a maximum of six sendAttemptItem objects.
2627

appstoreserverlibrary/models/ConsumptionRequest.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) 2023 Apple Inc. Licensed under MIT License.
2+
from typing import Optional
23

34
from attr import define
45
import attr
@@ -20,77 +21,77 @@ class ConsumptionRequest:
2021
https://developer.apple.com/documentation/appstoreserverapi/consumptionrequest
2122
"""
2223

23-
customerConsented: bool = attr.ib(default=None)
24+
customerConsented: Optional[bool] = attr.ib(default=None)
2425
"""
2526
A Boolean value that indicates whether the customer consented to provide consumption data to the App Store.
2627
2728
https://developer.apple.com/documentation/appstoreserverapi/customerconsented
2829
"""
2930

30-
consumptionStatus: ConsumptionStatus = attr.ib(default=None)
31+
consumptionStatus: Optional[ConsumptionStatus] = attr.ib(default=None)
3132
"""
3233
A value that indicates the extent to which the customer consumed the in-app purchase.
3334
3435
https://developer.apple.com/documentation/appstoreserverapi/consumptionstatus
3536
"""
3637

37-
platform: Platform = attr.ib(default=None)
38+
platform: Optional[Platform] = attr.ib(default=None)
3839
"""
3940
A value that indicates the platform on which the customer consumed the in-app purchase.
4041
4142
https://developer.apple.com/documentation/appstoreserverapi/platform
4243
"""
4344

44-
sampleContentProvided: bool = attr.ib(default=None)
45+
sampleContentProvided: Optional[bool] = attr.ib(default=None)
4546
"""
4647
A Boolean value that indicates whether you provided, prior to its purchase, a free sample or trial of the content, or information about its functionality.
4748
4849
https://developer.apple.com/documentation/appstoreserverapi/samplecontentprovided
4950
"""
5051

51-
deliveryStatus: DeliveryStatus = attr.ib(default=None)
52+
deliveryStatus: Optional[DeliveryStatus] = attr.ib(default=None)
5253
"""
5354
A value that indicates whether the app successfully delivered an in-app purchase that works properly.
5455
5556
https://developer.apple.com/documentation/appstoreserverapi/deliverystatus
5657
"""
5758

58-
appAccountToken: str = attr.ib(default=None)
59+
appAccountToken: Optional[str] = attr.ib(default=None)
5960
"""
6061
The UUID that an app optionally generates to map a customer's in-app purchase with its resulting App Store transaction.
6162
6263
https://developer.apple.com/documentation/appstoreserverapi/appaccounttoken
6364
"""
6465

65-
accountTenure: AccountTenure = attr.ib(default=None)
66+
accountTenure: Optional[AccountTenure] = attr.ib(default=None)
6667
"""
6768
The age of the customer's account.
6869
6970
https://developer.apple.com/documentation/appstoreserverapi/accounttenure
7071
"""
7172

72-
playTime: PlayTime = attr.ib(default=None)
73+
playTime: Optional[PlayTime] = attr.ib(default=None)
7374
"""
7475
A value that indicates the amount of time that the customer used the app.
7576
7677
https://developer.apple.com/documentation/appstoreserverapi/consumptionrequest
7778
"""
7879

79-
lifetimeDollarsRefunded: LifetimeDollarsRefunded = attr.ib(default=None)
80+
lifetimeDollarsRefunded: Optional[LifetimeDollarsRefunded] = attr.ib(default=None)
8081
"""
8182
A value that indicates the total amount, in USD, of refunds the customer has received, in your app, across all platforms.
8283
8384
https://developer.apple.com/documentation/appstoreserverapi/lifetimedollarsrefunded
8485
"""
8586

86-
lifetimeDollarsPurchased: LifetimeDollarsPurchased = attr.ib(default=None)
87+
lifetimeDollarsPurchased: Optional[LifetimeDollarsPurchased] = attr.ib(default=None)
8788
"""
8889
A value that indicates the total amount, in USD, of in-app purchases the customer has made in your app, across all platforms.
8990
9091
https://developer.apple.com/documentation/appstoreserverapi/lifetimedollarspurchased
9192
"""
9293

93-
userStatus: UserStatus = attr.ib(default=None)
94+
userStatus: Optional[UserStatus] = attr.ib(default=None)
9495
"""
9596
The status of the customer's account.
9697

appstoreserverlibrary/models/Data.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) 2023 Apple Inc. Licensed under MIT License.
2+
from typing import Optional
23

34
from attr import define
45
import attr
@@ -13,42 +14,42 @@ class Data:
1314
https://developer.apple.com/documentation/appstoreservernotifications/data
1415
"""
1516

16-
environment: Environment = attr.ib(default=None)
17+
environment: Optional[Environment] = attr.ib(default=None)
1718
"""
1819
The server environment that the notification applies to, either sandbox or production.
1920
2021
https://developer.apple.com/documentation/appstoreservernotifications/environment
2122
"""
2223

23-
appAppleId: int = attr.ib(default=None)
24+
appAppleId: Optional[int] = attr.ib(default=None)
2425
"""
2526
The unique identifier of an app in the App Store.
2627
2728
https://developer.apple.com/documentation/appstoreservernotifications/appappleid
2829
"""
2930

30-
bundleId: str = attr.ib(default=None)
31+
bundleId: Optional[str] = attr.ib(default=None)
3132
"""
3233
The bundle identifier of an app.
3334
3435
https://developer.apple.com/documentation/appstoreserverapi/bundleid
3536
"""
3637

37-
bundleVersion: str = attr.ib(default=None)
38+
bundleVersion: Optional[str] = attr.ib(default=None)
3839
"""
3940
The version of the build that identifies an iteration of the bundle.
4041
4142
https://developer.apple.com/documentation/appstoreservernotifications/bundleversion
4243
"""
4344

44-
signedTransactionInfo: str = attr.ib(default=None)
45+
signedTransactionInfo: Optional[str] = attr.ib(default=None)
4546
"""
4647
Transaction information signed by the App Store, in JSON Web Signature (JWS) format.
4748
4849
https://developer.apple.com/documentation/appstoreserverapi/jwstransaction
4950
"""
5051

51-
signedRenewalInfo: str = attr.ib(default=None)
52+
signedRenewalInfo: Optional[str] = attr.ib(default=None)
5253
"""
5354
Subscription renewal information, signed by the App Store, in JSON Web Signature (JWS) format.
5455

appstoreserverlibrary/models/ExtendRenewalDateRequest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) 2023 Apple Inc. Licensed under MIT License.
2+
from typing import Optional
23

34
from attr import define
45
import attr
@@ -13,22 +14,22 @@ class ExtendRenewalDateRequest:
1314
https://developer.apple.com/documentation/appstoreserverapi/extendrenewaldaterequest
1415
"""
1516

16-
extendByDays: int = attr.ib(default=None)
17+
extendByDays: Optional[int] = attr.ib(default=None)
1718
"""
1819
The number of days to extend the subscription renewal date.
1920
2021
https://developer.apple.com/documentation/appstoreserverapi/extendbydays
2122
maximum: 90
2223
"""
2324

24-
extendReasonCode: ExtendReasonCode = attr.ib(default=None)
25+
extendReasonCode: Optional[ExtendReasonCode] = attr.ib(default=None)
2526
"""
2627
The reason code for the subscription date extension
2728
2829
https://developer.apple.com/documentation/appstoreserverapi/extendreasoncode
2930
"""
3031

31-
requestIdentifier: str = attr.ib(default=None)
32+
requestIdentifier: Optional[str] = attr.ib(default=None)
3233
"""
3334
A string that contains a unique identifier you provide to track each subscription-renewal-date extension request.
3435

appstoreserverlibrary/models/ExtendRenewalDateResponse.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) 2023 Apple Inc. Licensed under MIT License.
2+
from typing import Optional
23

34
from attr import define
45
import attr
@@ -11,28 +12,28 @@ class ExtendRenewalDateResponse:
1112
https://developer.apple.com/documentation/appstoreserverapi/extendrenewaldateresponse
1213
"""
1314

14-
originalTransactionId: str = attr.ib(default=None)
15+
originalTransactionId: Optional[str] = attr.ib(default=None)
1516
"""
1617
The original transaction identifier of a purchase.
1718
1819
https://developer.apple.com/documentation/appstoreserverapi/originaltransactionid
1920
"""
2021

21-
webOrderLineItemId: str = attr.ib(default=None)
22+
webOrderLineItemId: Optional[str] = attr.ib(default=None)
2223
"""
2324
The unique identifier of subscription-purchase events across devices, including renewals.
2425
2526
https://developer.apple.com/documentation/appstoreserverapi/weborderlineitemid
2627
"""
2728

28-
success: bool = attr.ib(default=None)
29+
success: Optional[bool] = attr.ib(default=None)
2930
"""
3031
A Boolean value that indicates whether the subscription-renewal-date extension succeeded.
3132
3233
https://developer.apple.com/documentation/appstoreserverapi/success
3334
"""
3435

35-
effectiveDate: int = attr.ib(default=None)
36+
effectiveDate: Optional[int] = attr.ib(default=None)
3637
"""
3738
The new subscription expiration date for a subscription-renewal extension.
3839

appstoreserverlibrary/models/HistoryResponse.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Copyright (c) 2023 Apple Inc. Licensed under MIT License.
22

33
from attr import define
4-
from typing import List
4+
from typing import List, Optional
55
import attr
66

77
from .Environment import Environment
@@ -14,42 +14,42 @@ class HistoryResponse:
1414
https://developer.apple.com/documentation/appstoreserverapi/historyresponse
1515
"""
1616

17-
revision: str = attr.ib(default=None)
17+
revision: Optional[str] = attr.ib(default=None)
1818
"""
1919
A token you use in a query to request the next set of transactions for the customer.
2020
2121
https://developer.apple.com/documentation/appstoreserverapi/revision
2222
"""
2323

24-
hasMore: bool = attr.ib(default=None)
24+
hasMore: Optional[bool] = attr.ib(default=None)
2525
"""
2626
A Boolean value indicating whether the App Store has more transaction data.
2727
2828
https://developer.apple.com/documentation/appstoreserverapi/hasmore
2929
"""
3030

31-
bundleId: str = attr.ib(default=None)
31+
bundleId: Optional[str] = attr.ib(default=None)
3232
"""
3333
The bundle identifier of an app.
3434
3535
https://developer.apple.com/documentation/appstoreserverapi/bundleid
3636
"""
3737

38-
appAppleId: int = attr.ib(default=None)
38+
appAppleId: Optional[int] = attr.ib(default=None)
3939
"""
4040
The unique identifier of an app in the App Store.
4141
4242
https://developer.apple.com/documentation/appstoreservernotifications/appappleid
4343
"""
4444

45-
environment: Environment = attr.ib(default=None)
45+
environment: Optional[Environment] = attr.ib(default=None)
4646
"""
4747
The server environment in which you're making the request, whether sandbox or production.
4848
4949
https://developer.apple.com/documentation/appstoreserverapi/environment
5050
"""
5151

52-
signedTransactions: "List[str]" = attr.ib(default=None)
52+
signedTransactions: Optional[List[str]] = attr.ib(default=None)
5353
"""
5454
An array of in-app purchase transactions for the customer, signed by Apple, in JSON Web Signature format.
5555

0 commit comments

Comments
 (0)