Skip to content

Commit 426ea6b

Browse files
authored
Add "publish" step (#24)
According to the docs this isn't supposed to be needed for schedule changes. But I wanted to get the code in there so it's there if we need it. Signed-off-by: Phil Dibowitz <phil@ipom.com>
1 parent 0ce4b11 commit 426ea6b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

guidebook/sync_guidebook.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ class GuideBook:
7878
"x-rooms": "https://builder.guidebook.com/api/locations/",
7979
"x-maps": "https://builder.guidebook.com/api/maps/",
8080
"x-map-regions": "https://builder.guidebook.com/api/map-regions/",
81+
"publish": "https://builder.guidebook.com/api/guides/{guide}/publish/",
8182
}
8283

8384
COLOR_MAP = {
@@ -493,6 +494,27 @@ def delete_all(self):
493494
self.delete_tracks()
494495
self.delete_rooms()
495496

497+
def publish_updates(self):
498+
response = requests.post(
499+
self.URLS["publish"].format(guide=self.guide),
500+
headers=self.x_headers,
501+
)
502+
503+
if response.status_code == 204:
504+
return
505+
506+
if (
507+
response.status_code == 403
508+
and "no new content" in resp.text.lower()
509+
):
510+
self.logger.info("No changes to publish")
511+
return
512+
513+
self.logger.error("Failed to publish")
514+
self.logger.error("Status: %s" % response.status_code)
515+
self.logger.error("Body: %s" % response.text)
516+
sys.exit(1)
517+
496518

497519
@click.command(context_settings={"help_option_names": ["-h", "--help"]})
498520
@click.option(
@@ -559,6 +581,8 @@ def main(debug, update, delete_all, csv_file, api_file, x_api_file):
559581
ourguide.setup_sessions(ourdata.sessions)
560582
if x_key:
561583
ourguide.setup_x_map_regions()
584+
# unclear exactly when this is needed.
585+
ourguide.publish_updates()
562586

563587

564588
if __name__ == "__main__":

0 commit comments

Comments
 (0)