Last active
January 18, 2017 20:47
-
-
Save timani/cb414ce7591fb11366dacabd49956b52 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
import frontmatter, markdown | |
# Pivotal Cloud Foundry - Knowledge Base Section | |
section_id = 'XXXX' | |
# Load the markdown from the article | |
article = frontmatter.load('tests/hello-world.markdown') | |
# Extract the Zendesk Article ID | |
zd_article_id = post['zd_article_id'] | |
# Conert to HTML | |
html = markdown.markdown(article['content']) | |
# Check to see if the article Exist | |
# - Read the ID from the front matter | |
if post_id: | |
# 1. If an ID exists then update the article | |
# 2. Read the ID from the front matter of the markdown and search if an article exists | |
curl "https://{subdomain}.zendesk.com/api/v2/help_center/articles/search.json?query={search_string}" \ | |
-v -u {email_address}:{password} | |
if is_valid_id: | |
curl https://{subdomain}.zendesk.com/api/v2/help_center/articles/{id}.json \ | |
-d '{"article": {"promoted": false, "comments_disabled": true, "label_names": ["photo", "tripod"], "locale": "en-us" }}' \ | |
-v -u {email_address}:{password} -X PUT -H "Content-Type: application/json" | |
else: | |
# 3. If no ID exists, create the new article as a draft | |
curl https://{subdomain}.zendesk.com/api/v2/help_center/sections/{id}/articles.json \ | |
-d '{"article": {"title": "How to take pictures in low light", "body": "Use a tripod", "locale": "en-us" }}' \ | |
-v -u {email_address}:{password} -X POST -H "Content-Type: application/json" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment