diff --git a/Development_API.md b/Development_API.md index 4642a85..c20ee82 100644 --- a/Development_API.md +++ b/Development_API.md @@ -10,9 +10,10 @@ * [`details()`](#details-dynamic-view-into-available-notification-services-apprise-offers) * [`async_notify()`](#async_notify--leveraging-await-to-send-notifications) * [The Apprise Asset Object](#the-apprise-asset-object) - * [Pickle Support](#pickle-support) * **Advanced**: * [The Apprise Notification Object](#the-apprise-notification-object) + * **Features**: + * [Pickle Support](#pickle-serialization-support) # Development API @@ -331,7 +332,7 @@ The **AppriseAsset()** object also performs some dynamic _templating_ of the spe | **{TYPE}** | | | | The type of notification being preformed. For example, if the user calling the notify() function specifies a _notify_type_ of _NotifyType.WARNING_, the string _warning_ would be placed as the _{TYPE}_ | | **{XY}** | | | | The image size to use which is in the format of **AAxBB** (as an example 72x72). Depending on the notification service being called; this value will vary. If you plan on defining your own images, you should facilitate the sizes: **32x32**, **72x72**, **128x128**, and **256x256**| -Everytime the **notify()** function is called from the Apprise object, it uses the URL and/or local path and applies all of the templated masked values so that it can figure out what image to display. Here is an example how one might over-ride apprise to suit their own custom project needs: +Every time the **notify()** function is called from the Apprise object, it uses the URL and/or local path and applies all of the templated masked values so that it can figure out what image to display. Here is an example how one might over-ride apprise to suit their own custom project needs: ```python # Import this library import apprise @@ -388,4 +389,37 @@ obj.send( body=u"A test message", title=u"a title", ) +``` + +## Pickle/Serialization Support +You can Serialize your loaded notifications so they can be restored later on: +```python +import apprise +import pickle + +# Instantiate our object +apobj = apprise.Apprise() + +# Add our URLs +apobj.add("json://localhost") +apobj.add("xml://localhost") +apobj.add("form://localhost") +apobj.add("mailto://user:pass@localhost") + +# Now serialize our object for any purpose +serialized = pickle.dumps(apobj) + +# Consider even storing it to disk if you wanted: +with open("myfile.txt", "w") as file: + file.write(serialized) +``` + +With respect to the above example, we could later (or in another application) reload our object back as it was without having to re-add all the URLs again: +```python +# Restore our Apprise Object +apobj = pickle.loads(serialized) + +# Perhaps we previously wrote it to disk, well we can load our data this way as well: +with open("myfile.txt", "r+") as file: + apobj = pickle.loads(file.read()) ``` \ No newline at end of file