Subversion Repositories SmartDukaan

Rev

Rev 20640 | Details | Compare with Previous | 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
		Shipment [] shipArray = new Shipment[1];
40
		Shipment shpmnt = new Shipment();
41
		Party consignee = new Party();
42
 
43
		Contact contact = new Contact();
44
		contact.setCellPhone("9990381569");
45
		contact.setEmailAddress("amit.gupta@shop2020.in");
46
		contact.setPersonName("Amit Gupta");
47
		contact.setPhoneNumber1("1234567890");
48
		contact.setCompanyName("test");
49
		consignee.setContact(contact);
50
 
51
		Address consigneeAddress = new Address();
52
		consigneeAddress.setLine1("356, Divine Grace, Sector Omega-IV");
53
		consigneeAddress.setLine2("Greater Noida, Gautam Budh Nagar");
54
		consigneeAddress.setCity("Noida");
55
		consigneeAddress.setStateOrProvinceCode("UP");
56
		consigneeAddress.setPostCode("201301");
57
		consigneeAddress.setCountryCode("IN");
58
 
59
		consignee.setPartyAddress(consigneeAddress);
60
		shpmnt.setConsignee(consignee );
61
 
62
 
63
		shpmnt.setShipper(getTestShipper());
64
		shpmnt.setPickupLocation("Gurgaon");
65
		shpmnt.setShippingDateTime(Calendar.getInstance());
66
		Calendar dueDate = Calendar.getInstance();
67
		dueDate.add(Calendar.DATE, 5);
68
		shpmnt.setDueDate(dueDate);
69
 
70
		ShipmentDetails details = new ShipmentDetails();
71
		details.setProductGroup("DOM");
72
		details.setProductType("CDA");
73
		details.setPaymentType("P");
74
		Weight actualWeight = new Weight();
75
		actualWeight.setUnit("KG");
76
		actualWeight.setValue(0.3);
77
		details.setActualWeight(actualWeight);
78
		details.setChargeableWeight(new Weight("KG", 0.3));
79
		details.setDimensions(new Dimensions(10, 10, 10, "CM"));
80
		details.setDescriptionOfGoods("Electronics");
81
		details.setGoodsOriginCountry("IN");
82
		details.setServices("CODS");
83
		//if cod then
84
		details.setCashOnDeliveryAmount(new Money("INR", 600));
85
		details.setCustomsValueAmount(new Money("INR", 550));
86
		details.setNumberOfPieces(1);
87
		shpmnt.setDetails(details);
88
		//shpmnt.sr
89
 
90
		shipArray[0]=shpmnt;
91
 
92
		LabelInfo labelInfo = new LabelInfo();
93
		labelInfo.setReportID(9729);
94
		labelInfo.setReportType("URL");
95
 
96
		parameters.setLabelInfo(labelInfo);
97
		parameters.setClientInfo(getTestClientInfo());
22598 amit.gupta 98
		parameters.setShipments(shipArray);
20640 amit.gupta 99
 
100
 
101
		ShipmentCreationResponse scr = service.createShipments(parameters);
22598 amit.gupta 102
		if(scr.getHasErrors() && (scr.getNotifications() == null ||scr.getShipments()[0]==null)) {
103
			System.out.println("Some error " +  scr.getNotifications()[0]);
20640 amit.gupta 104
			return;
105
		}
22598 amit.gupta 106
		ProcessedShipment ps = scr.getShipments()[0];
20640 amit.gupta 107
		System.out.println(ps.getID());
108
 
109
	}
110
 
111
	private static Party getTestShipper() {
112
		Party shipper = new Party();
113
		shipper.setAccountNumber("DELTST002");
114
		Contact sc = new Contact();
115
		sc.setEmailAddress("testingapi@aramex.com");
116
		sc.setCellPhone("9990381569");
117
		sc.setCompanyName("TEST");
118
		sc.setPersonName("Test");
119
		sc.setPhoneNumber1("1234567890");
120
		shipper.setContact(sc);
121
		Address shipperAddress = new Address();
122
		shipperAddress.setLine1("Test");
123
		shipperAddress.setCity("Ggn");
124
		shipperAddress.setCountryCode("IN");
125
		shipperAddress.setPostCode("110001");
126
		shipper.setPartyAddress(shipperAddress);
127
		return shipper;
128
	}
129
 
130
	private static ClientInfo getTestClientInfo() {
131
		ClientInfo clientInfo = new ClientInfo();
132
		clientInfo.setAccountCountryCode("IN");
133
		clientInfo.setAccountNumber("DELTST002");
134
		clientInfo.setVersion("v1.0");	
135
		clientInfo.setAccountEntity("DEL");
136
		clientInfo.setUserName("testingapi@aramex.com");
137
		clientInfo.setPassword("R123456789$r");
138
		clientInfo.setAccountPin("231164");
139
		return clientInfo;
140
	}
141
}