def list(cls, **kwargs): """ Retrieve list of existing passes created by owner of API-key If template_id is specified, retrieve only passes associated with that template Other parameters are translated into query-modifiers Note that list() returns abbreviated form of passes. Use get() to retrieve full pass. API call used is v1/pass (GET) @type templateId: int @param templateId: ID of the template used to create new pass @type pageSize: int @param pageSize: Maximum length of list to return [Optional; Default = 10] @type page: int @param page: 1-based index of page into list, based on page_size [Optional; Default = 1] @type order: string @param order: Name of field on which to sort list [Optional; From (ID, Name, Created, Updated)] @type direction: string @param direction: Direction which to sort list [Optional; From (ASC, DESC); Default = DESC] @return: json form of list of pass header descriptions """ request_dict = kwargs request_url = "/pass" return pt_client.pt_get(request_url, request_dict)
def get(cls, template_id): """ Retrieve full-form template specified by template_id API call used is v1/template/<template_id> (GET) @type template_id: int @param template_id: ID of the template to retrieve @return: json form of template full-form description """ request_url = "/template/%s" % (int(template_id)) return pt_client.pt_get(request_url)
def get(cls, pass_id): """ Retrieve existing pass with specified ID API call used is v1/pass/<pass_id> (GET) @type pass_id: int @param pass_id: ID of desired Pass @return: json form of template full-form description """ request_url = "/pass/%d" % int(pass_id) return pt_client.pt_get(request_url, {})
def download(cls, pass_id, destination_path): """ Download pkpass file corresponding to existing pass with specified ID API call used is v1/pass/<pass_id>/download (GET) @type pass_id: int @param pass_id: ID of desired Pass @type destination_path: str @param destination_path: path to receive pass file. Path must exist, and filename must end with ".pkpass" @return: Writes pass to filesystem """ request_url = "/pass/%d/download" % int(pass_id) resp = pt_client.pt_get(request_url) if PassTools.test_mode: return resp elif resp is not None: fh = open(destination_path, "wb") fh.write(resp.content) fh.close()
def list(cls, **kwargs): """ Retrieve list of existing templates created by owner of API-key Optional parameters are translated into query-modifiers Note that list() returns header-only form of templates. Use get() to retrieve full template. API call used is v1/template/headers (GET) @type pageSize: int @param pageSize: Maximum length of list to return [Optional; Default = 10] @type page: int @param page: 1-based index of page into list, based on page_size [Optional; Default = 1] @type order: string @param order: Name of field on which to sort list [Optional; From (ID, Name, Created, Updated)] @type direction: string @param direction: Direction which to sort list [Optional; From (ASC, DESC); Default = DESC] @return: json form of list of template header descriptions """ request_dict = kwargs request_url = "/template/headers" return pt_client.pt_get(request_url, request_dict)