diff --git a/omnivoreql/omnivoreql.py b/omnivoreql/omnivoreql.py index 0b5c307..470fd4e 100644 --- a/omnivoreql/omnivoreql.py +++ b/omnivoreql/omnivoreql.py @@ -54,22 +54,24 @@ def save_url(self, url: str, labels: List[str] = None): "clientRequestId": str(uuid.uuid4()), "source": "api", "url": url, - "labels": labels + "labels": labels, } - } + }, ) - def save_page(self, url: str, original_content: str): + def save_page(self, url: str, original_content: str, labels: List[str] = None): """ Save a page with html content to Omnivore. :param url: The URL of the page to save. :param original_content: The original html content of the page. + :param labels: The labels to assign to the item. """ + labels = [] if labels is None else [{"name": x} for x in labels] mutation = gql( """ - mutation { - savePage(input: { clientRequestId: "%s", source: "api", url: "%s", originalContent:"%s" }) { + mutation SavePage($input: SavePageInput!) { + savePage(input: $input) { ... on SaveSuccess { url clientRequestId @@ -81,9 +83,19 @@ def save_page(self, url: str, original_content: str): } } """ - % (uuid.uuid4(), url, original_content) ) - return self.client.execute(mutation) + return self.client.execute( + mutation, + variable_values={ + "input": { + "clientRequestId": str(uuid.uuid4()), + "source": "api", + "url": url, + "originalContent": original_content, + "labels": labels, + } + }, + ) def get_profile(self): """ @@ -459,10 +471,5 @@ def delete_article(self, article_id: str): ) return self.client.execute( mutation, - variable_values={ - "input": { - "articleID": article_id, - "bookmark": False - } - } + variable_values={"input": {"articleID": article_id, "bookmark": False}}, )