|
public class ValidateAccountAddressCtrl { |
|
public List<zkups.ValidateAddressResult.AddressValidationResult> validationAddressesList {get; set;} |
|
|
|
public ValidateAccountAddressCtrl() {} |
|
|
|
public void init() { |
|
Account accountToCheck = [ |
|
SELECT ShippingStreet, ShippingCity, ShippingPostalCode, ShippingCountry, |
|
ShippingState |
|
FROM Account |
|
WHERE Name = 'Your Account Name' |
|
LIMIT 1]; |
|
|
|
zkups__UPSShipmatePreference__c shipmatePref = [ |
|
SELECT Id, Name, |
|
zkups__UserId__c, zkups__UserIdVisible__c, zkups__UPSAccountNumber__c, |
|
zkups__ThermalPrinterName__c, zkups__Street__c, zkups__State__c, zkups__SenderPhoneDefault__c, |
|
zkups__SenderNameDefault__c, zkups__SenderEMailDefault__c, zkups__SendEMailNotificationToShipper__c, |
|
zkups__SendEMailNotificationToRecipient__c, zkups__PrimaryContactTitle__c, zkups__PrimaryContactPhone__c, |
|
zkups__PrimaryContactName__c, zkups__PrimaryContactEmail__c, zkups__PostalCode__c, zkups__Password__c, |
|
zkups__LabelImageTypeDefault__c, zkups__EMailNotifyOnExceptionDefault__c, zkups__EMailNotifyOnDeliveryDefault__c, |
|
zkups__EMailMessageDefault__c, zkups__DetailedViewShipmatePreferenceList__c, zkups__DetailedViewReUsePackageList__c, |
|
zkups__Country__c, zkups__CompanyURL__c, zkups__CompanyName__c, zkups__City__c, zkups__AccessLicenseNumber__c, |
|
zkups__ShippingStreet__c, zkups__ShippingCity__c, zkups__ShippingState__c, zkups__ShippingPostalCode__c, |
|
zkups__ShippingCountry__c, zkups__ShippingIsResidential__c |
|
FROM zkups__UPSShipmatePreference__c |
|
LIMIT 1]; |
|
|
|
zkups__UPSShipment__c shipmentValidationAddress = new zkups__UPSShipment__c(); |
|
shipmentValidationAddress.zkups__RecipientStreet__c = accountToCheck.ShippingStreet; |
|
shipmentValidationAddress.zkups__RecipientCity__c = accountToCheck.ShippingCity; |
|
shipmentValidationAddress.zkups__RecipientPostalCode__c = accountToCheck.ShippingPostalCode; |
|
shipmentValidationAddress.zkups__RecipientCountry__c = accountToCheck.ShippingCountry; |
|
shipmentValidationAddress.zkups__RecipientState__c = accountToCheck.ShippingState; |
|
|
|
zkups.ValidateAddressResult validateAddressResult = zkups.ShipmentInterface.validateAddress(shipmentValidationAddress, shipmatePref); |
|
if (validateAddressResult.results != null) { |
|
validationAddressesList = validateAddressResult.results; |
|
} |
|
} |
|
} |