variables.usps = New usps(isProduction=true, isSecure=false, uspsUserID=variables.uspsUserID);
variables.RateV4 = variables.usps.RateV4(
Service = 'FIRST CLASS',
FirstClassMailType = 'PARCEL',
ZipOrigination = '99212',
ZipDestination = '22193',
SIZE = 'REGULAR',
Pounds = '0',
Ounces = '3.5'
<cffunction name="init" access="public" returntype="USPS" output="false" hint="Initializes the USPS CFC">
<cfargument name="isProduction" type="boolean" required="false" default="#getIsProduction()#">
<cfargument name="isSecure" type="boolean" required="false" default="#getIsSecure()#">
<cfargument name="uspsUserID" type="string" required="false" default="#getUspsUserID()#">
<cfscript>
// set constants (CF9 fix)
setURLTEST("http://testing.shippingapis.com/ShippingAPITest.dll");
setURLTESTSECURE("https://secure.shippingapis.com/ShippingAPITest.dll");
setURLPROD("http://production.shippingapis.com/ShippingAPI.dll");
setURLPRODSECURE("https://secure.shippingapis.com/ShippingAPI.dll");
// set production and secure flags
setIsProduction(arguments.isProduction);
setIsSecure(arguments.isSecure);
setUspsUserID(arguments.uspsUserID);
// configure url based on flags
if(getIsProduction()){
if(getIsSecure()){
setUrl(getURLPRODSECURE());
}
else{
setUrl(getURLPROD());
}
}
else{
if(getIsSecure()){
setUrl(getURLTESTSECURE());
}
else{
setUrl(getURLTEST());
}
}
return this;
</cfscript>
</cffunction>
<cfproperty name="isProduction" type="boolean">
<cfproperty name="isSecure" type="boolean">
<cfproperty name="uspsUserID" type="string">
<cfproperty name="url" type="string">
<cfproperty name="URLTEST" type="string">
<cfproperty name="URLTESTSECURE" type="string">
<cfproperty name="URLPROD" type="string">
<cfproperty name="URLPRODSECURE" type="string">
<cffunction name="setURLTEST" access="public" returntype="void">
<cfargument name="value" type="String" required="true">
<cfset variables.URLTEST = arguments.value />
</cffunction>
...