Skip to content

Instantly share code, notes, and snippets.

@frague59
Created February 10, 2021 09:50
Show Gist options
  • Save frague59/cef71de3e7caf1a39e6d33593e35c743 to your computer and use it in GitHub Desktop.
Save frague59/cef71de3e7caf1a39e6d33593e35c743 to your computer and use it in GitHub Desktop.
notify job file method
def notify_create_job_file(self, print_job: PrintJobCreate, pdf_file_path: Path) -> PrintJobFileCreate:
with self.get_api_instance(authenticated=True) as api_instance:
print_job_file = PrintJobFileCreateRequest(
print_job=print_job.pk,
title="Cartes d'identité",
attachment=open(pdf_file_path, "rb"), # noqa
)
try:
api_response = api_instance.printflow_api_job_file_add_create(
print_job_file_create_request=print_job_file
)
logger.info(
f"IdCardNotifier::notify_create_job_file() print_job_file {print_job_file} "
f"CREATED: {pprint.pformat(api_response, indent=2)}"
)
return api_response
except openapi_client.ApiException as e:
logger.error(
f"IdCardNotifier::notify_create_job() Unable to create job file for job {print_job} on "
f"{self.service_url}: {e}"
)
raise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment