Address Validation Via APEX
Address validation uses the carriers address validation service if they have one.
The example below show you how to do address validation against a UPS preference.
Id preferenceId = 'a025800000bs9Qx'; // Salesforce ID of your UPS Preference
zkmulti__MCShipment__c ship = new zkmulti__MCShipment__c(
// recipient info
zkmulti__Recipient_Company__c = 'Burlington Textiles Corp of America',
zkmulti__Recipient_Email__c = 'test@test.ttt',
zkmulti__Recipient_Name__c = 'Jack Rogers',
zkmulti__Recipient_Phone__c = '3362227000',
zkmulti__Recipient_Street__c = '525 S. Lexington Ave',
zkmulti__Recipient_City__c = 'Burlington',
zkmulti__Recipient_Zip_Postal_Code__c = '27215',
zkmulti__Recipient_State_Province__c = 'NC',
zkmulti__Recipient_Country__c = 'US'
);
zkmulti.AddressValidationResult result = zkmulti.ShipmentInterface.validateAddress(ship, preferenceId);
System.debug('result:' + result);
The example valid response has isValid=true:
result:AddressValidationResult:[addresses=(AddressResult:[addressClassificationCode=0, city=BURLINGTON, country=US, description=Unknown, postalCode=27215, residential=false, state=NC, streetLines=(525 S LEXINGTON AVE), urbanizationCode=null]), attributes={ambiguousAddressIndicator=false, validAddressIndicator=true}, isResidential=false, isValid=true, messages=()]