Subversion Repositories SmartDukaan

Rev

Rev 22893 | Rev 23526 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
22215 ashik.ali 1
package com.spice.profitmandi.common.util;
2
 
3
import java.util.HashMap;
4
import java.util.Map;
5
 
23502 ashik.ali 6
import org.apache.http.conn.HttpHostConnectException;
7
 
22215 ashik.ali 8
import com.spice.profitmandi.common.enumuration.SchemeType;
9
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
22893 amit.gupta 10
import com.spice.profitmandi.common.model.GadgetCopsDocumentInsuranceModel;
22215 ashik.ali 11
import com.spice.profitmandi.common.model.GadgetCopsInsuranceModel;
12
import com.spice.profitmandi.common.web.client.RestClient;
13
 
14
public class InsuranceUtils {
15
 
16
	private static final String HOST_NAME = "manage.gadgetcops.com";
17
	private static final String URI = "snsydataexchange.asmx/RegisterPolicy";
18
 
19
	private static final String MOBILE_BRAND = "mobileBrand";
20
	private static final String MOBILE_MODEL = "mobileModel";
21
	private static final String MOBILE_IMEI = "mobileIMEI";
22
	private static final String CUS_FIRST_NAME = "cusLastName";
23
	private static final String CUS_LAST_NAME = "cusFirstName";
24
	private static final String CUS_CONTACT_NUMBER = "cusContactNumber";
25
	private static final String CUS_EMAIL = "cusEmail";
26
	private static final String CUS_DOB = "cusDOB";
27
	private static final String CUS_ADDRESS1 = "cusAddress1";
28
	private static final String CUS_ADDRESS2 = "cusAddress2";
29
	private static final String CUS_CITY = "cusCity";
30
	private static final String CUS_STATE = "cusState";
31
	private static final String CUS_ZIP = "cusZip";
32
	private static final String TRANSACTION_DATE = "transactionDate";
33
	private static final String TRANSACTION_INVOICE_VALUE = "transactionInvoiceValue";
34
	private static final String TRANSACTION_INVOICE_NUMBER = "transactionInvoiceNumber";
35
	private static final String TRANSACTION_POLICY_NUMBER = "transactionPolicyNumber";
36
 
37
	public static void submitToGadgetCops(GadgetCopsInsuranceModel gadgetCopsInsuranceModel) throws ProfitMandiBusinessException{
38
		//RestClient rc = new RestClient(SchemeType.HTTP, "www.google.com", 8080);
39
		RestClient restClient = new RestClient(SchemeType.HTTP, HOST_NAME, 80);
40
 
41
		Map<String, String> params = new HashMap<>(18);
42
		//params.put(OP, REGISTER_POLICY);
43
		params.put(MOBILE_BRAND, gadgetCopsInsuranceModel.getBrand());
44
		params.put(MOBILE_MODEL, gadgetCopsInsuranceModel.getModelName());
45
		params.put(MOBILE_IMEI, gadgetCopsInsuranceModel.getSerialNumber());
46
		params.put(CUS_FIRST_NAME, gadgetCopsInsuranceModel.getCustomerFirstName());
47
		params.put(CUS_LAST_NAME, gadgetCopsInsuranceModel.getCustomerLastName());
48
		params.put(CUS_CONTACT_NUMBER, gadgetCopsInsuranceModel.getCustomerMobileNumber());
49
		params.put(CUS_EMAIL, gadgetCopsInsuranceModel.getCustomerEmailId());
50
		params.put(CUS_DOB, StringUtils.toString(gadgetCopsInsuranceModel.getCustomerDateOfBirth()));
51
		params.put(CUS_ADDRESS1, gadgetCopsInsuranceModel.getCustomerAddress1());
52
		params.put(CUS_ADDRESS2, gadgetCopsInsuranceModel.getCustomerAddress2());
53
		params.put(CUS_CITY, gadgetCopsInsuranceModel.getCustomerCity());
54
		params.put(CUS_STATE, gadgetCopsInsuranceModel.getCustomerState());
55
		params.put(CUS_ZIP, gadgetCopsInsuranceModel.getCustomerPinCode());
56
		params.put(TRANSACTION_DATE, StringUtils.toString(gadgetCopsInsuranceModel.getInvoiceCreationDate()));
57
		params.put(TRANSACTION_INVOICE_VALUE, String.valueOf(gadgetCopsInsuranceModel.getPrice()));
58
		params.put(TRANSACTION_INVOICE_NUMBER, gadgetCopsInsuranceModel.getInvoiceNumber());
59
		params.put(TRANSACTION_POLICY_NUMBER, gadgetCopsInsuranceModel.getPolicyNumber());
60
 
61
		Map<String, String> headers = new HashMap<>(0);
62
		//headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
63
 
23502 ashik.ali 64
		try {
65
			restClient.post(URI, params, headers);
66
		} catch (HttpHostConnectException e) {
67
			// TODO Auto-generated catch block
68
			e.printStackTrace();
69
		}
22215 ashik.ali 70
	}
22893 amit.gupta 71
 
72
	public static void submitToGadgetCops(GadgetCopsDocumentInsuranceModel gadgetCopsInsuranceModel) throws ProfitMandiBusinessException{
73
		//RestClient rc = new RestClient(SchemeType.HTTP, "www.google.com", 8080);
74
		RestClient restClient = new RestClient(SchemeType.HTTP, HOST_NAME, 80);
75
 
76
		Map<String, String> params = new HashMap<>(18);
77
		//params.put(OP, REGISTER_POLICY);
78
		params.put(MOBILE_BRAND, gadgetCopsInsuranceModel.getBrand());
79
		params.put(MOBILE_MODEL, gadgetCopsInsuranceModel.getModelName());
80
		params.put(MOBILE_IMEI, gadgetCopsInsuranceModel.getSerialNumber());
81
		params.put(CUS_FIRST_NAME, gadgetCopsInsuranceModel.getCustomerFirstName());
82
		params.put(CUS_LAST_NAME, gadgetCopsInsuranceModel.getCustomerLastName());
83
		params.put(CUS_CONTACT_NUMBER, gadgetCopsInsuranceModel.getCustomerMobileNumber());
84
		params.put(CUS_EMAIL, gadgetCopsInsuranceModel.getCustomerEmailId());
85
		params.put(CUS_DOB, StringUtils.toString(gadgetCopsInsuranceModel.getCustomerDateOfBirth()));
86
		params.put(CUS_ADDRESS1, gadgetCopsInsuranceModel.getCustomerAddress1());
87
		params.put(CUS_ADDRESS2, gadgetCopsInsuranceModel.getCustomerAddress2());
88
		params.put(CUS_CITY, gadgetCopsInsuranceModel.getCustomerCity());
89
		params.put(CUS_STATE, gadgetCopsInsuranceModel.getCustomerState());
90
		params.put(CUS_ZIP, gadgetCopsInsuranceModel.getCustomerPinCode());
91
		params.put(TRANSACTION_DATE, StringUtils.toString(gadgetCopsInsuranceModel.getInvoiceCreationDate()));
92
		params.put(TRANSACTION_INVOICE_VALUE, String.valueOf(gadgetCopsInsuranceModel.getPrice()));
93
		params.put(TRANSACTION_INVOICE_NUMBER, gadgetCopsInsuranceModel.getInvoiceNumber());
94
		params.put(TRANSACTION_POLICY_NUMBER, gadgetCopsInsuranceModel.getPolicyNumber());
95
 
96
		Map<String, String> headers = new HashMap<>(0);
97
		//headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
98
 
23502 ashik.ali 99
		try {
100
			restClient.post(URI, params, headers);
101
		} catch (HttpHostConnectException e) {
102
			// TODO Auto-generated catch block
103
			e.printStackTrace();
104
		}
22893 amit.gupta 105
	}
22215 ashik.ali 106
}