Updated Development_API (markdown)

master
Chris Caron 2023-12-16 14:45:47 -05:00
parent a2fb188e89
commit 1d71787724
1 changed files with 36 additions and 2 deletions

@ -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)
<!--te-->
# Development API
@ -389,3 +390,36 @@ obj.send(
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())
```