diff --git a/gorse/__init__.py b/gorse/__init__.py index 24bd0fe..639b576 100644 --- a/gorse/__init__.py +++ b/gorse/__init__.py @@ -53,9 +53,16 @@ def list_feedbacks(self, feedback_type: str, user_id: str): return r.json() raise GorseException(r.status_code, r.text) - def get_recommend(self, user_id: str, category: str = "", n: int = 10) -> List[str]: + def get_recommend(self, user_id: str, category: str = "", n: int = 10, offset: int = 0, write_back_type: str = None, + write_back_delay: str = None) -> List[str]: + payload = {"n": n, "offset": offset} + if write_back_type: + payload["write-back-type"] = write_back_type + if write_back_delay: + payload["write-back-delay"] = write_back_delay r = requests.get( - self.entry_point + "/api/recommend/%s/%s?n=%d" % (user_id, category, n), + self.entry_point + "/api/recommend/%s/%s" % (user_id, category), + params=payload, headers={"X-API-Key": self.api_key}, ) if r.status_code == 200: diff --git a/tests/test_gorse.py b/tests/test_gorse.py index ccbf748..b0190ef 100644 --- a/tests/test_gorse.py +++ b/tests/test_gorse.py @@ -116,6 +116,8 @@ def test_recommend(): client = Gorse(GORSE_ENDPOINT, GORSE_API_KEY) recommend = client.get_recommend('100') assert recommend == ['3', '2', '1'] + recommend = client.get_recommend("100", n=1, offset=1) + assert recommend == ["2"] def test_neighbors():