BoxLang 🚀 A New JVM Dynamic Language Learn More...
Royal Mail Click & Drop CFML provides a wrapper for the Royal Mail UK Click & Drop Web Services.
box install RMClickDropCFML
Check out the /examples
folder for an example implementation.
The UK Royal Mail Click & Drop CFML wrapper consists of two models; one representing the Orders REST API and one able to process the results files provided by the Click & Drop software. For the moment, the Orders API wrapper is only able to retrieve order data - it does not currently have order creation capabilities.
RMOrders = new models.orders(
api_key = 'your-api-key'
);
RMResultsFiles = new models.fileManager(
resultsfilePath = 'path/to/folder'
);
RMOrders = getInstance("orders@RMClickDropCFML");
RMResultsFiles = getInstance("fileManager@RMClickDropCFML");
alternatively inject it directly into your handler
property name="RMOrders" inject="tracking@RMClickDropCFML";
property name="RMResultsFiles" inject="fileManager@RMClickDropCFML";
When using with ColdBox, you'll want to insert your API key and/or filesystem details into your module settings:
RMClickDropCFML = {
api_key = getSystemSetting("RM_API_KEY", "")
, resultsfilePath = getSystemSetting("RM_RESULTSFILEPATH", "")
}
Retrieve details about a click & drop order with a simple call to the retrieve function of the orders model. This will return event dates and a tracking number.
orderDetails = RMOrders.retrieve('123456');
When dropping order files into Click & Drop, result files are generated. You may use functions of the fileManager model to retrieve data from these files.
fileList = RMResultsFiles.getFileList();
During processing, files are copied over to an internal folder for storage. (defaults to /store
). You may remove files from their original location with the deleteFiles
argument.
fileContents = RMResultsFiles.processFiles(
dateRange = '2021-01-01,2021-01-31'
, deleteFiles = false
);
Written by Gary Stanton.
https://garystanton.co.uk
$
box install RMClickDropCFML