Get all the deliverables and associated deliverables to print.
This is a sane, backwards incompatible re-implementation of retrieveToBePrinted.
Arguments:
from_date : The earliest date to retrieve files from. Should be formatted
like "YYYY-MM-DD". Defaults to the client's live date.
to_date : The latest date to retrieve files from. Should be formatted
like "YYYY-MM-DD". Defaults to today's date.
ignore_state : (optional) Ignore the file's print state. Defaults to False.
exclude_electronic_delivery : Default False, excludes documents that should
be delivered electronically.
only_electronic_delivery : Default False, only returns documents that should
be delivered electronically.
include_claims : Default False, if passed as true any claim deliverables
with tbd print state get returned within the same batch.
fields for claim deliverables are exactly the same for policy.
disable_edelivery_filtering : Default False, if passed as true no edelivery
filtering will occur
include_address_fields : Default False, if passed as true the address fields
will be included in the output
Returns:
An JSON string containing an object with two members, consistent ordering
not guaranteed:
processing: Whether or not nightly processing for the to_date
is processing, done, or not started.
files: A list of objects with the policy number, file id, date it
should print, label, and title, parent id or children ids.
For example:
{'processing': 'done',
'files': [{'policy_number': '10-2013-42',
'file_id': 'f6b8f1b0-e4b0-4738-b96d-51c270c76580',
'contact_id': 'c4e448ea-6494-439f-94eb-829a05f8f9f2',
'print_date': '2013-05-21',
'print_state': 'tbd',
'label': 'Declaration',
'title': '10-2013-42 - Declaration',
'batch': page_range(1,5)},
{'policy_number': '10-2013-42',
'file_id': '774f0b38-2b49-4d7c-ae0f-19541841fbeb',
'contact_id': 'c7404bb5-3d07-43c1-bc7b-2caffde84330',
'print_date': '2013-05-21',
'print_state': 'tbd',
'label': null,
'title': 'form-m01a32ll.pdf',
'parent': 'f6b8f1b0-e4b0-4738-b96d-51c270c76580',
'batch': ''}
]
}
To retrieve the file, the file_id item of each object in the list
can be passed to core.uploads.getAttachment as the GET parameter "id".
# This should be in a wiki article or other client-facing documentation
Developer Reference For Using the BritePrint API:
* A normal day's job consists of simply fetching the result of getToBePrinted,
downloading the files, printing them as desired, and then marking them as
printed in BriteCore to prevent duplicate print jobs. The result SHOULD be
parsed as JSON.
* The "processing" member should be checked for the value "done". Any other value
indicates that processing for today is either "incomplete" or "not started".
Implementations SHOULD wait until that value becomes "done" before starting a
day's printing to ensure all files needing to be printed for that day are listed.
* The "files" member contains an array of objects, one for each file.
Stable ordering is not guaranteed, though it should be correct for most use-cases.
* The "policy_number" member in the file object may be used to group and
sort the files by policy number.
* The "revision_id" member in the file object may be used to group and sort
the files by revision id.
* The "file_id" member contains the id to send to the getAttachment method
in BriteCore.
* The "contact_id" member contains the BriteCore contact id of the recipient.
* The "print_date" member may be used to sort by the file's desired print date.
* The "print_state" member is a hint as to whether or not the file has been
printed or not. Possible values are:
- "tbd" (to be determined, that is, not printed yet)
- "do not print" (Never print this.)
- "printed" (already printed at least once.)
- "failed" (marked as a failed print job.)
- "void"
- "silenced"
- "sent"
- "not mailed"
* The "label" member is the type of document. For example, "Declaration" or
"Notice of Cancellation". For forms, this is null.
* The "title" member is the document's title. For regular deliverables, it will
usually be the policy number and label. For forms, this might be something
like "form-m01a3dll.pdf" or "C0A63".
* The "parent" member indicates that this file should be printed in addition to
its parent. This is for additional forms for Declarations, for example.
This will not be present if there is no parent document.
* The "children" member indicates that this file is a composite of the documents
listed under that key.
* The "batch" member indicates the batch, if any, that this document was classified
under by `merge_mailings`. This will always be empty for forms (if parent is present)
or if the `merge_docs_by_recipient_and_pol` setting is not in use.
* Sometimes print jobs get backlogged, for example, over weekends or holidays.
* After sorting the deliverables as desired, you should pull down the PDF files
themselves by calling getAttachment, and passing it the file_id of a file.
From there, it can be printed as desired.
* After they've been sent to the printer, you MUST call markAsPrinted with the
file_ids of the files you've printed. Failing to do so can result in processing
errors later, and will not cause the file to appear in the list of files when
reprinting later.