Skip to content

Commit e880b7f

Browse files
author
Jinlei Zhang
committed
Use UPPER_CASE names for enum members.
Please refer to https://docs.python.org/3/library/enum.html
1 parent eecfbcb commit e880b7f

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

apns2/client.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,23 @@
1616

1717

1818
class NotificationPriority(Enum):
19-
Immediate = '10'
20-
Delayed = '5'
19+
IMMEDIATE = '10'
20+
DELAYED = '5'
2121

2222

2323
class NotificationType(Enum):
24-
Alert = 'alert'
25-
Background = 'background'
26-
VoIP = 'voip'
27-
Complication = 'complication'
28-
FileProvider = 'fileprovider'
24+
ALERT = 'alert'
25+
BACKGROUND = 'background'
26+
VOIP = 'voip'
27+
COMPLICATION = 'complication'
28+
FILEPROVIDER = 'fileprovider'
2929
MDM = 'mdm'
3030

3131

3232
RequestStream = collections.namedtuple('RequestStream', ['stream_id', 'token'])
3333
Notification = collections.namedtuple('Notification', ['token', 'payload'])
3434

35-
DEFAULT_APNS_PRIORITY = NotificationPriority.Immediate
35+
DEFAULT_APNS_PRIORITY = NotificationPriority.IMMEDIATE
3636
CONCURRENT_STREAMS_SAFETY_MAXIMUM = 1000
3737
MAX_CONNECTION_RETRIES = 3
3838

@@ -88,7 +88,7 @@ def watchdog() -> None:
8888
thread.start()
8989

9090
def send_notification(self, token_hex: str, notification: Payload, topic: Optional[str] = None,
91-
priority: NotificationPriority = NotificationPriority.Immediate,
91+
priority: NotificationPriority = NotificationPriority.IMMEDIATE,
9292
expiration: Optional[int] = None, collapse_id: Optional[str] = None) -> None:
9393
stream_id = self.send_notification_async(token_hex, notification, topic, priority, expiration, collapse_id)
9494
result = self.get_notification_result(stream_id)
@@ -100,7 +100,7 @@ def send_notification(self, token_hex: str, notification: Payload, topic: Option
100100
raise exception_class_for_reason(result)
101101

102102
def send_notification_async(self, token_hex: str, notification: Payload, topic: Optional[str] = None,
103-
priority: NotificationPriority = NotificationPriority.Immediate,
103+
priority: NotificationPriority = NotificationPriority.IMMEDIATE,
104104
expiration: Optional[int] = None, collapse_id: Optional[str] = None,
105105
push_type: Optional[NotificationType] = None) -> int:
106106
json_str = json.dumps(notification.dict(), cls=self.__json_encoder, ensure_ascii=False, separators=(',', ':'))
@@ -112,19 +112,19 @@ def send_notification_async(self, token_hex: str, notification: Payload, topic:
112112
if topic is not None:
113113
headers['apns-topic'] = topic
114114
if topic.endswith('.voip'):
115-
inferred_push_type = NotificationType.VoIP.value
115+
inferred_push_type = NotificationType.VOIP.value
116116
elif topic.endswith('.complication'):
117-
inferred_push_type = NotificationType.Complication.value
117+
inferred_push_type = NotificationType.COMPLICATION.value
118118
elif topic.endswith('.pushkit.fileprovider'):
119-
inferred_push_type = NotificationType.FileProvider.value
119+
inferred_push_type = NotificationType.FILEPROVIDER.value
120120
elif any([
121121
notification.alert is not None,
122122
notification.badge is not None,
123123
notification.sound is not None,
124124
]):
125-
inferred_push_type = NotificationType.Alert.value
125+
inferred_push_type = NotificationType.ALERT.value
126126
else:
127-
inferred_push_type = NotificationType.Background.value
127+
inferred_push_type = NotificationType.BACKGROUND.value
128128

129129
if push_type:
130130
inferred_push_type = push_type.value
@@ -166,7 +166,7 @@ def get_notification_result(self, stream_id: int) -> Union[str, Tuple[str, str]]
166166
return data['reason']
167167

168168
def send_notification_batch(self, notifications: Iterable[Notification], topic: Optional[str] = None,
169-
priority: NotificationPriority = NotificationPriority.Immediate,
169+
priority: NotificationPriority = NotificationPriority.IMMEDIATE,
170170
expiration: Optional[int] = None, collapse_id: Optional[str] = None,
171171
push_type: Optional[NotificationType] = None) -> Dict[str, Union[str, Tuple[str, str]]]:
172172
"""

0 commit comments

Comments
 (0)