/**
* PlayTrade API Java Client
* Copyright 2013 PureBuy Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use the this PlayTrade API Java Client except
* in compliance with the License.
*
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.IOException;
import uk.co.purebuy.commerce.businessobjects.importexport.playtrade.call.PlayTradeApiCallException;
import uk.co.purebuy.commerce.businessobjects.importexport.playtrade.call.UploadDispatchNotesCall;
import uk.co.purebuy.commerce.businessobjects.importexport.playtrade.dom.DispatchNotification;
import uk.co.purebuy.commerce.businessobjects.importexport.playtrade.dom.DispatchNotificationRow;
/**
* This example will notify PlayTrade servers that
* an order have been dispatched and give the postal
* tracking information for the order.
*
* @author Dave/James Allcock
* Copyright 2013 PureBuy Ltd
*/
public class UploadDispatchNotes
{
/**
* @param args
* @throws IOException
* @throws PlayTradeApiCallException
*/
public static void main(String[] args) throws IOException, PlayTradeApiCallException
{
//create the dispatch notifcation report
DispatchNotification dispatch_notification = new DispatchNotification();
//create data for each order to be notified
DispatchNotificationRow row_data = new DispatchNotificationRow();
row_data.setOrderId( "5743938475894" ); //the playtrade orderid
row_data.setDispatched("Y"); //the order has been dispatched
row_data.setCarrierId( DispatchNotification.CarrierID.Royal_Mail ); //use playtrades index to their carriers if possible
row_data.setTrackingNo( "tracking_#" ); //the courier tracking number
//add data to the report
dispatch_notification.addRowData(row_data);
//create the call
UploadDispatchNotesCall call = new UploadDispatchNotesCall();
//set the authentication
call.setUsername("user@email.com");
call.setPassword("password");
//set the orders to be notified
call.setDispatchNotification(dispatch_notification);
//make the call to the playtrade API
call.callUploadDispatchNotes();
System.out.println("SUCCESS: Submitted Dispatch Notification feed to PlayTrade '" + call.getBatchfile().getAbsolutePath() + "'");
}
}