-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
136 additions
and
5 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
23 changes: 23 additions & 0 deletions
23
pyopenproject/business/services/command/notification/find.py
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,23 @@ | ||
from pyopenproject.api_connection.exceptions.request_exception import RequestError | ||
from pyopenproject.api_connection.requests.get_request import GetRequest | ||
from pyopenproject.business.exception.business_error import BusinessError | ||
from pyopenproject.business.services.command.find_list_command import FindListCommand | ||
from pyopenproject.business.services.command.notification.notification_command import NotificationCommand | ||
from pyopenproject.model.notification import Notification | ||
|
||
|
||
class Find(NotificationCommand): | ||
|
||
def __init__(self, connection, notification_id): | ||
super().__init__(connection) | ||
self.notification_id = notification_id | ||
|
||
def execute(self): | ||
try: | ||
json_obj = GetRequest( | ||
self.connection, f"{self.CONTEXT}/{self.notification_id}",).execute() | ||
return Notification(json_obj) | ||
|
||
except RequestError as re: | ||
raise BusinessError( | ||
f"Error finding notifications:{re.args}") |
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
26 changes: 26 additions & 0 deletions
26
pyopenproject/business/services/command/notification/read.py
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,26 @@ | ||
from pyopenproject.api_connection.exceptions.request_exception import RequestError | ||
from pyopenproject.api_connection.requests.post_request import PostRequest | ||
from pyopenproject.business.exception.business_error import BusinessError | ||
from pyopenproject.business.services.command.notification.notification_command import NotificationCommand | ||
from pyopenproject.model.notification import Notification | ||
import json | ||
|
||
|
||
class Read(NotificationCommand): | ||
|
||
def __init__(self, connection, notification_id, filters): | ||
super().__init__(connection) | ||
self.filters = json.dumps({'filters': filters}) | ||
self.notification_id = notification_id | ||
|
||
def execute(self): | ||
try: | ||
response = PostRequest(connection=self.connection, | ||
headers={ | ||
"Content-Type": "application/json"}, | ||
context=f"{self.CONTEXT}/{self.notification_id}/read_ian", | ||
json=self.filters).execute() | ||
return response | ||
except RequestError as re: | ||
raise BusinessError( | ||
f"Error creating project form: {self.form.name}") from re |
26 changes: 26 additions & 0 deletions
26
pyopenproject/business/services/command/notification/read_all.py
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,26 @@ | ||
from pyopenproject.api_connection.exceptions.request_exception import RequestError | ||
from pyopenproject.api_connection.requests.post_request import PostRequest | ||
from pyopenproject.business.exception.business_error import BusinessError | ||
from pyopenproject.business.services.command.find_list_command import FindListCommand | ||
from pyopenproject.business.services.command.notification.notification_command import NotificationCommand | ||
from pyopenproject.model.notification import Notification | ||
import json | ||
|
||
|
||
class ReadAll(NotificationCommand): | ||
|
||
def __init__(self, connection, filters): | ||
super().__init__(connection) | ||
self.filters = json.dumps([{'filters':filters}]) | ||
|
||
def execute(self): | ||
try: | ||
response = PostRequest(connection=self.connection, | ||
headers={ | ||
"Content-Type": "application/json"}, | ||
context=f"{self.CONTEXT}/read_ian", | ||
json=self.filters).execute() | ||
return response | ||
except RequestError as re: | ||
raise BusinessError( | ||
f"Error creating project form: {self.form.name}") from re |
26 changes: 26 additions & 0 deletions
26
pyopenproject/business/services/command/notification/unread.py
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,26 @@ | ||
from pyopenproject.api_connection.exceptions.request_exception import RequestError | ||
from pyopenproject.api_connection.requests.post_request import PostRequest | ||
from pyopenproject.business.exception.business_error import BusinessError | ||
from pyopenproject.business.services.command.notification.notification_command import NotificationCommand | ||
from pyopenproject.model.notification import Notification | ||
import json | ||
|
||
|
||
class UnRead(NotificationCommand): | ||
|
||
def __init__(self, connection, notification_id, filters): | ||
super().__init__(connection) | ||
self.filters = json.dumps({'filters': filters}) | ||
self.notification_id = notification_id | ||
|
||
def execute(self): | ||
try: | ||
response = PostRequest(connection=self.connection, | ||
headers={ | ||
"Content-Type": "application/json"}, | ||
context=f"{self.CONTEXT}/{self.notification_id}/unread_ian", | ||
json=self.filters).execute() | ||
return response | ||
except RequestError as re: | ||
raise BusinessError( | ||
f"Error creating project form: {self.form.name}") from re |
25 changes: 25 additions & 0 deletions
25
pyopenproject/business/services/command/notification/unread_all.py
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,25 @@ | ||
from pyopenproject.api_connection.exceptions.request_exception import RequestError | ||
from pyopenproject.api_connection.requests.post_request import PostRequest | ||
from pyopenproject.business.exception.business_error import BusinessError | ||
from pyopenproject.business.services.command.notification.notification_command import NotificationCommand | ||
from pyopenproject.model.notification import Notification | ||
import json | ||
|
||
|
||
class UnReadAll(NotificationCommand): | ||
|
||
def __init__(self, connection, filters): | ||
super().__init__(connection) | ||
self.filters = json.dumps({'filters':filters}) | ||
|
||
def execute(self): | ||
try: | ||
response = PostRequest(connection=self.connection, | ||
headers={ | ||
"Content-Type": "application/json"}, | ||
context=f"{self.CONTEXT}/unread_ian", | ||
json=self.filters).execute() | ||
return response | ||
except RequestError as re: | ||
raise BusinessError( | ||
f"Error creating project form: {self.form.name}") from re |
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