from passtools.pt_template import Template # API User: # STEP 1: Retrieve your API key from your Account view on the PassTools website my_api_key = "your-key-goes-in-here" # STEP 2: # You'll always configure the api, providing your api key. # This is required! PassTools.configure(api_key = my_api_key) # Let's create a new pass from a template. # Start by retrieving a template using the same method used in Ex1_Templates.py # The first two steps are a bit contrived, since you would know the ID of the template # you wanted to use, but for this example we'll get the whole list and use the latest list_response = Template.list() template_header_list = list_response["templateHeaders"] the_template_id = template_header_list[0]['id'] get_response = Template.get(the_template_id) # Now create a new pass from the template. test_pass = Pass.create(the_template_id, get_response['fieldsModel']) print 25*"#" print "New Pass at start" print test_pass print 25*"#" # Add a location to that pass. Locations are passed as a list of dicts, length 1 or more # A pass can have a maximum of 10 locations
# STEP 2: # You'll always configure the api, providing your api key. # This is required! PassTools.configure(api_key = my_api_key) ####################### # TEMPLATES: ####################### # First, we'll demonstrate using 'list' to retrieve a default list of headers for templates we own print 25*"#" print "Retrieve default list of existing Templates owned by this user" print "Note that the list is accompanied by some meta-info about total template count, page-size, etc." print "And that the list of template headers proper is under the 'templateHeaders' key\n" list_response = Template.list() report_templates(list_response) print 25*"#", "\n" print "Alter pageSize, default sort" list_response = Template.list(pageSize=3) report_templates(list_response) print 25*"#", "\n" print "Alter pageSize, sort by name, ascending" # By the way: available sort order keys are "name", "id", "created", and "updated" list_response = Template.list(pageSize=7, direction="asc", order="Name") report_templates(list_response) print 25*"#", "\n"