Rev 22893 | Rev 23526 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.common.util;import java.util.HashMap;import java.util.Map;import org.apache.http.conn.HttpHostConnectException;import com.spice.profitmandi.common.enumuration.SchemeType;import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;import com.spice.profitmandi.common.model.GadgetCopsDocumentInsuranceModel;import com.spice.profitmandi.common.model.GadgetCopsInsuranceModel;import com.spice.profitmandi.common.web.client.RestClient;public class InsuranceUtils {private static final String HOST_NAME = "manage.gadgetcops.com";private static final String URI = "snsydataexchange.asmx/RegisterPolicy";private static final String MOBILE_BRAND = "mobileBrand";private static final String MOBILE_MODEL = "mobileModel";private static final String MOBILE_IMEI = "mobileIMEI";private static final String CUS_FIRST_NAME = "cusLastName";private static final String CUS_LAST_NAME = "cusFirstName";private static final String CUS_CONTACT_NUMBER = "cusContactNumber";private static final String CUS_EMAIL = "cusEmail";private static final String CUS_DOB = "cusDOB";private static final String CUS_ADDRESS1 = "cusAddress1";private static final String CUS_ADDRESS2 = "cusAddress2";private static final String CUS_CITY = "cusCity";private static final String CUS_STATE = "cusState";private static final String CUS_ZIP = "cusZip";private static final String TRANSACTION_DATE = "transactionDate";private static final String TRANSACTION_INVOICE_VALUE = "transactionInvoiceValue";private static final String TRANSACTION_INVOICE_NUMBER = "transactionInvoiceNumber";private static final String TRANSACTION_POLICY_NUMBER = "transactionPolicyNumber";public static void submitToGadgetCops(GadgetCopsInsuranceModel gadgetCopsInsuranceModel) throws ProfitMandiBusinessException{//RestClient rc = new RestClient(SchemeType.HTTP, "www.google.com", 8080);RestClient restClient = new RestClient(SchemeType.HTTP, HOST_NAME, 80);Map<String, String> params = new HashMap<>(18);//params.put(OP, REGISTER_POLICY);params.put(MOBILE_BRAND, gadgetCopsInsuranceModel.getBrand());params.put(MOBILE_MODEL, gadgetCopsInsuranceModel.getModelName());params.put(MOBILE_IMEI, gadgetCopsInsuranceModel.getSerialNumber());params.put(CUS_FIRST_NAME, gadgetCopsInsuranceModel.getCustomerFirstName());params.put(CUS_LAST_NAME, gadgetCopsInsuranceModel.getCustomerLastName());params.put(CUS_CONTACT_NUMBER, gadgetCopsInsuranceModel.getCustomerMobileNumber());params.put(CUS_EMAIL, gadgetCopsInsuranceModel.getCustomerEmailId());params.put(CUS_DOB, StringUtils.toString(gadgetCopsInsuranceModel.getCustomerDateOfBirth()));params.put(CUS_ADDRESS1, gadgetCopsInsuranceModel.getCustomerAddress1());params.put(CUS_ADDRESS2, gadgetCopsInsuranceModel.getCustomerAddress2());params.put(CUS_CITY, gadgetCopsInsuranceModel.getCustomerCity());params.put(CUS_STATE, gadgetCopsInsuranceModel.getCustomerState());params.put(CUS_ZIP, gadgetCopsInsuranceModel.getCustomerPinCode());params.put(TRANSACTION_DATE, StringUtils.toString(gadgetCopsInsuranceModel.getInvoiceCreationDate()));params.put(TRANSACTION_INVOICE_VALUE, String.valueOf(gadgetCopsInsuranceModel.getPrice()));params.put(TRANSACTION_INVOICE_NUMBER, gadgetCopsInsuranceModel.getInvoiceNumber());params.put(TRANSACTION_POLICY_NUMBER, gadgetCopsInsuranceModel.getPolicyNumber());Map<String, String> headers = new HashMap<>(0);//headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);try {restClient.post(URI, params, headers);} catch (HttpHostConnectException e) {// TODO Auto-generated catch blocke.printStackTrace();}}public static void submitToGadgetCops(GadgetCopsDocumentInsuranceModel gadgetCopsInsuranceModel) throws ProfitMandiBusinessException{//RestClient rc = new RestClient(SchemeType.HTTP, "www.google.com", 8080);RestClient restClient = new RestClient(SchemeType.HTTP, HOST_NAME, 80);Map<String, String> params = new HashMap<>(18);//params.put(OP, REGISTER_POLICY);params.put(MOBILE_BRAND, gadgetCopsInsuranceModel.getBrand());params.put(MOBILE_MODEL, gadgetCopsInsuranceModel.getModelName());params.put(MOBILE_IMEI, gadgetCopsInsuranceModel.getSerialNumber());params.put(CUS_FIRST_NAME, gadgetCopsInsuranceModel.getCustomerFirstName());params.put(CUS_LAST_NAME, gadgetCopsInsuranceModel.getCustomerLastName());params.put(CUS_CONTACT_NUMBER, gadgetCopsInsuranceModel.getCustomerMobileNumber());params.put(CUS_EMAIL, gadgetCopsInsuranceModel.getCustomerEmailId());params.put(CUS_DOB, StringUtils.toString(gadgetCopsInsuranceModel.getCustomerDateOfBirth()));params.put(CUS_ADDRESS1, gadgetCopsInsuranceModel.getCustomerAddress1());params.put(CUS_ADDRESS2, gadgetCopsInsuranceModel.getCustomerAddress2());params.put(CUS_CITY, gadgetCopsInsuranceModel.getCustomerCity());params.put(CUS_STATE, gadgetCopsInsuranceModel.getCustomerState());params.put(CUS_ZIP, gadgetCopsInsuranceModel.getCustomerPinCode());params.put(TRANSACTION_DATE, StringUtils.toString(gadgetCopsInsuranceModel.getInvoiceCreationDate()));params.put(TRANSACTION_INVOICE_VALUE, String.valueOf(gadgetCopsInsuranceModel.getPrice()));params.put(TRANSACTION_INVOICE_NUMBER, gadgetCopsInsuranceModel.getInvoiceNumber());params.put(TRANSACTION_POLICY_NUMBER, gadgetCopsInsuranceModel.getPolicyNumber());Map<String, String> headers = new HashMap<>(0);//headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED_VALUE);try {restClient.post(URI, params, headers);} catch (HttpHostConnectException e) {// TODO Auto-generated catch blocke.printStackTrace();}}}