1. Home
  2. Docs
  3. Multi
  4. Apex Code
Log a Case

Multi-carrier APEX Global Methods

Our standard Multi-Carrier Package is great for creating shipments using the shipping wizard and process builder, however sometimes users need more flexibility with shipping, rating and interfacing with scales. For example:

  1. You want to create 500 labels at a time as part of a mass-shipping campaign
  2. You want to create a heavily customized version of our shipping wizard

To enable the Global Apex Methods in your org, you will need to install our ShipAutomate Package (sandbox install and production install).

The ShipAutomate package exposes the following methods:

Method Signature Description
asynchronousProcessBulkShipment(String bulkShipmentId)

Books a shipment with the carrier using the asynchronous method. This can be used for all shipments with one or more packages. Returns the Bulk Shipment Id.

synchronousProcessBulkShipment(String bulkShipmentId)

Books a shipment with the carrier using the synchronous method. This method is slightly faster than the asynchronous method BUT can only be used for shipments having only 1 package. Returns the Bulk Shipment Id.

validateBulkShipment(String bulkShipmentId, Boolean performAddressValidation)

Validates that all the required fields are present in the shipment object.

For example if the street address is missing, this method will return an error.

If you want to perform address validation on this shipment then set the performAddressValidation value to true.

calculateRates(Id preferenceId, MCShipment__c shipment, List<MCPackage__c> packages, MCShipment_Special_Services__c shipmentSS, List<MCCustoms_Item__c> customsItems, Map<String, Object> additionalParameters)

This method allows you to make a call out to the carrier to get the rates for a particular shipment.

This is useful if you want to preselect the cheapest or fastest rate.

getScaleInfo(MCShipmate_Preference__c preference)

This method allows you to get the weight from the scale that is attached to your computer.

Be sure to have the desktop app installed and the Scale recognised.

Bulk Shipping Process

As you will see the code samples below, there is a defined process for creating shipments in bulk. This is as follows:

  1. Define the PreferenceId and the Id of the object you will be shipping to e.g. (Case or Order)
  2. Instantiate the the Bulk Shipment object (zkmulti__MCBulk_Shipment__c) passing the Preference object as the parameter. Insert the Bulk Shipment object.
  3. Define the shipment (zkmulti__MCShipment__c) and then insert it.
  4. Define the packages (zkmulti__MCPackage__c) and then insert them.
  5. Call the asynchronousProcessBulkShipment method passing the batchId and assign its response to a String.
  6. The returned String will be the Salesforce ID of the batch shipment, which is a container for your generated shipments. 


Bulk Shipments Using CAS (Custom Address Source)

Id prefId = 'a025800000OAzvj';

Id casId = 'a035800000ZqL52AAF';

Id recordId = '5005800000OKcBo';

zkmulti__MCBulk_Shipment__c bulkShipment = new zkmulti__MCBulk_Shipment__c (

zkmulti__Shipmate_Preference__c = prefId,

zkmulti__Custom_Address_Source__c = casId

);

insert bulkShipment;

zkmulti__MCShipment__c ship = new zkmulti__MCShipment__c();

ship.zkmulti__Bulk_Shipment__c = bulkShipment.Id;

ship.zkmulti__Test_Case__c = recordId;

insert ship;

String batchId = zkmulti.BulkShipmentInterface.asynchronousProcessBulkShipment(bulkShipment.Id);

System.debug('BATCH ID :' + batchId);

Bulk Shipments UPS US to US

Id prefId = 'a025800000PIlRQ'; 
Id contactId = '00358000006wy1I'; // Jack Rodgers
zkmulti__MCShipmate_Preference__c shipmatePref = [
SELECT Id, Name, zkmulti__AccountNumber__c,
zkmulti__Carrier__c, zkmulti__Label_Image_Type_Default__c,
zkmulti__Billing_City__c, zkmulti__Billing_Country__c, zkmulti__Billing_State__c,
zkmulti__Billing_Street__c, zkmulti__Billing_Zip_Postal_Code__c, zkmulti__Company_Name__c, zkmulti__Sender_Email_Default__c, zkmulti__Sender_Name_Default__c,
zkmulti__Sender_Phone_Default__c, zkmulti__Shipping_City__c, zkmulti__Shipping_Country__c, zkmulti__Shipping_Is_Residential__c,
zkmulti__Shipping_State__c, zkmulti__Shipping_Street__c, zkmulti__Shipping_Zip_Postal_Code__c, zkmulti__Currency_Default__c
FROM zkmulti__MCShipmate_Preference__c
WHERE Id = :prefId];
// get contact information (for recipient information)
Contact con = [
SELECT MailingCity, Account.Name, MailingCountry,
Email, FirstName, LastName,
Phone, MailingState, MailingStreet,
MailingPostalCode
FROM Contact
WHERE Id = :contactId];
// 1. Bulk Shipment
zkmulti__MCBulk_Shipment__c bulkShipment = new zkmulti__MCBulk_Shipment__c (
zkmulti__Shipmate_Preference__c = prefId
);
insert bulkShipment;
// 2. Shipment and Shipment Info (required object)
zkmulti__MCShipment__c ship = new zkmulti__MCShipment__c(
zkmulti__Bulk_Shipment__c = bulkShipment.Id,
zkmulti__Carrier__c = 'UPS',
zkmulti__Label_Image_Type__c = 'GIF',
// sender info
zkmulti__Sender_Name__c = shipmatePref.zkmulti__Sender_Name_Default__c,
zkmulti__Sender_City__c = shipmatePref.zkmulti__Shipping_City__c,
zkmulti__Sender_Company__c = shipmatePref.zkmulti__Company_Name__c,
zkmulti__Sender_Country__c = shipmatePref.zkmulti__Shipping_Country__c,
zkmulti__Sender_Email__c = shipmatePref.zkmulti__Sender_Email_Default__c,
zkmulti__Sender_Phone__c = shipmatePref.zkmulti__Sender_Phone_Default__c,
zkmulti__Sender_State_Province__c = shipmatePref.zkmulti__Shipping_State__c,
zkmulti__Sender_Street__c = shipmatePref.zkmulti__Shipping_Street__c,
zkmulti__Sender_Zip_Postal_Code__c = shipmatePref.zkmulti__Shipping_Zip_Postal_Code__c,
zkmulti__Sender_Address_is_Residential__c = false,
// recipient info
zkmulti__Recipient_City__c = con.MailingCity,
zkmulti__Recipient_Company__c = con.Account.Name,
zkmulti__Recipient_Country__c = con.MailingCountry,
zkmulti__Recipient_Email__c = con.Email,
zkmulti__Recipient_Name__c = con.FirstName + ' ' + con.LastName,
zkmulti__Recipient_Phone__c = con.Phone,
zkmulti__Recipient_State_Province__c = con.MailingState,
zkmulti__Recipient_Street__c = con.MailingStreet,
zkmulti__Recipient_Zip_Postal_Code__c = con.MailingPostalCode,
zkmulti__Ship_Date__c = Date.today(),
zkmulti__Currency__c = 'USD',
zkmulti__Dimension_Units__c = 'IN',
zkmulti__Weight_Units__c = 'LBS',
zkmulti__Service_Type__c = 'UPS_GROUND',
zkmulti__Package_Type__c = 'UPS_YOUR_PACKAGING',
zkmulti__Payment_Type__c = 'SENDER',
zkmulti__Billing_Account_Number__c = shipmatePref.zkmulti__AccountNumber__c,
zkmulti__Billing_Country__c = shipmatePref.zkmulti__Billing_Country__c
);
insert ship;
// 3. Packages
zkmulti__MCPackage__c pkg = new zkmulti__MCPackage__c (
zkmulti__Shipment__c = ship.Id,
zkmulti__Weight__c = 1,
zkmulti__Length__c = 1,
zkmulti__Width__c = 1,
zkmulti__Height__c = 1,
zkmulti__DeclaredValue__c = 0
);
insert pkg;
String batchId = zkmulti.BulkShipmentInterface.asynchronousProcessBulkShipment(bulkShipment.Id);
System.debug('BATCH ID :' + batchId);

Bulk Shipments UPS US to CA

Id prefId = 'a025800000PIlRQ'; 
Id contactId = '0035800000lYYoP'; // CANADA Contact
Id commercialInvoiceId = 'a0S58000006by4E';
Id naftaCoId = 'a0T5800000CjM06';
zkmulti__MCShipmate_Preference__c shipmatePref = [
SELECT Id, Name, zkmulti__AccountNumber__c,
zkmulti__Carrier__c, zkmulti__Label_Image_Type_Default__c,
zkmulti__Billing_City__c, zkmulti__Billing_Country__c, zkmulti__Billing_State__c,
zkmulti__Billing_Street__c, zkmulti__Billing_Zip_Postal_Code__c, zkmulti__Company_Name__c, zkmulti__Sender_Email_Default__c, zkmulti__Sender_Name_Default__c,
zkmulti__Sender_Phone_Default__c, zkmulti__Shipping_City__c, zkmulti__Shipping_Country__c, zkmulti__Shipping_Is_Residential__c,
zkmulti__Shipping_State__c, zkmulti__Shipping_Street__c, zkmulti__Shipping_Zip_Postal_Code__c, zkmulti__Currency_Default__c
FROM zkmulti__MCShipmate_Preference__c
WHERE Id = :prefId];
// get contact information (for recipient information)
Contact con = [
SELECT MailingCity, Account.Name, MailingCountry,
Email, FirstName, LastName,
Phone, MailingState, MailingStreet,
MailingPostalCode
FROM Contact
WHERE Id = :contactId];
// 1. Bulk Shipment
zkmulti__MCBulk_Shipment__c bulkShipment = new zkmulti__MCBulk_Shipment__c (
zkmulti__Shipmate_Preference__c = prefId
);
insert bulkShipment;
// 2. Shipment and Shipment Info (required object)
// Shipment Info
zkmulti__MCShipmentInfo__c shipInfo = new zkmulti__MCShipmentInfo__c(
zkmulti__Contents_Type__c = 'NON_DOCUMENTS',// NON_DOCUMENTS OR DOCUMENTS_ONLY
zkmulti__DutiesPaymentType__c = 'SENDER',
// set duties
zkmulti__DutiesPayorAccount__c = shipmatePref.zkmulti__AccountNumber__c, // intl info
zkmulti__DutiesPayorAccountCountry__c = shipmatePref.zkmulti__Billing_Country__c // intl info
);
insert shipInfo;
// Shipment
zkmulti__MCShipment__c ship = new zkmulti__MCShipment__c(
zkmulti__Bulk_Shipment__c = bulkShipment.Id,
zkmulti__Shipment_Info__c = shipInfo.Id,
zkmulti__Carrier__c = 'UPS',
zkmulti__Label_Image_Type__c = 'GIF',
// sender info
zkmulti__Sender_Name__c = shipmatePref.zkmulti__Sender_Name_Default__c,
zkmulti__Sender_City__c = shipmatePref.zkmulti__Shipping_City__c,
zkmulti__Sender_Company__c = shipmatePref.zkmulti__Company_Name__c,
zkmulti__Sender_Country__c = shipmatePref.zkmulti__Shipping_Country__c,
zkmulti__Sender_Email__c = shipmatePref.zkmulti__Sender_Email_Default__c,
zkmulti__Sender_Phone__c = shipmatePref.zkmulti__Sender_Phone_Default__c,
zkmulti__Sender_State_Province__c = shipmatePref.zkmulti__Shipping_State__c,
zkmulti__Sender_Street__c = shipmatePref.zkmulti__Shipping_Street__c,
zkmulti__Sender_Zip_Postal_Code__c = shipmatePref.zkmulti__Shipping_Zip_Postal_Code__c,
zkmulti__Sender_Address_is_Residential__c = false,
// recipient info
zkmulti__Recipient_City__c = con.MailingCity,
zkmulti__Recipient_Company__c = con.Account.Name,
zkmulti__Recipient_Country__c = con.MailingCountry,
zkmulti__Recipient_Email__c = con.Email,
zkmulti__Recipient_Name__c = con.FirstName + ' ' + con.LastName,
zkmulti__Recipient_Phone__c = con.Phone,
zkmulti__Recipient_State_Province__c = con.MailingState,
zkmulti__Recipient_Street__c = con.MailingStreet,
zkmulti__Recipient_Zip_Postal_Code__c = con.MailingPostalCode,
zkmulti__Ship_Date__c = Date.today(),
zkmulti__Currency__c = 'USD',
zkmulti__Dimension_Units__c = 'IN',
zkmulti__Weight_Units__c = 'LBS',
zkmulti__Service_Type__c = 'INTERNATIONAL_ECONOMY',
zkmulti__Package_Type__c = 'UPS_YOUR_PACKAGING',
zkmulti__ShipmentDescription__c = 'Description_of_goods',
zkmulti__Payment_Type__c = 'SENDER',
zkmulti__Billing_Account_Number__c = shipmatePref.zkmulti__AccountNumber__c,
zkmulti__Billing_Country__c = shipmatePref.zkmulti__Billing_Country__c
);
insert ship;
// 3. Packages
zkmulti__MCPackage__c pkg = new zkmulti__MCPackage__c (
zkmulti__Shipment__c = ship.Id,
zkmulti__Weight__c = 2,
zkmulti__Length__c = 1,
zkmulti__Width__c = 1,
zkmulti__Height__c = 1,
zkmulti__DeclaredValue__c = 10
);
insert pkg;
// 4. Custom Items
zkmulti__MCCustoms_Item__c customItem = new zkmulti__MCCustoms_Item__c(
zkmulti__Shipment__c = ship.Id,
zkmulti__Carrier__c = 'UPS',
zkmulti__CiMarksAndNumbers__c = null,
zkmulti__Country_of_Manufacture__c = 'US',
zkmulti__Description__c = 'collapsible umbrella',
zkmulti__ExportLicenseExpirationDate__c = null,
zkmulti__ExportLicenseNumber__c = null,
zkmulti__Harmonized_Code__c = '6601.91.00',
zkmulti__NetCostDateRangeEnd__c = Date.today().addDays(1),
zkmulti__NetCostDateRangeStart__c = Date.today().addDays(-1),
zkmulti__NetCostMethod__c = 'NC',
zkmulti__NumberOfPieces__c = 1,
zkmulti__PartNumber__c = 'UM-12344',
zkmulti__NaftaPreferenceCriterion__c = 'A',
zkmulti__NaftaProducerDetermination__c = 'NO_1',
zkmulti__Quantity__c = 1,
zkmulti__QuantityUnits__c = 'EA',
zkmulti__UnitPrice__c = 10,
zkmulti__Weight__c = 2,
zkmulti__Weight_Units__c = 'LB',
zkmulti__UnitOfMeasurement__c = 'Each'
);
insert customItem;
zkmulti__RequestedShipmentDocuments__c reqShipDocs = new zkmulti__RequestedShipmentDocuments__c(
zkmulti__Shipment__c = ship.Id,
zkmulti__CO__c = true,
zkmulti__CommercialInvoice__c = commercialInvoiceId,
zkmulti__NaftaCo__c = naftaCoId,
zkmulti__OverridePaperlessForIntlDocuments__c = true,
zkmulti__ImporterAccount__c = null,
zkmulti__ImporterSameAsConsignee__c = true
);
insert reqShipDocs;
String batchId = zkmulti.BulkShipmentInterface.asynchronousProcessBulkShipment(bulkShipment.Id);
System.debug('BATCH ID :' + batchId);

Bulk Shipments GB to US - Interlink

Id prefId = 'a025800000OBkHb'; 
Id contactId = '00358000006wy1I'; // Jack Rodgers
zkmulti__MCShipmate_Preference__c shipmatePref = [
SELECT Id, Name, zkmulti__AccountNumber__c,
zkmulti__Carrier__c, zkmulti__Label_Image_Type_Default__c,
zkmulti__Billing_City__c, zkmulti__Billing_Country__c, zkmulti__Billing_State__c,
zkmulti__Billing_Street__c, zkmulti__Billing_Zip_Postal_Code__c, zkmulti__Company_Name__c, zkmulti__Sender_Email_Default__c, zkmulti__Sender_Name_Default__c,
zkmulti__Sender_Phone_Default__c, zkmulti__Shipping_City__c, zkmulti__Shipping_Country__c, zkmulti__Shipping_Is_Residential__c,
zkmulti__Shipping_State__c, zkmulti__Shipping_Street__c, zkmulti__Shipping_Zip_Postal_Code__c, zkmulti__Currency_Default__c
FROM zkmulti__MCShipmate_Preference__c
WHERE Id = :prefId];
// get contact information (for recipient information)
Contact con = [
SELECT MailingCity, Account.Name, MailingCountry,
Email, FirstName, LastName,
Phone, MailingState, MailingStreet,
MailingPostalCode
FROM Contact
WHERE Id = :contactId];
// 1. Bulk Shipment
zkmulti__MCBulk_Shipment__c bulkShipment = new zkmulti__MCBulk_Shipment__c (
zkmulti__Shipmate_Preference__c = prefId
);
insert bulkShipment;
// 2. Shipment and Shipment Info (required object)
// Shipment Info
zkmulti__MCShipmentInfo__c shipInfo = new zkmulti__MCShipmentInfo__c(
zkmulti__Contents_Type__c = 'Merchandise'
);
insert shipInfo;
// Shipment
zkmulti__MCShipment__c ship = new zkmulti__MCShipment__c(
zkmulti__Bulk_Shipment__c = bulkShipment.Id,
zkmulti__Shipment_Info__c = shipInfo.Id,
zkmulti__Carrier__c = 'InterlinkExpress',
zkmulti__Label_Image_Type__c = 'PNG',
// sender info
zkmulti__Sender_Name__c = shipmatePref.zkmulti__Sender_Name_Default__c,
zkmulti__Sender_City__c = shipmatePref.zkmulti__Shipping_City__c,
zkmulti__Sender_Company__c = shipmatePref.zkmulti__Company_Name__c,
zkmulti__Sender_Country__c = shipmatePref.zkmulti__Shipping_Country__c,
zkmulti__Sender_Email__c = shipmatePref.zkmulti__Sender_Email_Default__c,
zkmulti__Sender_Phone__c = shipmatePref.zkmulti__Sender_Phone_Default__c,
zkmulti__Sender_State_Province__c = shipmatePref.zkmulti__Shipping_State__c,
zkmulti__Sender_Street__c = shipmatePref.zkmulti__Shipping_Street__c,
zkmulti__Sender_Zip_Postal_Code__c = shipmatePref.zkmulti__Shipping_Zip_Postal_Code__c,
zkmulti__Sender_Address_is_Residential__c = false,
// recipient info
zkmulti__Recipient_City__c = con.MailingCity,
zkmulti__Recipient_Company__c = con.Account.Name,
zkmulti__Recipient_Country__c = con.MailingCountry,
zkmulti__Recipient_Email__c = con.Email,
zkmulti__Recipient_Name__c = con.FirstName + ' ' + con.LastName,
zkmulti__Recipient_Phone__c = con.Phone,
zkmulti__Recipient_State_Province__c = con.MailingState,
zkmulti__Recipient_Street__c = con.MailingStreet,
zkmulti__Recipient_Zip_Postal_Code__c = con.MailingPostalCode,
zkmulti__Ship_Date__c = Date.today(),
zkmulti__Currency__c = 'GBP',
zkmulti__Dimension_Units__c = 'IN',
zkmulti__Weight_Units__c = 'LB',
zkmulti__Service_Type__c = 'InterlinkAirExpressInternationalAir',
zkmulti__Package_Type__c = 'Parcel',
zkmulti__Payment_Type__c = 'SENDER'
);
insert ship;
// 3. Packages
zkmulti__MCPackage__c pkg = new zkmulti__MCPackage__c (
zkmulti__Shipment__c = ship.Id,
zkmulti__Weight__c = 1,
zkmulti__Length__c = 1,
zkmulti__Width__c = 1,
zkmulti__Height__c = 1,
zkmulti__DeclaredValue__c = 10
);
insert pkg;
// 4. Custom Items
zkmulti__MCCustoms_Item__c customItem = new zkmulti__MCCustoms_Item__c(
zkmulti__Shipment__c = ship.Id,
zkmulti__Carrier__c = 'InterlinkExpress',
zkmulti__Country_of_Manufacture__c = 'US',
zkmulti__Description__c = 'test description',
zkmulti__Quantity__c = 1,
zkmulti__QuantityUnits__c = 'F',
zkmulti__UnitPrice__c = 10,
zkmulti__Weight__c = 1
);
insert customItem;
String batchId = zkmulti.BulkShipmentInterface.asynchronousProcessBulkShipment(bulkShipment.Id);
System.debug('BATCH ID :' + batchId);

Bulk Shipments GB to GB - Interlink

Id prefId = 'a025800000OBkHb'; 
Id contactId = '0035800000MnthL'; // Gb Contact
zkmulti__MCShipmate_Preference__c shipmatePref = [
SELECT Id, Name, zkmulti__AccountNumber__c,
zkmulti__Carrier__c, zkmulti__Label_Image_Type_Default__c,
zkmulti__Billing_City__c, zkmulti__Billing_Country__c, zkmulti__Billing_State__c,
zkmulti__Billing_Street__c, zkmulti__Billing_Zip_Postal_Code__c, zkmulti__Company_Name__c, zkmulti__Sender_Email_Default__c, zkmulti__Sender_Name_Default__c,
zkmulti__Sender_Phone_Default__c, zkmulti__Shipping_City__c, zkmulti__Shipping_Country__c, zkmulti__Shipping_Is_Residential__c,
zkmulti__Shipping_State__c, zkmulti__Shipping_Street__c, zkmulti__Shipping_Zip_Postal_Code__c, zkmulti__Currency_Default__c
FROM zkmulti__MCShipmate_Preference__c
WHERE Id = :prefId];
// get contact information (for recipient information)
Contact con = [
SELECT MailingCity, Account.Name, MailingCountry,
Email, FirstName, LastName,
Phone, MailingState, MailingStreet,
MailingPostalCode
FROM Contact
WHERE Id = :contactId];
// 1. Bulk Shipment
zkmulti__MCBulk_Shipment__c bulkShipment = new zkmulti__MCBulk_Shipment__c (
zkmulti__Shipmate_Preference__c = prefId
);
insert bulkShipment;
// 2. Shipment and Shipment Info (required object)
zkmulti__MCShipment__c ship = new zkmulti__MCShipment__c(
zkmulti__Bulk_Shipment__c = bulkShipment.Id,
zkmulti__Carrier__c = 'InterlinkExpress',
zkmulti__Label_Image_Type__c = 'PNG',
// sender info
zkmulti__Sender_Name__c = shipmatePref.zkmulti__Sender_Name_Default__c,
zkmulti__Sender_City__c = shipmatePref.zkmulti__Shipping_City__c,
zkmulti__Sender_Company__c = shipmatePref.zkmulti__Company_Name__c,
zkmulti__Sender_Country__c = shipmatePref.zkmulti__Shipping_Country__c,
zkmulti__Sender_Email__c = shipmatePref.zkmulti__Sender_Email_Default__c,
zkmulti__Sender_Phone__c = shipmatePref.zkmulti__Sender_Phone_Default__c,
zkmulti__Sender_State_Province__c = shipmatePref.zkmulti__Shipping_State__c,
zkmulti__Sender_Street__c = shipmatePref.zkmulti__Shipping_Street__c,
zkmulti__Sender_Zip_Postal_Code__c = shipmatePref.zkmulti__Shipping_Zip_Postal_Code__c,
zkmulti__Sender_Address_is_Residential__c = false,
// recipient info
zkmulti__Recipient_City__c = con.MailingCity,
zkmulti__Recipient_Company__c = con.Account.Name,
zkmulti__Recipient_Country__c = con.MailingCountry,
zkmulti__Recipient_Email__c = con.Email,
zkmulti__Recipient_Name__c = con.FirstName + ' ' + con.LastName,
zkmulti__Recipient_Phone__c = con.Phone,
zkmulti__Recipient_State_Province__c = con.MailingState,
zkmulti__Recipient_Street__c = con.MailingStreet,
zkmulti__Recipient_Zip_Postal_Code__c = con.MailingPostalCode,
zkmulti__Ship_Date__c = Date.today(),
zkmulti__Currency__c = 'GBP',
zkmulti__Dimension_Units__c = 'IN',
zkmulti__Weight_Units__c = 'LB',
zkmulti__Service_Type__c = 'InterlinkExpresspak1By10:30',
zkmulti__Package_Type__c = 'Parcel',
zkmulti__Payment_Type__c = 'SENDER'
// zkmulti__Billing_Account_Number__c = shipmatePref.zkmulti__AccountNumber__c,
// zkmulti__Billing_Country__c = shipmatePref.zkmulti__Billing_Country__c
);
insert ship;
// 3. Packages
zkmulti__MCPackage__c pkg = new zkmulti__MCPackage__c (
zkmulti__Shipment__c = ship.Id,
zkmulti__Weight__c = 1,
zkmulti__Length__c = 1,
zkmulti__Width__c = 1,
zkmulti__Height__c = 1,
zkmulti__DeclaredValue__c = 0
);
insert pkg;
String batchId = zkmulti.BulkShipmentInterface.asynchronousProcessBulkShipment(bulkShipment.Id);
System.debug('BATCH ID :' + batchId);

Calculate Rates UPS

Id prefId = 'a025800000PIlRQ'; 
Id contactId = '00358000006wy1I'; // Jack Rodgers
zkmulti__MCShipmate_Preference__c shipmatePref = [
SELECT Id, Name, zkmulti__AccountNumber__c,
zkmulti__Carrier__c, zkmulti__Label_Image_Type_Default__c,
zkmulti__Billing_City__c, zkmulti__Billing_Country__c, zkmulti__Billing_State__c,
zkmulti__Billing_Street__c, zkmulti__Billing_Zip_Postal_Code__c, zkmulti__Company_Name__c, zkmulti__Sender_Email_Default__c, zkmulti__Sender_Name_Default__c,
zkmulti__Sender_Phone_Default__c, zkmulti__Shipping_City__c, zkmulti__Shipping_Country__c, zkmulti__Shipping_Is_Residential__c,
zkmulti__Shipping_State__c, zkmulti__Shipping_Street__c, zkmulti__Shipping_Zip_Postal_Code__c, zkmulti__Currency_Default__c
FROM zkmulti__MCShipmate_Preference__c
WHERE Id = :prefId];
// get contact information (for recipient information)
Contact con = [
SELECT MailingCity, Account.Name, MailingCountry,
Email, FirstName, LastName,
Phone, MailingState, MailingStreet,
MailingPostalCode
FROM Contact
WHERE Id = :contactId];
// 1. Shipment and Shipment Info (required object)
zkmulti__MCShipment__c ship = new zkmulti__MCShipment__c(
zkmulti__Carrier__c = 'UPS',
zkmulti__Label_Image_Type__c = 'GIF',
// sender info
zkmulti__Sender_Name__c = shipmatePref.zkmulti__Sender_Name_Default__c,
zkmulti__Sender_City__c = shipmatePref.zkmulti__Shipping_City__c,
zkmulti__Sender_Company__c = shipmatePref.zkmulti__Company_Name__c,
zkmulti__Sender_Country__c = shipmatePref.zkmulti__Shipping_Country__c,
zkmulti__Sender_Email__c = shipmatePref.zkmulti__Sender_Email_Default__c,
zkmulti__Sender_Phone__c = shipmatePref.zkmulti__Sender_Phone_Default__c,
zkmulti__Sender_State_Province__c = shipmatePref.zkmulti__Shipping_State__c,
zkmulti__Sender_Street__c = shipmatePref.zkmulti__Shipping_Street__c,
zkmulti__Sender_Zip_Postal_Code__c = shipmatePref.zkmulti__Shipping_Zip_Postal_Code__c,
zkmulti__Sender_Address_is_Residential__c = false,
// recipient info
zkmulti__Recipient_City__c = con.MailingCity,
zkmulti__Recipient_Company__c = con.Account.Name,
zkmulti__Recipient_Country__c = con.MailingCountry,
zkmulti__Recipient_Email__c = con.Email,
zkmulti__Recipient_Name__c = con.FirstName + ' ' + con.LastName,
zkmulti__Recipient_Phone__c = con.Phone,
zkmulti__Recipient_State_Province__c = con.MailingState,
zkmulti__Recipient_Street__c = con.MailingStreet,
zkmulti__Recipient_Zip_Postal_Code__c = con.MailingPostalCode,
zkmulti__Ship_Date__c = Date.today(),
zkmulti__Currency__c = 'USD',
zkmulti__Dimension_Units__c = 'IN',
zkmulti__Weight_Units__c = 'LBS',
zkmulti__Service_Type__c = 'UPS_GROUND',
zkmulti__Package_Type__c = 'UPS_YOUR_PACKAGING',
zkmulti__Payment_Type__c = 'SENDER',
zkmulti__Billing_Account_Number__c = shipmatePref.zkmulti__AccountNumber__c,
zkmulti__Billing_Country__c = shipmatePref.zkmulti__Billing_Country__c
);
// 2. Packages
List<zkmulti__MCPackage__c> packages = new List<zkmulti__MCPackage__c>();
zkmulti__MCPackage__c pkg = new zkmulti__MCPackage__c (
zkmulti__Weight__c = 1,
zkmulti__Length__c = 1,
zkmulti__Width__c = 1,
zkmulti__Height__c = 1,
zkmulti__DeclaredValue__c = 0
);
packages.add(pkg);
List<ShipmentRate> rates = zkmulti.BulkShipmentInterface.calculateRates(shipmatePref.Id, ship, packages, null, null, null);
System.debug('RATES: ' + rates);
/*
Example:
[
carrier=UPS,
cost=null,
currencyIsoCode=null,
delivery_date=null,
delivery_days=2,
estimate_delivery_days=null,
mailService=null,
params={carriage_charges=35.22, currency=USD, negotiated_total_charges=34.87, scheduled_delivery_time=10:30 A.M., service_option_charges=0.00, total_charges=35.22},
rate=35.22,
service_type=UPS_SECOND_DAY_AIR_AM,
shipmentProvider=null
]
*/

Calculate Rates Interlink

Id prefId = 'a025800000OBkHb'; 
Id contactId = '0035800000MnthL'; // Gb Contact
zkmulti__MCShipmate_Preference__c shipmatePref = [
SELECT Id, Name, zkmulti__AccountNumber__c,
zkmulti__Carrier__c, zkmulti__Label_Image_Type_Default__c,
zkmulti__Billing_City__c, zkmulti__Billing_Country__c, zkmulti__Billing_State__c,
zkmulti__Billing_Street__c, zkmulti__Billing_Zip_Postal_Code__c, zkmulti__Company_Name__c, zkmulti__Sender_Email_Default__c, zkmulti__Sender_Name_Default__c,
zkmulti__Sender_Phone_Default__c, zkmulti__Shipping_City__c, zkmulti__Shipping_Country__c, zkmulti__Shipping_Is_Residential__c,
zkmulti__Shipping_State__c, zkmulti__Shipping_Street__c, zkmulti__Shipping_Zip_Postal_Code__c, zkmulti__Currency_Default__c
FROM zkmulti__MCShipmate_Preference__c
WHERE Id = :prefId];
// get contact information (for recipient information)
Contact con = [
SELECT MailingCity, Account.Name, MailingCountry,
Email, FirstName, LastName,
Phone, MailingState, MailingStreet,
MailingPostalCode
FROM Contact
WHERE Id = :contactId];
// 1. Shipment and Shipment Info (required object)
zkmulti__MCShipment__c ship = new zkmulti__MCShipment__c(
zkmulti__Carrier__c = 'InterlinkExpress',
zkmulti__Label_Image_Type__c = 'PNG',
// sender info
zkmulti__Sender_Name__c = shipmatePref.zkmulti__Sender_Name_Default__c,
zkmulti__Sender_City__c = shipmatePref.zkmulti__Shipping_City__c,
zkmulti__Sender_Company__c = shipmatePref.zkmulti__Company_Name__c,
zkmulti__Sender_Country__c = shipmatePref.zkmulti__Shipping_Country__c,
zkmulti__Sender_Email__c = shipmatePref.zkmulti__Sender_Email_Default__c,
zkmulti__Sender_Phone__c = shipmatePref.zkmulti__Sender_Phone_Default__c,
zkmulti__Sender_State_Province__c = shipmatePref.zkmulti__Shipping_State__c,
zkmulti__Sender_Street__c = shipmatePref.zkmulti__Shipping_Street__c,
zkmulti__Sender_Zip_Postal_Code__c = shipmatePref.zkmulti__Shipping_Zip_Postal_Code__c,
zkmulti__Sender_Address_is_Residential__c = false,
// recipient info
zkmulti__Recipient_City__c = con.MailingCity,
zkmulti__Recipient_Company__c = con.Account.Name,
zkmulti__Recipient_Country__c = con.MailingCountry,
zkmulti__Recipient_Email__c = con.Email,
zkmulti__Recipient_Name__c = con.FirstName + ' ' + con.LastName,
zkmulti__Recipient_Phone__c = con.Phone,
zkmulti__Recipient_State_Province__c = con.MailingState,
zkmulti__Recipient_Street__c = con.MailingStreet,
zkmulti__Recipient_Zip_Postal_Code__c = con.MailingPostalCode,
zkmulti__Ship_Date__c = Date.today(),
zkmulti__Currency__c = 'GBP',
zkmulti__Dimension_Units__c = 'IN',
zkmulti__Weight_Units__c = 'LB',
zkmulti__Service_Type__c = 'InterlinkExpresspak1By10:30',
zkmulti__Package_Type__c = 'Parcel',
zkmulti__Payment_Type__c = 'SENDER'
);
// 2. Packages
List<zkmulti__MCPackage__c> packages = new List<zkmulti__MCPackage__c>();
zkmulti__MCPackage__c pkg = new zkmulti__MCPackage__c (
zkmulti__Weight__c = 1,
zkmulti__Length__c = 1,
zkmulti__Width__c = 1,
zkmulti__Height__c = 1,
zkmulti__DeclaredValue__c = 0
);
packages.add(pkg);
List<ShipmentRate> rates = zkmulti.BulkShipmentInterface.calculateRates(shipmatePref.Id, ship, packages, null, null, null);
System.debug('RATES: ' + rates);
/*
Example:
[
carrier=InterlinkExpress,
cost=null,
currencyIsoCode=null,
delivery_date=null,
delivery_days=1,
estimate_delivery_days=null,
mailService=null,
params={delivery_type=null, product_id=null, product_type=null},
rate=0.01,
service_type=InterlinkExpresspak1By12,
shipmentProvider=null
]
*/

Calculate Rates FedEx

Id prefId = 'a025800000OAzvj'; 
Id contactId = '00358000006wy1I'; // Jack Rodgers
zkmulti__MCShipmate_Preference__c shipmatePref = [
SELECT Id, Name, zkmulti__AccountNumber__c,
zkmulti__Carrier__c, zkmulti__Label_Image_Type_Default__c,
zkmulti__Billing_City__c, zkmulti__Billing_Country__c, zkmulti__Billing_State__c,
zkmulti__Billing_Street__c, zkmulti__Billing_Zip_Postal_Code__c, zkmulti__Company_Name__c, zkmulti__Sender_Email_Default__c, zkmulti__Sender_Name_Default__c,
zkmulti__Sender_Phone_Default__c, zkmulti__Shipping_City__c, zkmulti__Shipping_Country__c, zkmulti__Shipping_Is_Residential__c,
zkmulti__Shipping_State__c, zkmulti__Shipping_Street__c, zkmulti__Shipping_Zip_Postal_Code__c, zkmulti__Currency_Default__c
FROM zkmulti__MCShipmate_Preference__c
WHERE Id = :prefId];
// get contact information (for recipient information)
Contact con = [
SELECT MailingCity, Account.Name, MailingCountry,
Email, FirstName, LastName,
Phone, MailingState, MailingStreet,
MailingPostalCode
FROM Contact
WHERE Id = :contactId];
// 1. Shipment and Shipment Info (required object)
zkmulti__MCShipment__c ship = new zkmulti__MCShipment__c(
zkmulti__Carrier__c = 'FedEx',
zkmulti__DropoffType__c = 'DROP_BOX',
zkmulti__Label_Image_Type__c = 'PNG',
// sender info
zkmulti__Sender_Name__c = shipmatePref.zkmulti__Sender_Name_Default__c,
zkmulti__Sender_City__c = shipmatePref.zkmulti__Shipping_City__c,
zkmulti__Sender_Company__c = shipmatePref.zkmulti__Company_Name__c,
zkmulti__Sender_Country__c = shipmatePref.zkmulti__Shipping_Country__c,
zkmulti__Sender_Email__c = shipmatePref.zkmulti__Sender_Email_Default__c,
zkmulti__Sender_Phone__c = shipmatePref.zkmulti__Sender_Phone_Default__c,
zkmulti__Sender_State_Province__c = shipmatePref.zkmulti__Shipping_State__c,
zkmulti__Sender_Street__c = shipmatePref.zkmulti__Shipping_Street__c,
zkmulti__Sender_Zip_Postal_Code__c = shipmatePref.zkmulti__Shipping_Zip_Postal_Code__c,
zkmulti__Sender_Address_is_Residential__c = false,
// recipient info
zkmulti__Recipient_City__c = con.MailingCity,
zkmulti__Recipient_Company__c = con.Account.Name,
zkmulti__Recipient_Country__c = con.MailingCountry,
zkmulti__Recipient_Email__c = con.Email,
zkmulti__Recipient_Name__c = con.FirstName + ' ' + con.LastName,
zkmulti__Recipient_Phone__c = con.Phone,
zkmulti__Recipient_State_Province__c = con.MailingState,
zkmulti__Recipient_Street__c = con.MailingStreet,
zkmulti__Recipient_Zip_Postal_Code__c = con.MailingPostalCode,
zkmulti__Ship_Date__c = Date.today(),
zkmulti__Currency__c = 'USD',
zkmulti__Dimension_Units__c = 'IN',
zkmulti__Weight_Units__c = 'LB',
zkmulti__Service_Type__c = 'FEDEX_2_DAY_AM',
zkmulti__Package_Type__c = 'YOUR_PACKAGING',
zkmulti__Payment_Type__c = 'SENDER',
zkmulti__Billing_Account_Number__c = shipmatePref.zkmulti__AccountNumber__c,
zkmulti__Billing_Country__c = shipmatePref.zkmulti__Billing_Country__c
);
// 2. Packages
List<zkmulti__MCPackage__c> packages = new List<zkmulti__MCPackage__c>();
zkmulti__MCPackage__c pkg = new zkmulti__MCPackage__c (
zkmulti__Weight__c = 1,
zkmulti__Length__c = 1,
zkmulti__Width__c = 1,
zkmulti__Height__c = 1,
zkmulti__DeclaredValue__c = 0
);
packages.add(pkg);
List<ShipmentRate> rates = zkmulti.BulkShipmentInterface.calculateRates(shipmatePref.Id, ship, packages, null, null, null);
System.debug('RATES: ' + rates);
/*
Example:
[
carrier=FedEx,
cost=null,
currencyIsoCode=null,
delivery_date=2018-07-02 23:00:00,
delivery_days=null,
estimate_delivery_days=null,
mailService=null,
params={base_charge=100.96, delivery_day_of_week=TUE, discounts=0.0, net_charge=107.77, rate_type=PAYOR_ACCOUNT_PACKAGE, rebates=0.0, surcharges=6.81, taxes=0.0, transit_time=null},
rate=107.77,
service_type=FIRST_OVERNIGHT,
shipmentProvider=null
]
*/