Skip to content

Commit

Permalink
feat: allow to use reasons and min_censures in get_given
Browse files Browse the repository at this point in the history
  • Loading branch information
db0 committed Sep 8, 2023
1 parent 2c329f7 commit c283fea
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions pythonseer/censure.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __init__(self, _requestor: Requestor):

def create(
self,
domain: str,
domain,
) -> Optional[dict]:
"""
Create a censure
Expand Down Expand Up @@ -67,6 +67,8 @@ def get_received(
def get_given(
self,
domain_set: set = None,
reasons: list = None,
min_censures: int = 1,
format: Optional[FormatType] = FormatType.FULL
) -> Optional[dict]:
"""
Expand All @@ -75,8 +77,9 @@ def get_given(
If logged-in, defaults to user's home domain
Args:
domain_set (set)
domains (str)
domain_set (set or str)
reasons (list)
min_censures (int)
format (Optional[FormatType], optional): Defaults to FormatType.FULL.
Returns:
Expand All @@ -89,7 +92,13 @@ def get_given(
# Handle sending the domain name as str gracefully
elif type(domain_set) is str:
domain_csv = domain_set
else:
elif type(domain_set) is set:
domain_csv = ','.join(domain_set)
endpoint = f"/censures_given/{domain_csv}{format.get_query('?')}"
else:
raise Exception("'domain' has to be a set or a string")
reasons_query = ''
if reasons is not None:
reasons_csv = ','.join(reasons)
reasons_query = f"&reasons_csv={reasons_csv}"
endpoint = f"/censures_given/{domain_csv}?min_censures={min_censures}{reasons_query}{format.get_query('&')}"
return self._requestor.api(Request.GET, endpoint)

0 comments on commit c283fea

Please sign in to comment.