-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for notifications API in KERIA
- Loading branch information
1 parent
502a2e4
commit 1876985
Showing
10 changed files
with
224 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# -*- encoding: utf-8 -*- | ||
""" | ||
SIGNIFY | ||
signify.app.notifying module | ||
""" | ||
from signify.app.clienting import SignifyClient | ||
from signify.core import httping | ||
|
||
|
||
class Notifications: | ||
""" Domain class for accessing Endpoint Role Authorizations """ | ||
|
||
def __init__(self, client: SignifyClient): | ||
self.client = client | ||
|
||
def list(self, start=0, end=24): | ||
""" Returns list of notifications | ||
Parameters: | ||
start (int): start index of list of notifications, defaults to 0 | ||
end (int): end index of list of notifications, defaults to 24 | ||
Returns: | ||
dict: data with start, end, total and notes of list result | ||
""" | ||
headers = dict(Range=f"notes={start}-{end}") | ||
res = self.client.get(f"/notifications", headers=headers) | ||
cr = res.headers["content-range"] | ||
start, end, total = httping.parseRangeHeader(cr, "notes") | ||
|
||
return dict(start=start, end=end, total=total, notes=res.json()) | ||
|
||
def markAsRead(self, nid): | ||
""" Mark notification as read | ||
Parameters: | ||
nid (str): qb64 SAID of notification to mark as read | ||
Returns: | ||
bool: True means notification marked as read | ||
""" | ||
res = self.client.put(f"/notifications/{nid}", json={}) | ||
return res.status == 202 | ||
|
||
def delete(self, nid): | ||
""" Delete notification | ||
Parameters: | ||
nid(str): qb64 SAID of notification to delete | ||
Returns: | ||
bool: True means notification deleted | ||
""" | ||
res = self.client.delete(path=f"/notifications/{nid}") | ||
return res.status == 202 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.