diff --git a/miniflux.py b/miniflux.py index 37d8fd5..fefd9a0 100644 --- a/miniflux.py +++ b/miniflux.py @@ -315,6 +315,15 @@ def toggle_bookmark(self, entry_id: int) -> bool: raise ClientError(response) return True + def save_entry(self, entry_id: int) -> bool: + endpoint = self._get_endpoint(f"/entries/{entry_id}/save") + response = requests.post( + endpoint, headers=self._headers, auth=self._auth, timeout=self._timeout + ) + if response.status_code != 202: + raise ClientError(response) + return True + def get_categories(self) -> List[Dict]: endpoint = self._get_endpoint("/categories") response = requests.get( diff --git a/tests/test_client.py b/tests/test_client.py index 4d9e549..e995df8 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -855,6 +855,25 @@ def test_api_key_auth(self): timeout=30.0, ) + def test_save_entry(self): + requests = _get_request_mock() + expected_result = True + + response = mock.Mock() + response.status_code = 202 + requests.post.return_value = response + + client = miniflux.Client("http://localhost", api_key="secret") + result = client.save_entry(123) + + requests.post.assert_called_once_with( + "http://localhost/v1/entries/123/save", + headers={"X-Auth-Token": "secret"}, + auth=None, + timeout=30.0, + ) + assert result == expected_result + def _get_request_mock(): patcher = mock.patch("miniflux.requests")