Skip to content

Commit

Permalink
Merge pull request #35 from andrewthetechie/schedule-blank-string
Browse files Browse the repository at this point in the history
Exclude none values when creating and updating
  • Loading branch information
andrewthetechie committed Jan 8, 2022
2 parents 67cbd29 + 376578a commit 818dd54
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/healthchecks_io/client/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ async def create_check(self, new_check: CheckCreate) -> Check:
"""
request_url = self._get_api_request_url("checks/")
response = self.check_response(
await self._client.post(request_url, json=new_check.dict())
await self._client.post(request_url, json=new_check.dict(exclude_none=True))
)
return Check.from_api_result(response.json())

Expand All @@ -118,7 +118,8 @@ async def update_check(self, uuid: str, update_check: CheckCreate) -> Check:
request_url = self._get_api_request_url(f"checks/{uuid}")
response = self.check_response(
await self._client.post(
request_url, json=update_check.dict(exclude_unset=True)
request_url,
json=update_check.dict(exclude_unset=True, exclude_none=True),
)
)
return Check.from_api_result(response.json())
Expand Down
7 changes: 5 additions & 2 deletions src/healthchecks_io/client/sync_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def create_check(self, new_check: CheckCreate) -> Check:
"""
request_url = self._get_api_request_url("checks/")
response = self.check_response(
self._client.post(request_url, json=new_check.dict())
self._client.post(request_url, json=new_check.dict(exclude_none=True))
)
return Check.from_api_result(response.json())

Expand All @@ -163,7 +163,10 @@ def update_check(self, uuid: str, update_check: CheckCreate) -> Check:
"""
request_url = self._get_api_request_url(f"checks/{uuid}")
response = self.check_response(
self._client.post(request_url, json=update_check.dict(exclude_unset=True))
self._client.post(
request_url,
json=update_check.dict(exclude_unset=True, exclude_none=True),
)
)
return Check.from_api_result(response.json())

Expand Down

0 comments on commit 818dd54

Please sign in to comment.