Example 74 : Find delivery options

Printer-friendly version

 This example shows you how to find delivery options.

package com.metapack.dm.test;
 
import com.metapack.deliverymanager.client.AllocationFilter;
import com.metapack.deliverymanager.client.Consignment;
import com.metapack.deliverymanager.client.DeliveryOption;
import com.metapack.deliverymanager.client.webservices.AllocationService;
 
public class Example74 extends ExampleBase {
 
	public void run() throws Exception {
		AllocationService service = createAllocationService();
 
		Consignment consignment = createDefaultConsignment( "EXAMPLE-74" , 1 );
		AllocationFilter filter = null;
		DeliveryOption[] options = service.findDeliveryOptions( consignment , filter );
 
		for( DeliveryOption option : options ) {
			System.out.println( "Service " + option.getCarrierServiceCode() 
					+ " can delivery it and it will cost " + option.getShippingCost() );
		}
	}
 
	public static void main(String[] args ){
		Example74 ex = new Example74();
		try {
			ex.run();
		} catch( Exception e ) {
			e.printStackTrace();
		}
	}
}