Subversion Repositories SmartDukaan

Rev

Rev 23526 | 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
 
23526 ashik.ali 39
		RestClient restClient = new RestClient();
22215 ashik.ali 40
		Map<String, String> params = new HashMap<>(18);
41
		//params.put(OP, REGISTER_POLICY);
42
		params.put(MOBILE_BRAND, gadgetCopsInsuranceModel.getBrand());
43
		params.put(MOBILE_MODEL, gadgetCopsInsuranceModel.getModelName());
44
		params.put(MOBILE_IMEI, gadgetCopsInsuranceModel.getSerialNumber());
45
		params.put(CUS_FIRST_NAME, gadgetCopsInsuranceModel.getCustomerFirstName());
46
		params.put(CUS_LAST_NAME, gadgetCopsInsuranceModel.getCustomerLastName());
47
		params.put(CUS_CONTACT_NUMBER, gadgetCopsInsuranceModel.getCustomerMobileNumber());
48
		params.put(CUS_EMAIL, gadgetCopsInsuranceModel.getCustomerEmailId());
23602 amit.gupta 49
		params.put(CUS_DOB, StringUtils.toGadgetCopDateString(gadgetCopsInsuranceModel.getCustomerDateOfBirth()));
22215 ashik.ali 50
		params.put(CUS_ADDRESS1, gadgetCopsInsuranceModel.getCustomerAddress1());
51
		params.put(CUS_ADDRESS2, gadgetCopsInsuranceModel.getCustomerAddress2());
52
		params.put(CUS_CITY, gadgetCopsInsuranceModel.getCustomerCity());
53
		params.put(CUS_STATE, gadgetCopsInsuranceModel.getCustomerState());
54
		params.put(CUS_ZIP, gadgetCopsInsuranceModel.getCustomerPinCode());
23602 amit.gupta 55
		params.put(TRANSACTION_DATE, StringUtils.toGadgetCopDateString(gadgetCopsInsuranceModel.getInvoiceCreationDate()));
22215 ashik.ali 56
		params.put(TRANSACTION_INVOICE_VALUE, String.valueOf(gadgetCopsInsuranceModel.getPrice()));
57
		params.put(TRANSACTION_INVOICE_NUMBER, gadgetCopsInsuranceModel.getInvoiceNumber());
58
		params.put(TRANSACTION_POLICY_NUMBER, gadgetCopsInsuranceModel.getPolicyNumber());
59
 
60
		Map<String, String> headers = new HashMap<>(0);
61
		//headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
62
 
23502 ashik.ali 63
		try {
23526 ashik.ali 64
			restClient.post(SchemeType.HTTP, HOST_NAME, 80, URI, params, headers);
23502 ashik.ali 65
		} catch (HttpHostConnectException e) {
66
			// TODO Auto-generated catch block
67
			e.printStackTrace();
68
		}
22215 ashik.ali 69
	}
22893 amit.gupta 70
 
71
	public static void submitToGadgetCops(GadgetCopsDocumentInsuranceModel gadgetCopsInsuranceModel) throws ProfitMandiBusinessException{
23526 ashik.ali 72
		RestClient restClient = new RestClient();
22893 amit.gupta 73
		Map<String, String> params = new HashMap<>(18);
74
		//params.put(OP, REGISTER_POLICY);
75
		params.put(MOBILE_BRAND, gadgetCopsInsuranceModel.getBrand());
76
		params.put(MOBILE_MODEL, gadgetCopsInsuranceModel.getModelName());
77
		params.put(MOBILE_IMEI, gadgetCopsInsuranceModel.getSerialNumber());
78
		params.put(CUS_FIRST_NAME, gadgetCopsInsuranceModel.getCustomerFirstName());
79
		params.put(CUS_LAST_NAME, gadgetCopsInsuranceModel.getCustomerLastName());
80
		params.put(CUS_CONTACT_NUMBER, gadgetCopsInsuranceModel.getCustomerMobileNumber());
81
		params.put(CUS_EMAIL, gadgetCopsInsuranceModel.getCustomerEmailId());
23602 amit.gupta 82
		params.put(CUS_DOB, StringUtils.toGadgetCopDateString(gadgetCopsInsuranceModel.getCustomerDateOfBirth()));
22893 amit.gupta 83
		params.put(CUS_ADDRESS1, gadgetCopsInsuranceModel.getCustomerAddress1());
84
		params.put(CUS_ADDRESS2, gadgetCopsInsuranceModel.getCustomerAddress2());
85
		params.put(CUS_CITY, gadgetCopsInsuranceModel.getCustomerCity());
86
		params.put(CUS_STATE, gadgetCopsInsuranceModel.getCustomerState());
87
		params.put(CUS_ZIP, gadgetCopsInsuranceModel.getCustomerPinCode());
23602 amit.gupta 88
		params.put(TRANSACTION_DATE, StringUtils.toGadgetCopDateString(gadgetCopsInsuranceModel.getInvoiceCreationDate()));
22893 amit.gupta 89
		params.put(TRANSACTION_INVOICE_VALUE, String.valueOf(gadgetCopsInsuranceModel.getPrice()));
90
		params.put(TRANSACTION_INVOICE_NUMBER, gadgetCopsInsuranceModel.getInvoiceNumber());
91
		params.put(TRANSACTION_POLICY_NUMBER, gadgetCopsInsuranceModel.getPolicyNumber());
92
 
93
		Map<String, String> headers = new HashMap<>(0);
94
		//headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);
95
 
23502 ashik.ali 96
		try {
23526 ashik.ali 97
			restClient.post(SchemeType.HTTP, HOST_NAME, 80, URI, params, headers);
23502 ashik.ali 98
		} catch (HttpHostConnectException e) {
99
			// TODO Auto-generated catch block
100
			e.printStackTrace();
101
		}
22893 amit.gupta 102
	}
22215 ashik.ali 103
}