Skip to content

Commit

Permalink
fix api calls
Browse files Browse the repository at this point in the history
  • Loading branch information
markusressel committed Sep 28, 2024
1 parent 1e3081d commit 1688230
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
21 changes: 11 additions & 10 deletions keel_telegram_bot/client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def get_tracked(self) -> List[TrackedImage]:
result = [TrackedImage.from_dict(tracked) for tracked in response]
return result

def set_tracked(self, identifier: str, provider: Provider, trigger: Trigger, schedule: str or None) -> None:
def set_tracked(self, identifier: str, provider: Provider, trigger: Trigger,
schedule: PollSchedule or None) -> None:
"""
Set the tracking properties for an image
:param identifier: the identifier of the image
Expand All @@ -71,9 +72,9 @@ def set_tracked(self, identifier: str, provider: Provider, trigger: Trigger, sch
"""
self._do_request(HttpMethod.PUT, self._base_url + "/v1/tracked", json={
"identifier": identifier,
"provider": provider,
"trigger": trigger,
"schedule": schedule,
"provider": provider.value,
"trigger": trigger.value,
"schedule": schedule.value,
})

def set_required_approvals_count(
Expand All @@ -87,7 +88,7 @@ def set_required_approvals_count(
"""
self._do_request(HttpMethod.PUT, self._base_url + "/v1/approvals", json={
"identifier": identifier,
"provider": provider,
"provider": provider.value,
"votesRequired": votes_required,
})

Expand All @@ -100,8 +101,8 @@ def set_policy(self, identifier: str, provider: Provider, policy: Policy) -> Non
"""
self._do_request(HttpMethod.PUT, self._base_url + "/v1/policies", json={
"identifier": identifier,
"provider": provider,
"policy": policy,
"provider": provider.value,
"policy": policy.value,
})

def set_schedule(self, identifier: str, provider: Provider, schedule: PollSchedule) -> None:
Expand All @@ -113,8 +114,8 @@ def set_schedule(self, identifier: str, provider: Provider, schedule: PollSchedu
"""
self._do_request(HttpMethod.PUT, self._base_url + "/v1/schedule", json={
"identifier": identifier,
"provider": provider,
"schedule": schedule,
"provider": provider.value,
"schedule": schedule.value,
})

def set_trigger(self, identifier: str, provider: Provider, trigger: Trigger) -> None:
Expand Down Expand Up @@ -181,7 +182,7 @@ def _run_approval_action(self, id: str, identifier: str, voter: str, action: Act
"id": id,
"identifier": identifier,
"voter": voter,
"action": action,
"action": action.value,
})

def get_stats(self) -> DailyStats:
Expand Down
3 changes: 3 additions & 0 deletions keel_telegram_bot/client/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ def from_value(value: str):
duration = parse_golang_duration(value)
return PollSchedule(duration)

def value(self):
return self.__str__()

def __str__(self):
return f"@every {timedelta_to_golang_duration(self.interval)}"

Expand Down

0 comments on commit 1688230

Please sign in to comment.