Skip to content

Commit

Permalink
chore: Add support for labels in save_page method
Browse files Browse the repository at this point in the history
  • Loading branch information
yazdipour committed Jun 16, 2024
1 parent bbeb940 commit c81f7ca
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions omnivoreql/omnivoreql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
"""
Expand Down Expand Up @@ -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}},
)

0 comments on commit c81f7ca

Please sign in to comment.