-
-
Notifications
You must be signed in to change notification settings - Fork 16
Custom Protocols
Luis Majano edited this page Dec 7, 2015
·
1 revision
In order to create your own custom protocol you will create a CFC that inherits from cbmailservices.models.AbstractProtocol
and make sure you implement the init()
and send()
method.
Each protocol will be initialized with a struct of properties defined in the configuration CFC ColdBox.cfc
. You will receive them in the constructor:
function init( required struct properties={} ){
return thisl
}
You can then use them for initialization purposes. Here is an example of the FileProtocol
function init( required struct properties={} ){
super.init(argumentCollection=arguments);
// Property Checks
if(NOT propertyExists("filePath")){
// No API key was found, so throw an exception.
throw(message="filePath property is Required",type="FileProtocol.PropertyNotFound");
}
// auto expand
if( NOT propertyExists("autoExpand") ){
setProperty("autoExpand",true);
}
// expandPath?
if( getProperty("autoExpand") ){
setProperty("filePath", expandPath( getProperty('filePath') ) );
}
return this;
}
Then you can implement the send()
method which receives a payload
object which maps to the cbmailservices.models.Mail
object.