Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
20640 amit.gupta 1
package com.aramex.impl;
2
 
3
import java.util.Calendar;
4
 
5
import com.aramex.stub.Address;
6
import com.aramex.stub.ArrayOfShipment;
7
import com.aramex.stub.ClientInfo;
8
import com.aramex.stub.Contact;
9
import com.aramex.stub.Dimensions;
10
import com.aramex.stub.LabelInfo;
11
import com.aramex.stub.Money;
12
import com.aramex.stub.Party;
13
import com.aramex.stub.ProcessedShipment;
14
import com.aramex.stub.Service_1_0_PortType;
15
import com.aramex.stub.Service_1_0_Service;
16
import com.aramex.stub.Service_1_0_ServiceLocator;
17
import com.aramex.stub.Shipment;
18
import com.aramex.stub.ShipmentCreationRequest;
19
import com.aramex.stub.ShipmentCreationResponse;
20
import com.aramex.stub.ShipmentDetails;
21
import com.aramex.stub.Weight;
22
 
23
public class AramexTest {
24
 
25
	public static void main(String[] args) throws Exception {
26
		/*
27
		 * 
28
		AccountCountryCode =JO
29
		AccountEntity = AMM
30
		AccountNumber= 20016
31
		AccountPin = 331421
32
		UserName = testingapi@aramex.com
33
		Password = R123456789$r
34
		Version = v1.0
35
		*/
36
		Service_1_0_Service aramexService = new Service_1_0_ServiceLocator();
37
		Service_1_0_PortType service = aramexService.getBasicHttpBinding_Service_1_0();
38
		ShipmentCreationRequest parameters = new ShipmentCreationRequest();
39
		ArrayOfShipment shipments = new ArrayOfShipment();
40
		Shipment [] shipArray = new Shipment[1];
41
		Shipment shpmnt = new Shipment();
42
		Party consignee = new Party();
43
 
44
		Contact contact = new Contact();
45
		contact.setCellPhone("9990381569");
46
		contact.setEmailAddress("amit.gupta@shop2020.in");
47
		contact.setPersonName("Amit Gupta");
48
		contact.setPhoneNumber1("1234567890");
49
		contact.setCompanyName("test");
50
		consignee.setContact(contact);
51
 
52
		Address consigneeAddress = new Address();
53
		consigneeAddress.setLine1("356, Divine Grace, Sector Omega-IV");
54
		consigneeAddress.setLine2("Greater Noida, Gautam Budh Nagar");
55
		consigneeAddress.setCity("Noida");
56
		consigneeAddress.setStateOrProvinceCode("UP");
57
		consigneeAddress.setPostCode("201301");
58
		consigneeAddress.setCountryCode("IN");
59
 
60
		consignee.setPartyAddress(consigneeAddress);
61
		shpmnt.setConsignee(consignee );
62
 
63
 
64
		shpmnt.setShipper(getTestShipper());
65
		shpmnt.setPickupLocation("Gurgaon");
66
		shpmnt.setShippingDateTime(Calendar.getInstance());
67
		Calendar dueDate = Calendar.getInstance();
68
		dueDate.add(Calendar.DATE, 5);
69
		shpmnt.setDueDate(dueDate);
70
 
71
		ShipmentDetails details = new ShipmentDetails();
72
		details.setProductGroup("DOM");
73
		details.setProductType("CDA");
74
		details.setPaymentType("P");
75
		Weight actualWeight = new Weight();
76
		actualWeight.setUnit("KG");
77
		actualWeight.setValue(0.3);
78
		details.setActualWeight(actualWeight);
79
		details.setChargeableWeight(new Weight("KG", 0.3));
80
		details.setDimensions(new Dimensions(10, 10, 10, "CM"));
81
		details.setDescriptionOfGoods("Electronics");
82
		details.setGoodsOriginCountry("IN");
83
		details.setServices("CODS");
84
		//if cod then
85
		details.setCashOnDeliveryAmount(new Money("INR", 600));
86
		details.setCustomsValueAmount(new Money("INR", 550));
87
		details.setNumberOfPieces(1);
88
		shpmnt.setDetails(details);
89
		//shpmnt.sr
90
 
91
		shipArray[0]=shpmnt;
92
		shipments.setShipment(shipArray);
93
 
94
		LabelInfo labelInfo = new LabelInfo();
95
		labelInfo.setReportID(9729);
96
		labelInfo.setReportType("URL");
97
 
98
		parameters.setLabelInfo(labelInfo);
99
		parameters.setClientInfo(getTestClientInfo());
100
		parameters.setShipments(shipments);
101
 
102
 
103
		ShipmentCreationResponse scr = service.createShipments(parameters);
104
		if(scr.getHasErrors() && (scr.getNotifications() == null ||scr.getShipments().getProcessedShipment(0)==null)) {
105
			System.out.println("Some error " +  scr.getNotifications().getNotification());
106
			return;
107
		}
108
		ProcessedShipment ps = scr.getShipments().getProcessedShipment(0);
109
		System.out.println(ps.getID());
110
 
111
	}
112
 
113
	private static Party getTestShipper() {
114
		Party shipper = new Party();
115
		shipper.setAccountNumber("DELTST002");
116
		Contact sc = new Contact();
117
		sc.setEmailAddress("testingapi@aramex.com");
118
		sc.setCellPhone("9990381569");
119
		sc.setCompanyName("TEST");
120
		sc.setPersonName("Test");
121
		sc.setPhoneNumber1("1234567890");
122
		shipper.setContact(sc);
123
		Address shipperAddress = new Address();
124
		shipperAddress.setLine1("Test");
125
		shipperAddress.setCity("Ggn");
126
		shipperAddress.setCountryCode("IN");
127
		shipperAddress.setPostCode("110001");
128
		shipper.setPartyAddress(shipperAddress);
129
		return shipper;
130
	}
131
 
132
	private static ClientInfo getTestClientInfo() {
133
		ClientInfo clientInfo = new ClientInfo();
134
		clientInfo.setAccountCountryCode("IN");
135
		clientInfo.setAccountNumber("DELTST002");
136
		clientInfo.setVersion("v1.0");	
137
		clientInfo.setAccountEntity("DEL");
138
		clientInfo.setUserName("testingapi@aramex.com");
139
		clientInfo.setPassword("R123456789$r");
140
		clientInfo.setAccountPin("231164");
141
		return clientInfo;
142
	}
143
}