Package com.clover.sdk.v1.printer.job
Class PrintJobsConnector
- java.lang.Object
-
- com.clover.sdk.v1.CallConnector
-
- com.clover.sdk.v1.printer.job.PrintJobsConnector
-
public class PrintJobsConnector extends CallConnector
A class that encapsulates interaction with Clover's print job queue.- See Also:
PrintJobsContract
-
-
Field Summary
-
Fields inherited from class com.clover.sdk.v1.CallConnector
context
-
-
Constructor Summary
Constructors Constructor Description PrintJobsConnector(Context context)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>
getPrintJobIds(int state)
Get all of the print job IDs with the given state.Integer
getState(String printJobId)
Get the state of a previously printed print job.String
print(PrintJob printJob)
Print aPrintJob
to any configured suitable printer.String
print(Printer printer, PrintJob printJob)
Print aPrintJob
.-
Methods inherited from class com.clover.sdk.v1.CallConnector
call
-
-
-
-
Constructor Detail
-
PrintJobsConnector
public PrintJobsConnector(Context context)
-
-
Method Detail
-
print
@Nullable public String print(@Nullable Printer printer, @NonNull PrintJob printJob)
Print aPrintJob
. If the providedPrinter
is not configurednull
is returned. If the providedPrinter
is null then this method is equivalent toprint(PrintJob)
. To retrieve the list of suitable printers usePrinterConnector.getPrinters(Category)
passing the print job'sPrintJob.getPrinterCategory()
as the argument.
-
print
@Nullable public String print(@NonNull PrintJob printJob)
Print aPrintJob
to any configured suitable printer. A suitable printer is one where the printer's category (Printer.getCategory()
matches the print job's category (PrintJob.getPrinterCategory()
. If no suitable printer is configured the job is not printed andnull
is returned. If there are multiple suitable configured printers the order of selection is not defined. The selection is not stable; it may be different for each invocations of this method. If it is preferable to ensure a suitable printer is configured before printing callPrinterConnector.getPrinters(Category)
passingPrintJob.getPrinterCategory()
as the argument, and pass the explicit printer argument toprint(Printer, PrintJob)
instead of this method. This method is a convenience. The caller is not required to retrieve and evaluate the list of configured printers first and select one, possibly involving the user. Most merchants have at most one printer of each type (receipt, order, label, fiscal) configured. This however is not guaranteed. This method is equivalent to callingPrintJob.print(Context, Account)
withPrintJob.printToAny
set to true. The actual value ofPrintJob.printToAny
is not considered here.
-
getState
@Nullable public Integer getState(@NonNull String printJobId)
Get the state of a previously printed print job. Print jobs older than one hour are deleted regardless of their state. If the print job for the given ID has been deleted from the database, null is returned.- Parameters:
printJobId
- aString
, the print job ID.- Returns:
- an
Integer
, the print job state ornull
if the print job does not exist. - See Also:
PrintJobsContract.STATE_IN_QUEUE
,PrintJobsContract.STATE_PRINTING
,PrintJobsContract.STATE_DONE
,PrintJobsContract.STATE_ERROR
-
getPrintJobIds
public List<String> getPrintJobIds(int state)
Get all of the print job IDs with the given state. This is a hidden API. It is subject to change without warning. Use at your own risk. There is very little use of this outside of test / example code. In most cases callers will print, capture the return print job ID, and usegetState(String)
to get the state for that ID.
-
-