3939# Enum which contains Apprise's notification types
4040# Yes - they are strings but let's stay future proof here
4141class AppriseNotificationType (Enum ):
42- info : apprise .NotifyType .INFO
43- success : apprise .NotifyType .SUCCESS
44- warning : apprise .NotifyType .WARNING
45- failure : apprise .NotifyType .FAILURE
42+ info = apprise .NotifyType .INFO
43+ success = apprise .NotifyType .SUCCESS
44+ warning = apprise .NotifyType .WARNING
45+ failure = apprise .NotifyType .FAILURE
4646
4747
4848@library (scope = "GLOBAL" , auto_keywords = True )
@@ -88,7 +88,7 @@ def __init__(
8888 self .__attachments = self .__transform_apprise_attachments (
8989 attachments = attachments
9090 )
91- self .__notify_type = notify_type
91+ self .__notify_type = self . __transform_notify_type ( notify_type = notify_type )
9292
9393 def __transform_apprise_clients (self , clients : object ):
9494 # we will either accept a list item or a string
@@ -114,6 +114,19 @@ def __transform_apprise_attachments(self, attachments: object):
114114 else :
115115 return attachments
116116
117+ def __transform_notify_type (self , notify_type : object ):
118+
119+ if not notify_type :
120+ raise ValueError ("No value for 'notify_type' has been specified" )
121+
122+ # Convert to lower case and check if it exists in our enum
123+ __nt = notify_type .lower ()
124+ if __nt not in AppriseNotificationType .__members__ :
125+ raise ValueError ("Unsupported value for 'notify_type' has been specified" )
126+
127+ # enum exists, let's get the value
128+ return AppriseNotificationType [__nt ].value
129+
117130 # Python "Getter" methods
118131 #
119132 # Note that adding an additional Robot decorator (@keyword) will not
@@ -144,12 +157,12 @@ def attachments(self):
144157 return self .__attachments
145158
146159 @property
147- def instance (self ):
160+ def apprise_instance (self ):
148161 return self .__apprise_instance
149162
150163 @property
151164 def notify_type (self ):
152- return self .__apprise_instance
165+ return self .__notify_type
153166
154167 # Python "Setter" methods
155168 #
@@ -193,8 +206,6 @@ def attachments(self, attachments: object):
193206
194207 @clients .setter
195208 def clients (self , clients : object ):
196- if not clients :
197- raise ValueError ("No value for 'clients' has been specified" )
198209 self .__clients = self .__transform_apprise_clients (clients = clients )
199210
200211 @apprise_instance .setter
@@ -205,16 +216,7 @@ def apprise_instance(self, apprise_instance: object):
205216
206217 @notify_type .setter
207218 def notify_type (self , notify_type : str ):
208- if not notify_type :
209- raise ValueError ("No value for 'notify_type' has been specified" )
210-
211- # Convert to lower case and check if it exists in our enum
212- __nt = notify_type .lower ()
213- if __nt not in AppriseNotificationType .__members__ :
214- raise ValueError ("Invalid value for 'notify_type' has been specified" )
215-
216- # enum exists, let's get the value
217- self .__notify_type = AppriseNotificationType [__nt ].value
219+ self .__notify_type = self .__transform_notify_type (notify_type = notify_type )
218220
219221 #
220222 # Robot-specific "getter" keywords
@@ -384,7 +386,7 @@ def send_apprise_message(
384386 # otherwise, add the config data to the config object and
385387 # later on add the config object to Apprise
386388 for client in self .clients :
387- if not add_via_config_file :
389+ if not _apprise_config :
388390 logger .debug (msg = f"Attaching client '{ client } '" )
389391 self .apprise_instance .add (client )
390392 else :
@@ -421,4 +423,9 @@ def send_apprise_message(
421423
422424
423425if __name__ == "__main__" :
426+ appr = AppriseLibrary (
427+ body = "My body" , title = "My title" , clients = "SECRET_CLIENT_ID" , notify_type = "info"
428+ )
429+ appr .send_apprise_message ()
430+
424431 pass
0 commit comments