{
	"info": {
		"_postman_id": "cebdb1b1-b5bd-4e90-98c0-a2fd3c63ad45",
		"name": "FnacDarty-370 Patch 20190225_1",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
	},
	"item": [
		{
			"name": "#510 Uniformisation des scripts Neolane",
			"item": [
				{
					"name": "Neolane service activation notification",
					"item": [
						{
							"name": "NeolaneCustomerLifeScript",
							"event": [
								{
									"listen": "test",
									"script": {
										"id": "c9d1777c-3904-4e91-93ad-3705d7967263",
										"exec": [
											"var jsonData = JSON.parse(responseBody);",
											"tests[\"is.success\"] = jsonData.actionStatus.status === \"SUCCESS\";",
											"tests[\"is.compiled\"] = jsonData.compilationErrors.length === 0;",
											""
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										},
										{
											"key": "saveHelperData",
											"value": true,
											"type": "boolean"
										},
										{
											"key": "showPassword",
											"value": false,
											"type": "boolean"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Proxy-Authorization",
										"value": "{{proxy.auth}}"
									},
									{
										"key": "Content-Type",
										"value": "application/json"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\r\n    \"code\": \"org.meveo.service.script.NeolaneCustomerLifeScript\",\r\n    \"description\": \"Call NeolaneCustomerLifeScript\",\r\n    \"type\": \"JAVA\",\r\n    \"script\": \"package org.meveo.service.script;\\r\\n\\r\\nimport org.apache.http.client.methods.CloseableHttpResponse;\\r\\nimport org.apache.http.client.methods.HttpPost;\\r\\nimport org.apache.http.conn.ssl.NoopHostnameVerifier;\\r\\nimport org.apache.http.conn.ssl.SSLContextBuilder;\\r\\nimport org.apache.http.conn.ssl.TrustStrategy;\\r\\nimport org.apache.http.entity.StringEntity;\\r\\nimport org.apache.http.impl.client.CloseableHttpClient;\\r\\nimport org.apache.http.impl.client.HttpClients;\\r\\nimport org.meveo.admin.exception.BusinessException;\\r\\nimport org.meveo.admin.exception.ImportInvoiceException;\\r\\nimport org.meveo.admin.exception.InvoiceExistException;\\r\\nimport org.meveo.api.dto.invoice.GenerateInvoiceRequestDto;\\r\\nimport org.meveo.commons.utils.StringUtils;\\r\\nimport org.meveo.model.ICustomFieldEntity;\\r\\nimport org.meveo.model.admin.Seller;\\r\\nimport org.meveo.model.billing.BillingAccount;\\r\\nimport org.meveo.model.billing.InstanceStatusEnum;\\r\\nimport org.meveo.model.billing.Invoice;\\r\\nimport org.meveo.model.billing.ServiceInstance;\\r\\nimport org.meveo.model.billing.SubCategoryInvoiceAgregate;\\r\\nimport org.meveo.model.billing.Subscription;\\r\\nimport org.meveo.model.billing.UserAccount;\\r\\nimport org.meveo.model.catalog.OfferTemplate;\\r\\nimport org.meveo.model.crm.Customer;\\r\\nimport org.meveo.model.crm.Provider;\\r\\nimport org.meveo.model.payments.CustomerAccount;\\r\\nimport org.meveo.model.payments.DDPaymentMethod;\\r\\nimport org.meveo.model.payments.PaymentMethod;\\r\\nimport org.meveo.model.payments.PaymentMethodEnum;\\r\\nimport org.meveo.model.shared.ContactInformation;\\r\\nimport org.meveo.model.shared.DateUtils;\\r\\nimport org.meveo.model.shared.Name;\\r\\nimport org.meveo.model.shared.Title;\\r\\nimport org.meveo.service.billing.impl.InvoiceService;\\r\\nimport org.meveo.service.crm.impl.CustomFieldInstanceService;\\r\\nimport org.meveo.service.crm.impl.ProviderService;\\r\\n\\r\\nimport java.io.IOException;\\r\\nimport java.math.BigDecimal;\\r\\nimport java.math.RoundingMode;\\r\\nimport java.security.cert.CertificateException;\\r\\nimport java.security.cert.X509Certificate;\\r\\nimport java.util.Calendar;\\r\\nimport java.util.Date;\\r\\nimport java.util.List;\\r\\nimport java.util.Map;\\r\\n\\r\\n/**\\r\\n * Appel le web service Neolane\\r\\n *    Mail et SMS de bienvenue\\r\\n *    Mail de rappel de l'\\u00E9ch\\u00E9ancier, et montant de la premi\\u00E8re facture\\r\\n *\\r\\n * @author Mounir Bahije\\r\\n */\\r\\npublic class NeolaneCustomerLifeScript extends Script {\\r\\n\\r\\n    private CustomFieldInstanceService cfiService = (CustomFieldInstanceService) getServiceInterface(CustomFieldInstanceService.class.getSimpleName());\\r\\n    private ProviderService providerService = (ProviderService) getServiceInterface(ProviderService.class.getSimpleName());\\r\\n    private InvoiceService invoiceService = (InvoiceService) getServiceInterface(InvoiceService.class.getSimpleName());\\r\\n\\r\\n    private Provider appProvider = providerService.getProvider();\\r\\n\\r\\n    private static final String DATE_PATTERN = \\\"yyyy/MM/dd HH:mm:ss\\\";\\r\\n    private static final String DATE_PATTERN_BODY = \\\"dd/MM/yyyy\\\";\\r\\n    private static final String CF_FD_URL_WS_NCLS = \\\"CF_FD_URL_WS_NCLS\\\";\\r\\n    private static final String CF_FD_ACTION_URI_WS_NCLS = \\\"CF_FD_ACTION_URI_WS_NCLS\\\";\\r\\n    private static final String CF_FD_URL_SELFCARE_NCLS = \\\"CF_FD_URL_SELFCARE_NCLS\\\";\\r\\n    private static final String CF_FD_URL_SERENITE_NCLS = \\\"CF_FD_URL_SERENITE_NCLS\\\";\\r\\n    private static final String CULTURE = \\\"fr-FR\\\";\\r\\n    private static final String SUBSCRIPTION_CREATED = \\\"0\\\";\\r\\n    private static final String SUBSCRIPTION_ACTIVE = \\\"1\\\";\\r\\n    private static final String SUBSCRIPTION_SUSPENDED = \\\"2\\\";\\r\\n    private static final String SUBSCRIPTION_RESILIATED = \\\"3\\\";\\r\\n    private static final String SUBSCRIPTION_CANCELED = \\\"4\\\";\\r\\n    private static final String SUBSCRIPTION_CLOSED = \\\"5\\\";\\r\\n\\r\\n    @Override\\r\\n    public void execute(Map<String, Object> methodContext) throws BusinessException {\\r\\n\\r\\n\\r\\n        if (cfiService == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeScript : cfiService is null\\\");\\r\\n            return;\\r\\n        }\\r\\n        ServiceInstance service = (ServiceInstance) methodContext.get(\\\"event\\\");\\r\\n\\r\\n        if (service != null) {\\r\\n            if (InstanceStatusEnum.ACTIVE == service.getStatus()) {\\r\\n                Subscription subscription = service.getSubscription();\\r\\n                setWSData(subscription);\\r\\n            }\\r\\n        }\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Call Neolane WS\\r\\n     *\\r\\n     * @param soapEnvBody\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private String callWebService(String soapEnvBody) throws BusinessException {\\r\\n\\r\\n        String body =\\r\\n                \\\"<?xml version=\\\\\\\"1.0\\\\\\\" encoding=\\\\\\\"UTF-8\\\\\\\"?><soapenv:Envelope xmlns:soapenv=\\\\\\\"http://schemas.xmlsoap.org/soap/envelope/\\\\\\\" \\\" +\\r\\n                        \\\"xmlns:urn=\\\\\\\"urn:nms:rtMsg\\\\\\\"><soapenv:Header/><soapenv:Body>\\\"\\r\\n                        + soapEnvBody + \\\"</soapenv:Body></soapenv:Envelope>\\\";\\r\\n\\r\\n        StringEntity stringEntity = new StringEntity(body, \\\"UTF-8\\\");\\r\\n\\r\\n        final String wsUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_WS_NCLS, true);\\r\\n        final String actionUri = (String) this.fetchCFConfigValue(appProvider, CF_FD_ACTION_URI_WS_NCLS, true);\\r\\n\\r\\n        // Request parameters and other properties.\\r\\n        HttpPost httpPost = new HttpPost(wsUrl);\\r\\n        httpPost.setEntity(stringEntity);\\r\\n        httpPost.setHeader(\\\"SOAPAction\\\", actionUri);\\r\\n\\r\\n        // Execute and get the response.\\r\\n        CloseableHttpClient httpClient = getCloseableHttpClient();\\r\\n        CloseableHttpResponse response = null;\\r\\n        try {\\r\\n\\r\\n            log.info(\\\"we want to sent to this address = \\\" + actionUri);\\r\\n            log.info(\\\"This body = \\\" + body);\\r\\n\\r\\n            response = httpClient.execute(httpPost);\\r\\n            boolean responseOk = false;\\r\\n            if (response != null) {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    if (response.getStatusLine().getStatusCode() == 200) {\\r\\n                        responseOk = true;\\r\\n                        log.info(\\\"in NeolaneCustomerLifeScript : body sent and it's Ok\\\");\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n            if (responseOk) {\\r\\n                return \\\"OK\\\";\\r\\n            } else {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    log.error(\\\"In NeolaneCustomerLifeScript : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                } else {\\r\\n                    log.error(\\\"In NeolaneCustomerLifeScript : response.getStatusLine() = null \\\");\\r\\n                }\\r\\n                return \\\"KO\\\";\\r\\n            }\\r\\n\\r\\n        } catch (IOException e) {\\r\\n            log.error(\\\"Exception in NeolaneCustomerLifeScript :\\\", e);\\r\\n        }\\r\\n        return \\\"KO\\\";\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * fetch CF Config Value\\r\\n     *\\r\\n     * @param entity\\r\\n     * @param cfKey\\r\\n     * @param isMandatory\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private Object fetchCFConfigValue(ICustomFieldEntity entity, String cfKey, boolean isMandatory) throws BusinessException {\\r\\n        Object cfValue = cfiService.getCFValue(entity, cfKey);\\r\\n        if (isMandatory && (cfValue == null || (cfValue instanceof String && org.apache.commons.lang3.StringUtils.isEmpty(String.valueOf(cfValue))))) {\\r\\n            throw new BusinessException(\\\" Missing mandatory config [\\\" + cfKey + \\\"]\\\");\\r\\n        }\\r\\n        return cfValue;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * get CloseableHttpClient\\r\\n     *\\r\\n     * @return trusted httpClient\\r\\n     */\\r\\n    public CloseableHttpClient getCloseableHttpClient()\\r\\n    {\\r\\n        CloseableHttpClient httpClient = null;\\r\\n        try {\\r\\n            httpClient = HttpClients.custom().\\r\\n                    setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).\\r\\n                    setSSLContext(new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy()\\r\\n                    {\\r\\n                        public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException\\r\\n                        {\\r\\n                            return true;\\r\\n                        }\\r\\n                    }).build()).build();\\r\\n        } catch (Exception e) {\\r\\n            log.error(\\\"KeyManagementException in creating http client instance\\\", e);\\r\\n        }\\r\\n        return httpClient;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Set Data for Neolane WS\\r\\n     *\\r\\n     * @param subscription the subscription activated\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private void setWSData(Subscription subscription) throws BusinessException {\\r\\n\\r\\n        Date nowDate = new Date();\\r\\n\\r\\n        if (subscription == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeScript : subscription is null\\\");\\r\\n            return;\\r\\n        }\\r\\n\\r\\n        List<ServiceInstance> listServiceSearchLicence = subscription.getServiceInstances();\\r\\n        if (listServiceSearchLicence == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeScript : services of subscription is null / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n\\r\\n        String licence = \\\"\\\";\\r\\n        String offerType = \\\"FNAC+\\\";\\r\\n        for (ServiceInstance serviceSearchLicence : listServiceSearchLicence) {\\r\\n            if (serviceSearchLicence == null) {\\r\\n                log.error(\\\"NeolaneCustomerLifeScript : serviceSearchLicence is null / subscription code = \\\" + subscription.getCode());\\r\\n                continue;\\r\\n            }\\r\\n            if (\\\"SE_FD_LICENCE\\\".equalsIgnoreCase(serviceSearchLicence.getCode())) {\\r\\n                offerType = \\\"SERENITE\\\";\\r\\n                licence = (String) cfiService.getInheritedCFValue(serviceSearchLicence, \\\"CF_SE_FD_LICENCE_NUMBER\\\");\\r\\n            }\\r\\n        }\\r\\n\\r\\n        UserAccount userAccount = subscription.getUserAccount();\\r\\n        if (userAccount == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeScript : userAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n        ContactInformation contactInformation = userAccount.getContactInformation();\\r\\n        if (contactInformation == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeScript : contactInformation is null / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n\\r\\n        //////////////\\r\\n        String email = contactInformation.getEmail();\\r\\n\\r\\n        String ws_address = email;\\r\\n\\r\\n        String ws_culture = CULTURE;\\r\\n\\r\\n        String ws_sendByMail = \\\"true\\\";\\r\\n\\r\\n        String ws_sendBySMS = \\\"true\\\";\\r\\n\\r\\n        String cellphone = contactInformation.getMobile();\\r\\n        if (StringUtils.isBlank(cellphone)) {\\r\\n            cellphone = \\\"\\\";\\r\\n        }\\r\\n        String ws_cellphone = cellphone;\\r\\n\\r\\n        BillingAccount billingAccount = userAccount.getBillingAccount();\\r\\n        if (billingAccount == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeScript : billingAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n\\r\\n\\r\\n        Calendar expirationDateCalendar = Calendar.getInstance();\\r\\n        expirationDateCalendar.setTime(nowDate);\\r\\n        expirationDateCalendar.add(Calendar.HOUR_OF_DAY, 12);\\r\\n        String ws_expirationDate = DateUtils.formatDateWithPattern(expirationDateCalendar.getTime(), DATE_PATTERN);\\r\\n\\r\\n        String ws_originalDate = DateUtils.formatDateWithPattern(nowDate, DATE_PATTERN);\\r\\n\\r\\n\\r\\n        String ws_rcpId = \\\"-2\\\";\\r\\n\\r\\n        String ws_templateBienvenue = \\\"BIENV_OPENCELL_FPL\\\";\\r\\n        if (\\\"SERENITE\\\".equals(offerType))\\r\\n            ws_templateBienvenue = \\\"BIENV_OPENCELL_SER\\\";\\r\\n\\r\\n        OfferTemplate offer = subscription.getOffer();\\r\\n        if (offer == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeScript : offer is null / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n\\r\\n        String ws_templateRappel = \\\"ECHEA_OPENCELL_FPL\\\";\\r\\n        if (\\\"SERENITE\\\".equals(offerType)) {\\r\\n            String periodicity = \\\"\\\";\\r\\n            if (cfiService.getInheritedCFValue(offer, \\\"CF_OF_FD_CALENDAR\\\") != null) {\\r\\n                periodicity = String.valueOf(cfiService.getInheritedCFValue(offer, \\\"CF_OF_FD_CALENDAR\\\"));\\r\\n            }\\r\\n            if ((\\\"CAL_MONTHLY_1ST\\\".equalsIgnoreCase(periodicity)) || (\\\"CAL_MONTHLY_PERIOD\\\".equalsIgnoreCase(periodicity))) {\\r\\n                ws_templateRappel = \\\"ECHEA_OPENCELL_SER_M\\\";\\r\\n            } else {\\r\\n                ws_templateRappel = \\\"ECHEA_OPENCELL_SER_A\\\";\\r\\n            }\\r\\n\\r\\n        }\\r\\n\\r\\n        String ws_enseigne = \\\"\\\";\\r\\n        boolean enseigneTest = false;\\r\\n        Seller seller = subscription.getSeller();\\r\\n        Seller seller_N_1 = null;\\r\\n        Seller seller_N_2 = null;\\r\\n        if (seller != null) {\\r\\n            seller_N_1 = seller.getSeller();\\r\\n            if (seller_N_1 != null) {\\r\\n                seller_N_2 = seller_N_1.getSeller();\\r\\n                if (seller_N_2 != null) {\\r\\n                    if (seller_N_2.getCode() != null) {\\r\\n                        enseigneTest = true;\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n        }\\r\\n        if (enseigneTest) {\\r\\n            ws_enseigne = seller_N_2.getCode();\\r\\n        } else {\\r\\n            log.error(\\\"NeolaneCustomerLifeScript : enseigne is undefined / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n\\r\\n        CustomerAccount customerAccount = billingAccount.getCustomerAccount();\\r\\n        if (customerAccount == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeScript : customerAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n\\r\\n        boolean nameOk = false;\\r\\n        Customer customer = null;\\r\\n        Name name = null;\\r\\n        Title title = null;\\r\\n        if (customerAccount != null) {\\r\\n            customer = customerAccount.getCustomer();\\r\\n            if (customer != null) {\\r\\n                name = customer.getName();\\r\\n                if (name != null) {\\r\\n                    nameOk = true;\\r\\n                }\\r\\n            }\\r\\n        }\\r\\n\\r\\n        if (nameOk == false) {\\r\\n            log.error(\\\"NeolaneCustomerLifeScript : problem with name / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n        title = name.getTitle();\\r\\n        String ws_gender = \\\"\\\";\\r\\n        if (title != null && title.getCode() != null) {\\r\\n            ws_gender = title.getCode();\\r\\n        }\\r\\n\\r\\n        String ws_firstName = (name.getFirstName() == null) ? \\\"\\\" : name.getFirstName();\\r\\n        String ws_lastName = (name.getLastName() == null) ? \\\"\\\" : name.getLastName();\\r\\n\\r\\n        String ws_email = email;\\r\\n\\r\\n        String ws_contractNumber = subscription.getCode();\\r\\n\\r\\n        String ws_offerLabel = (offer.getName() == null) ? \\\"\\\" : offer.getName();\\r\\n\\r\\n        String ws_contractStatus = \\\"\\\";\\r\\n        if (subscription.getStatus() == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeScript : subscription.status is null / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n\\r\\n        switch (subscription.getStatus()) {\\r\\n            case CREATED:\\r\\n                ws_contractStatus = SUBSCRIPTION_CREATED;\\r\\n                break;\\r\\n            case ACTIVE:\\r\\n                ws_contractStatus = SUBSCRIPTION_ACTIVE;\\r\\n                break;\\r\\n            case CANCELED:\\r\\n                ws_contractStatus = SUBSCRIPTION_CANCELED;\\r\\n                break;\\r\\n            case RESILIATED:\\r\\n                ws_contractStatus = SUBSCRIPTION_RESILIATED;\\r\\n                break;\\r\\n            case CLOSED:\\r\\n                ws_contractStatus = SUBSCRIPTION_CLOSED;\\r\\n                break;\\r\\n            case SUSPENDED:\\r\\n                ws_contractStatus = SUBSCRIPTION_SUSPENDED;\\r\\n                break;\\r\\n            default:\\r\\n                ws_contractStatus = \\\"\\\";\\r\\n        }\\r\\n\\r\\n        String ws_cardNumber = \\\"\\\";\\r\\n        String ws_serenityUrl = \\\"\\\";\\r\\n        if (\\\"SERENITE\\\".equals(offerType)) {\\r\\n            ws_cardNumber = licence;\\r\\n            final String urlSerenite = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_SERENITE_NCLS, true);\\r\\n            ws_serenityUrl = urlSerenite + licence;\\r\\n        } else {\\r\\n            if (StringUtils.isBlank(cfiService.getInheritedCFValue(subscription, \\\"CF_SU_FD_CARD_NUMBER\\\"))) {\\r\\n                ws_cardNumber = \\\"\\\";\\r\\n            } else {\\r\\n                ws_cardNumber = (String) cfiService.getInheritedCFValue(subscription, \\\"CF_SU_FD_CARD_NUMBER\\\");\\r\\n            }\\r\\n        }\\r\\n\\r\\n        String ws_adhNumber = \\\"\\\";\\r\\n\\r\\n        final String selfCareUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_SELFCARE_NCLS, true);\\r\\n        String ws_urlSelfcare = \\\"\\\";\\r\\n        if (!StringUtils.isBlank(selfCareUrl)) {\\r\\n            ws_urlSelfcare = selfCareUrl;\\r\\n        }\\r\\n\\r\\n        String ws_engagmentEndDateBienvenue = \\\"\\\";\\r\\n\\r\\n        String ws_engagmentEndDateRappel  = DateUtils.formatDateWithPattern(subscription.getEndAgreementDate(), DATE_PATTERN_BODY);\\r\\n\\r\\n        String ws_tryBuyEndDate = \\\"\\\";\\r\\n        if (\\\"SERENITE\\\".equals(offerType)) {\\r\\n            ws_tryBuyEndDate = \\\"\\\";\\r\\n        } else {\\r\\n            Long trialDuratien = (Long) cfiService.getInheritedCFValue(subscription, \\\"CF_OF_SU_FD_TRY_DURATION\\\");\\r\\n            if (trialDuratien == null) {\\r\\n                trialDuratien = 0L;\\r\\n            }\\r\\n            Date subscriptionDate = subscription.getSubscriptionDate();\\r\\n            if (subscriptionDate == null) {\\r\\n                ws_tryBuyEndDate = \\\"\\\";\\r\\n            } else {\\r\\n                Date endOfTrialDate = DateUtils.addDaysToDate(subscriptionDate, trialDuratien.intValue()) ;\\r\\n                ws_tryBuyEndDate = DateUtils.formatDateWithPattern(endOfTrialDate, DATE_PATTERN_BODY);\\r\\n            }\\r\\n        }\\r\\n\\r\\n        String ws_subAmount = \\\"0\\\";\\r\\n        if (cfiService.getInheritedCFValue(subscription.getOffer(), \\\"CF_OF_FD_PRICE\\\") != null) {\\r\\n            ws_subAmount = String.valueOf(cfiService.getInheritedCFValue(subscription.getOffer(), \\\"CF_OF_FD_PRICE\\\"));\\r\\n        }\\r\\n\\r\\n        String ws_cbValidityDate = \\\"\\\";\\r\\n        String ws_paymentModeBienvenue = \\\"\\\";\\r\\n        String ws_paymentModeRappel = \\\"\\\";\\r\\n        PaymentMethod preferredPaymentMethod = customerAccount.getPreferredPaymentMethod();\\r\\n        if (preferredPaymentMethod != null) {\\r\\n            PaymentMethodEnum paymentType = preferredPaymentMethod.getPaymentType();\\r\\n            if (paymentType != null) {\\r\\n                if ((PaymentMethodEnum.DIRECTDEBIT == paymentType) || (PaymentMethodEnum.WIRETRANSFER == paymentType)) {\\r\\n                    ws_paymentModeRappel = \\\"SEPA\\\";\\r\\n                } else if (PaymentMethodEnum.CARD == paymentType) {\\r\\n                    ws_paymentModeRappel = \\\"CB\\\";\\r\\n                }\\r\\n            }\\r\\n        }\\r\\n\\r\\n        String ws_rejectDate = \\\"\\\";\\r\\n        String ws_rejectedInvoiceNb = \\\"\\\";\\r\\n        String ws_rejectedAmountTTC = \\\"\\\";\\r\\n        String ws_reason = \\\"\\\";\\r\\n\\r\\n        String ws_amountDrawnBienvenue = \\\"\\\";\\r\\n        String ws_withdrawalDateBienvenue = \\\"\\\";\\r\\n\\r\\n        String ws_amountDrawnRappel = \\\"\\\";\\r\\n        String ws_withdrawalDateRappel = \\\"\\\";\\r\\n\\r\\n\\r\\n        GenerateInvoiceRequestDto generateInvoiceRequestDto = new GenerateInvoiceRequestDto();\\r\\n\\r\\n        generateInvoiceRequestDto.setTargetType(\\\"BillingAccount\\\");\\r\\n        generateInvoiceRequestDto.setTargetCode(billingAccount.getCode());\\r\\n        generateInvoiceRequestDto.setInvoicingDate(new Date());\\r\\n        generateInvoiceRequestDto.setLastTransactionDate(DateUtils.addDaysToDate(new Date(), 1));\\r\\n        generateInvoiceRequestDto.setGenerateXML(false);\\r\\n        generateInvoiceRequestDto.setGeneratePDF(false);\\r\\n        generateInvoiceRequestDto.setGenerateAO(false);\\r\\n        generateInvoiceRequestDto.setIgnoreInvoicingThreshold(true);\\r\\n\\r\\n        BigDecimal totalDiscount = new BigDecimal(\\\"0\\\");\\r\\n        try {\\r\\n            List<Invoice> listInvoice = invoiceService.generateInvoice(billingAccount, generateInvoiceRequestDto, null, true);\\r\\n            if (listInvoice != null) {\\r\\n\\r\\n                for (Invoice invoice : listInvoice) {\\r\\n                    List<SubCategoryInvoiceAgregate> discountAgregates = invoice.getDiscountAgregates();\\r\\n                    if (discountAgregates != null) {\\r\\n                        for (SubCategoryInvoiceAgregate subCategoryInvoiceAgregate : discountAgregates) {\\r\\n                            totalDiscount.add(subCategoryInvoiceAgregate.getAmountWithoutTax());\\r\\n                        }\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n\\r\\n            if (listInvoice != null) {\\r\\n                for (Invoice invoice : listInvoice) {\\r\\n                    invoiceService.cancelInvoice(invoice);\\r\\n                    invoiceService.commit();\\r\\n                }\\r\\n            }\\r\\n\\r\\n        } catch (InvoiceExistException e) {\\r\\n            log.error(\\\"In NeolaneCustomerLifeScript InvoiceExistException = \\\" + e);\\r\\n        } catch (ImportInvoiceException e) {\\r\\n            log.error(\\\"In NeolaneCustomerLifeScript ImportInvoiceException = \\\" + e);\\r\\n        }\\r\\n\\r\\n        if (!\\\"0\\\".equals(ws_subAmount)) {\\r\\n            BigDecimal ws_subAmountValue = new BigDecimal(ws_subAmount);\\r\\n            ws_subAmountValue.add(totalDiscount);\\r\\n            ws_amountDrawnRappel = (ws_subAmountValue.setScale(2, RoundingMode.DOWN)).toString();\\r\\n            Date withdrawalDate = billingAccount.getNextInvoiceDate();\\r\\n            ws_withdrawalDateRappel = DateUtils.formatDateWithPattern(withdrawalDate, DATE_PATTERN_BODY);\\r\\n        }\\r\\n\\r\\n\\r\\n        String ws_oneTimeCBPaymentDate = \\\"\\\";\\r\\n        String ws_oneTimePaymentAmount = \\\"\\\";\\r\\n        String ws_refundDate = \\\"\\\";\\r\\n        String ws_refundAmount = \\\"\\\";\\r\\n        String ws_discountEntryDate = \\\"\\\";\\r\\n        String ws_discountAmount = \\\"\\\";\\r\\n        String ws_transacAutorisationNb = \\\"\\\";\\r\\n        String ws_rumBienvenue = \\\"\\\";\\r\\n        String ws_icsBienvenue = \\\"\\\";\\r\\n        String ws_legalEntityNameBienvenue = \\\"\\\";\\r\\n\\r\\n        String ws_rumRappel = \\\"\\\";\\r\\n        String ws_icsRappel = \\\"\\\";\\r\\n        String ws_legalEntityNameRappel = \\\"\\\";\\r\\n\\r\\n        if (preferredPaymentMethod instanceof DDPaymentMethod) {\\r\\n            ws_rumRappel = ((DDPaymentMethod) preferredPaymentMethod).getMandateIdentification();\\r\\n        }\\r\\n\\r\\n        Seller entiteJuridique = seller_N_1;\\r\\n        ws_icsRappel = (String) cfiService.getInheritedCFValue(entiteJuridique, \\\"CF_S_FD_ICS\\\");\\r\\n\\r\\n        ws_legalEntityNameRappel = entiteJuridique.getDescription();\\r\\n\\r\\n        String ws_activationDate = \\\"\\\";\\r\\n        String ws_terminationDate = \\\"\\\";\\r\\n        String ws_terminationReason = \\\"\\\";\\r\\n        String ws_trActivationDate = \\\"\\\";\\r\\n        String ws_trDeactivationDate = \\\"\\\";\\r\\n\\r\\n        String soapEnvBodyBienvenue =\\r\\n\\r\\n                \\\"<urn:Submit><urn:sessiontoken></urn:sessiontoken><urn:elemCtx><ctx \\\" + \\\" address=\\\\\\\"\\\" + ws_address + \\\"\\\\\\\"\\\" + \\\" culture=\\\\\\\"\\\" + ws_culture + \\\"\\\\\\\"\\\"\\r\\n                        + \\\" sendByMail=\\\\\\\"\\\" + ws_sendByMail + \\\"\\\\\\\"\\\" + \\\" sendBySMS=\\\\\\\"\\\" + ws_sendBySMS + \\\"\\\\\\\"\\\" + \\\" cellphone=\\\\\\\"\\\" + ws_cellphone + \\\"\\\\\\\"\\\" + \\\" expirationDate=\\\\\\\"\\\"\\r\\n                        + ws_expirationDate + \\\"\\\\\\\"\\\" + \\\" originalDate=\\\\\\\"\\\" + ws_originalDate + \\\"\\\\\\\"\\\" + \\\" rcpId=\\\\\\\"\\\" + ws_rcpId + \\\"\\\\\\\"\\\" + \\\" template=\\\\\\\"\\\" + ws_templateBienvenue\\r\\n                        + \\\"\\\\\\\"\\\" + \\\" xmlns=\\\\\\\"\\\\\\\">\\\" + \\\"<CUSTOMER> \\\" + \\\"<Enseigne>\\\" + ws_enseigne + \\\"</Enseigne>\\\" + \\\"<Gender>\\\" + ws_gender + \\\"</Gender>\\\" + \\\"<FirstName>\\\"\\r\\n                        + ws_firstName + \\\"</FirstName>\\\" + \\\"<LastName>\\\" + ws_lastName + \\\"</LastName>\\\" + \\\"<Email>\\\" + ws_email + \\\"</Email>\\\" + \\\"<SendBySMS>\\\" + ws_sendBySMS\\r\\n                        + \\\"</SendBySMS>\\\" + \\\"<sendByMail>\\\" + ws_sendByMail + \\\"</sendByMail>\\\" + \\\"<ContractNumber>\\\" + ws_contractNumber + \\\"</ContractNumber>\\\" + \\\"<offerLabel>\\\"\\r\\n                        + ws_offerLabel + \\\"</offerLabel>\\\" + \\\"<ContractStatus>\\\" + ws_contractStatus + \\\"</ContractStatus>\\\" + \\\"<CardNumber>\\\" + ws_cardNumber + \\\"</CardNumber>\\\"\\r\\n                        + \\\"<AdhNumber>\\\" + ws_adhNumber + \\\"</AdhNumber>\\\" + \\\"<SelfCareUrl>\\\" + ws_urlSelfcare + \\\"</SelfCareUrl>\\\" + \\\"<SerenityUrl>\\\" + ws_serenityUrl\\r\\n                        + \\\"</SerenityUrl>\\\" + \\\"<EngagmentEndDate>\\\" + ws_engagmentEndDateBienvenue + \\\"</EngagmentEndDate>\\\" + \\\"<TryBuyEndDate>\\\" + ws_tryBuyEndDate\\r\\n                        + \\\"</TryBuyEndDate>\\\" + \\\"<SubAmount>\\\" + ws_subAmount + \\\"</SubAmount>\\\" + \\\"</CUSTOMER> \\\" + \\\"<INVOICE> \\\" + \\\"<CBValidityDate>\\\" + ws_cbValidityDate\\r\\n                        + \\\"</CBValidityDate>\\\" + \\\"<PaymentMode>\\\" + ws_paymentModeBienvenue + \\\"</PaymentMode>\\\" + \\\"<RejectDate>\\\" + ws_rejectDate + \\\"</RejectDate>\\\"\\r\\n                        + \\\"<RejectedInvoiceNb>\\\" + ws_rejectedInvoiceNb + \\\"</RejectedInvoiceNb>\\\" + \\\"<RejectedAmountTTC>\\\" + ws_rejectedAmountTTC + \\\"</RejectedAmountTTC>\\\"\\r\\n                        + \\\"<Reason>\\\" + ws_reason + \\\"</Reason>\\\" + \\\"<AmountDrawn>\\\" + ws_amountDrawnBienvenue + \\\"</AmountDrawn>\\\" + \\\"<WithdrawalDate>\\\" + ws_withdrawalDateBienvenue\\r\\n                        + \\\"</WithdrawalDate>\\\" + \\\"<OneTimeCBPaymentDate>\\\" + ws_oneTimeCBPaymentDate + \\\"</OneTimeCBPaymentDate>\\\" + \\\"<OneTimePaymentAmount>\\\"\\r\\n                        + ws_oneTimePaymentAmount + \\\"</OneTimePaymentAmount>\\\" + \\\"<RefundDate>\\\" + ws_refundDate + \\\"</RefundDate>\\\" + \\\"<RefundAmount>\\\" + ws_refundAmount\\r\\n                        + \\\"</RefundAmount>\\\" + \\\"<DiscountEntryDate>\\\" + ws_discountEntryDate + \\\"</DiscountEntryDate>\\\" + \\\"<DiscountAmount>\\\" + ws_discountAmount\\r\\n                        + \\\"</DiscountAmount>\\\" + \\\"<TransacAutorisationNb>\\\" + ws_transacAutorisationNb + \\\"</TransacAutorisationNb>\\\" + \\\"<Rum>\\\" + ws_rumBienvenue + \\\"</Rum>\\\" + \\\"<Ics>\\\"\\r\\n                        + ws_icsBienvenue + \\\"</Ics>\\\" + \\\"<LegalEntityName>\\\" + ws_legalEntityNameBienvenue + \\\"</LegalEntityName>\\\" + \\\"</INVOICE>\\\" + \\\"<TERMINATION>\\\" + \\\"<ActivationDate>\\\"\\r\\n                        + ws_activationDate + \\\"</ActivationDate>\\\" + \\\"<TerminationDate>\\\" + ws_terminationDate + \\\"</TerminationDate>\\\" + \\\"<TerminationReason>\\\"\\r\\n                        + ws_terminationReason + \\\"</TerminationReason>\\\" + \\\"</TERMINATION>\\\" + \\\"<TACITRENEWAL>\\\" + \\\"<TrActivationDate>\\\" + ws_trActivationDate\\r\\n                        + \\\"</TrActivationDate>\\\" + \\\"<TrDeactivationDate>\\\" + ws_trDeactivationDate + \\\"</TrDeactivationDate>\\\" + \\\"</TACITRENEWAL>\\\"\\r\\n                        + \\\"</ctx></urn:elemCtx></urn:Submit>\\\";\\r\\n\\r\\n        String responseBienvenue = callWebService(soapEnvBodyBienvenue);\\r\\n\\r\\n        log.info(\\\"responseBienvenue = \\\" + responseBienvenue);\\r\\n        log.info(\\\"soapEnvBodyBienvenue = \\\" + soapEnvBodyBienvenue);\\r\\n\\r\\n        String soapEnvBodyRappel =\\r\\n\\r\\n                \\\"<urn:Submit><urn:sessiontoken></urn:sessiontoken><urn:elemCtx><ctx \\\" + \\\" address=\\\\\\\"\\\" + ws_address + \\\"\\\\\\\"\\\" + \\\" culture=\\\\\\\"\\\" + ws_culture + \\\"\\\\\\\"\\\"\\r\\n                        + \\\" sendByMail=\\\\\\\"\\\" + ws_sendByMail + \\\"\\\\\\\"\\\" + \\\" sendBySMS=\\\\\\\"\\\" + ws_sendBySMS + \\\"\\\\\\\"\\\" + \\\" cellphone=\\\\\\\"\\\" + ws_cellphone + \\\"\\\\\\\"\\\" + \\\" expirationDate=\\\\\\\"\\\"\\r\\n                        + ws_expirationDate + \\\"\\\\\\\"\\\" + \\\" originalDate=\\\\\\\"\\\" + ws_originalDate + \\\"\\\\\\\"\\\" + \\\" rcpId=\\\\\\\"\\\" + ws_rcpId + \\\"\\\\\\\"\\\" + \\\" template=\\\\\\\"\\\" + ws_templateRappel + \\\"\\\\\\\"\\\"\\r\\n                        + \\\" xmlns=\\\\\\\"\\\\\\\">\\\" + \\\"<CUSTOMER> \\\" + \\\"<Enseigne>\\\" + ws_enseigne + \\\"</Enseigne>\\\" + \\\"<Gender>\\\" + ws_gender + \\\"</Gender>\\\" + \\\"<FirstName>\\\" + ws_firstName\\r\\n                        + \\\"</FirstName>\\\" + \\\"<LastName>\\\" + ws_lastName + \\\"</LastName>\\\" + \\\"<Email>\\\" + ws_email + \\\"</Email>\\\" + \\\"<SendBySMS>\\\" + ws_sendBySMS + \\\"</SendBySMS>\\\"\\r\\n                        + \\\"<sendByMail>\\\" + ws_sendByMail + \\\"</sendByMail>\\\" + \\\"<ContractNumber>\\\" + ws_contractNumber + \\\"</ContractNumber>\\\" + \\\"<offerLabel>\\\" + ws_offerLabel\\r\\n                        + \\\"</offerLabel>\\\" + \\\"<ContractStatus>\\\" + ws_contractStatus + \\\"</ContractStatus>\\\" + \\\"<CardNumber>\\\" + ws_cardNumber + \\\"</CardNumber>\\\" + \\\"<AdhNumber>\\\"\\r\\n                        + ws_adhNumber + \\\"</AdhNumber>\\\" + \\\"<SelfCareUrl>\\\" + ws_urlSelfcare + \\\"</SelfCareUrl>\\\" + \\\"<SerenityUrl>\\\" + ws_serenityUrl + \\\"</SerenityUrl>\\\"\\r\\n                        + \\\"<EngagmentEndDate>\\\" + ws_engagmentEndDateRappel + \\\"</EngagmentEndDate>\\\" + \\\"<TryBuyEndDate>\\\" + ws_tryBuyEndDate + \\\"</TryBuyEndDate>\\\"\\r\\n                        + \\\"<SubAmount>\\\" + ws_subAmount + \\\"</SubAmount>\\\" + \\\"</CUSTOMER> \\\" + \\\"<INVOICE> \\\" + \\\"<CBValidityDate>\\\" + ws_cbValidityDate + \\\"</CBValidityDate>\\\"\\r\\n                        + \\\"<PaymentMode>\\\" + ws_paymentModeRappel + \\\"</PaymentMode>\\\" + \\\"<RejectDate>\\\" + ws_rejectDate + \\\"</RejectDate>\\\" + \\\"<RejectedInvoiceNb>\\\"\\r\\n                        + ws_rejectedInvoiceNb + \\\"</RejectedInvoiceNb>\\\" + \\\"<RejectedAmountTTC>\\\" + ws_rejectedAmountTTC + \\\"</RejectedAmountTTC>\\\" + \\\"<Reason>\\\" + ws_reason\\r\\n                        + \\\"</Reason>\\\" + \\\"<AmountDrawn>\\\" + ws_amountDrawnRappel + \\\"</AmountDrawn>\\\" + \\\"<WithdrawalDate>\\\" + ws_withdrawalDateRappel + \\\"</WithdrawalDate>\\\"\\r\\n                        + \\\"<OneTimeCBPaymentDate>\\\" + ws_oneTimeCBPaymentDate + \\\"</OneTimeCBPaymentDate>\\\" + \\\"<OneTimePaymentAmount>\\\" + ws_oneTimePaymentAmount\\r\\n                        + \\\"</OneTimePaymentAmount>\\\" + \\\"<RefundDate>\\\" + ws_refundDate + \\\"</RefundDate>\\\" + \\\"<RefundAmount>\\\" + ws_refundAmount + \\\"</RefundAmount>\\\"\\r\\n                        + \\\"<DiscountEntryDate>\\\" + ws_discountEntryDate + \\\"</DiscountEntryDate>\\\" + \\\"<DiscountAmount>\\\" + ws_discountAmount + \\\"</DiscountAmount>\\\"\\r\\n                        + \\\"<TransacAutorisationNb>\\\" + ws_transacAutorisationNb + \\\"</TransacAutorisationNb>\\\" + \\\"<Rum>\\\" + ws_rumRappel + \\\"</Rum>\\\" + \\\"<Ics>\\\" + ws_icsRappel + \\\"</Ics>\\\"\\r\\n                        + \\\"<LegalEntityName>\\\" + ws_legalEntityNameRappel + \\\"</LegalEntityName>\\\" + \\\"</INVOICE>\\\" + \\\"<TERMINATION>\\\" + \\\"<ActivationDate>\\\" + ws_activationDate\\r\\n                        + \\\"</ActivationDate>\\\" + \\\"<TerminationDate>\\\" + ws_terminationDate + \\\"</TerminationDate>\\\" + \\\"<TerminationReason>\\\" + ws_terminationReason\\r\\n                        + \\\"</TerminationReason>\\\" + \\\"</TERMINATION>\\\" + \\\"<TACITRENEWAL>\\\" + \\\"<TrActivationDate>\\\" + ws_trActivationDate + \\\"</TrActivationDate>\\\"\\r\\n                        + \\\"<TrDeactivationDate>\\\" + ws_trDeactivationDate + \\\"</TrDeactivationDate>\\\" + \\\"</TACITRENEWAL>\\\" + \\\"</ctx></urn:elemCtx></urn:Submit>\\\";\\r\\n\\r\\n        String responseRappel = callWebService(soapEnvBodyRappel);\\r\\n        log.info(\\\"responseRappel = \\\" + responseRappel);\\r\\n        log.info(\\\"soapEnvBodyRappel = \\\" + soapEnvBodyRappel);\\r\\n\\r\\n    }\\r\\n}\",\r\n    \"executionRoles\": [],\r\n    \"sourcingRoles\": []\r\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/scriptInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"scriptInstance",
										"createOrUpdate"
									]
								},
								"description": "&#9888; comportement différent en fonction de échu (màj nb lic) / échoir (màj+valo diff)"
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLife_J0_Script",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										},
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"org.meveo.service.script.NeolaneCustomerLife_J0_Script\",\n    \"description\": \"NeolaneCustomerLife_J0 Script\",\n    \"type\": \"JAVA\",\n    \"script\": \"package org.meveo.service.script;\\r\\n\\r\\nimport org.apache.http.client.methods.CloseableHttpResponse;\\r\\nimport org.apache.http.client.methods.HttpPost;\\r\\nimport org.apache.http.conn.ssl.NoopHostnameVerifier;\\r\\nimport org.apache.http.conn.ssl.SSLContextBuilder;\\r\\nimport org.apache.http.conn.ssl.TrustStrategy;\\r\\nimport org.apache.http.entity.StringEntity;\\r\\nimport org.apache.http.impl.client.CloseableHttpClient;\\r\\nimport org.apache.http.impl.client.HttpClients;\\r\\nimport org.meveo.admin.exception.BusinessException;\\r\\nimport org.meveo.commons.utils.StringUtils;\\r\\nimport org.meveo.model.ICustomFieldEntity;\\r\\nimport org.meveo.model.admin.Seller;\\r\\nimport org.meveo.model.billing.BillingAccount;\\r\\nimport org.meveo.model.billing.ServiceInstance;\\r\\nimport org.meveo.model.billing.Subscription;\\r\\nimport org.meveo.model.billing.SubscriptionRenewal;\\r\\nimport org.meveo.model.billing.UserAccount;\\r\\nimport org.meveo.model.catalog.OfferTemplate;\\r\\nimport org.meveo.model.crm.Customer;\\r\\nimport org.meveo.model.crm.Provider;\\r\\nimport org.meveo.model.payments.CustomerAccount;\\r\\nimport org.meveo.model.payments.DDPaymentMethod;\\r\\nimport org.meveo.model.payments.PaymentMethod;\\r\\nimport org.meveo.model.shared.ContactInformation;\\r\\nimport org.meveo.model.shared.DateUtils;\\r\\nimport org.meveo.model.shared.Name;\\r\\nimport org.meveo.model.shared.Title;\\r\\nimport org.meveo.service.billing.impl.ServiceInstanceService;\\r\\nimport org.meveo.service.crm.impl.CustomFieldInstanceService;\\r\\nimport org.meveo.service.crm.impl.ProviderService;\\r\\n\\r\\nimport java.io.IOException;\\r\\nimport java.security.cert.CertificateException;\\r\\nimport java.security.cert.X509Certificate;\\r\\nimport java.util.Calendar;\\r\\nimport java.util.Date;\\r\\nimport java.util.HashMap;\\r\\nimport java.util.List;\\r\\nimport java.util.Map;\\r\\n\\r\\n/**\\r\\n * Appel le web service Neolane\\r\\n *    Mail de confirmation conversion essai (+ mail de demande d'avis client)\\r\\n *    Mail de confirmation de r\\u00E9siliation , si conversion ko\\r\\n *\\r\\n * @author Mounir Bahije\\r\\n */\\r\\npublic class NeolaneCustomerLife_J0_Script extends Script {\\r\\n\\r\\n    private CustomFieldInstanceService cfiService = (CustomFieldInstanceService) getServiceInterface(\\\"CustomFieldInstanceService\\\");\\r\\n    private ServiceInstanceService serviceInstanceService = (ServiceInstanceService) getServiceInterface(\\\"ServiceInstanceService\\\");\\r\\n    private ProviderService providerService = (ProviderService) getServiceInterface(ProviderService.class.getSimpleName());\\r\\n    private Provider appProvider = providerService.getProvider();\\r\\n\\r\\n    private static final String CULTURE = \\\"fr-FR\\\";\\r\\n    private static final String DATE_PATTERN = \\\"yyyy/MM/dd HH:mm:ss\\\";\\r\\n    private static final String DATE_PATTERN_BODY = \\\"dd/MM/yyyy\\\";\\r\\n    private static final String CF_FD_URL_WS_NCLS = \\\"CF_FD_URL_WS_NCLS\\\";\\r\\n    private static final String CF_FD_ACTION_URI_WS_NCLS = \\\"CF_FD_ACTION_URI_WS_NCLS\\\";\\r\\n    private static final String CF_FD_URL_SELFCARE_NCLS = \\\"CF_FD_URL_SELFCARE_NCLS\\\";\\r\\n\\r\\n    private static final String SUBSCRIPTION_CREATED = \\\"0\\\";\\r\\n    private static final String SUBSCRIPTION_ACTIVE = \\\"1\\\";\\r\\n    private static final String SUBSCRIPTION_SUSPENDED = \\\"2\\\";\\r\\n    private static final String SUBSCRIPTION_RESILIATED = \\\"3\\\";\\r\\n    private static final String SUBSCRIPTION_CANCELED = \\\"4\\\";\\r\\n    private static final String SUBSCRIPTION_CLOSED = \\\"5\\\";\\r\\n    private static final int BEFORE_TRY_END_DATE = 0;\\r\\n\\r\\n    @Override\\r\\n    public void execute(Map<String, Object> methodContext) throws BusinessException {\\r\\n\\r\\n        String searchField = \\\"%\\\" + \\\"REC_MAIN\\\";\\r\\n        String query = String.format(\\\"select  si  from ServiceInstance  si WHERE si.code like '%s'\\\", searchField);\\r\\n        Map<String, Object> params = new HashMap<>();\\r\\n        List<ServiceInstance> listServiceInstance = (List<ServiceInstance>) serviceInstanceService.executeSelectQuery(query.toString(), params);\\r\\n        methodContext.clear();\\r\\n        setWSData(listServiceInstance);\\r\\n\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Call Neolane WS\\r\\n     *\\r\\n     * @param soapEnvBody\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private String callWebService(String soapEnvBody) throws BusinessException {\\r\\n\\r\\n        String body =\\r\\n                \\\"<?xml version=\\\\\\\"1.0\\\\\\\" encoding=\\\\\\\"UTF-8\\\\\\\"?><soapenv:Envelope xmlns:soapenv=\\\\\\\"http://schemas.xmlsoap.org/soap/envelope/\\\\\\\" xmlns:urn=\\\\\\\"urn:nms:rtMsg\\\\\\\"><soapenv:Header/><soapenv:Body>\\\"\\r\\n                        + soapEnvBody + \\\"</soapenv:Body></soapenv:Envelope>\\\";\\r\\n        StringEntity stringEntity = new StringEntity(body, \\\"UTF-8\\\");\\r\\n\\r\\n        final String wsUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_WS_NCLS, true);\\r\\n        final String actionUri = (String) this.fetchCFConfigValue(appProvider, CF_FD_ACTION_URI_WS_NCLS, true);\\r\\n\\r\\n        // Request parameters and other properties.\\r\\n        HttpPost httpPost = new HttpPost(wsUrl);\\r\\n        httpPost.setEntity(stringEntity);\\r\\n        httpPost.setHeader(\\\"SOAPAction\\\", actionUri);\\r\\n\\r\\n        // Execute and get the response.\\r\\n        CloseableHttpClient httpClient = getCloseableHttpClient();\\r\\n        CloseableHttpResponse response = null;\\r\\n        try {\\r\\n            log.info(\\\"we want to sent to this address = \\\" + actionUri);\\r\\n            log.info(\\\"This body = \\\" + body);\\r\\n            response = httpClient.execute(httpPost);\\r\\n            boolean responseOk = false;\\r\\n            if (response != null) {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    if (response.getStatusLine().getStatusCode() == 200) {\\r\\n                        responseOk = true;\\r\\n                        log.info(\\\"In NeolaneCustomerLife_J0_Script : body sent and it's Ok\\\");\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n            if (responseOk) {\\r\\n                log.info(\\\"In NeolaneCustomerLife_J0_Script : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                return \\\"OK\\\";\\r\\n            } else {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    log.error(\\\"In NeolaneCustomerLife_J0_Script : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                } else {\\r\\n                    log.error(\\\"In NeolaneCustomerLife_J0_Script : response.getStatusLine() = null \\\");\\r\\n                }\\r\\n                return \\\"KO\\\";\\r\\n            }\\r\\n        } catch (IOException e) {\\r\\n            log.error(\\\"Exception in NeolaneCustomerLife_J0_Script :\\\", e);\\r\\n        }\\r\\n        return \\\"KO\\\";\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * fetch CF Config Value\\r\\n     *\\r\\n     * @param entity\\r\\n     * @param cfKey\\r\\n     * @param isMandatory\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private Object fetchCFConfigValue(ICustomFieldEntity entity, String cfKey, boolean isMandatory) throws BusinessException {\\r\\n        Object cfValue = cfiService.getCFValue(entity, cfKey);\\r\\n        if (isMandatory && (cfValue == null || (cfValue instanceof String && org.apache.commons.lang3.StringUtils.isEmpty(String.valueOf(cfValue))))) {\\r\\n            throw new BusinessException(\\\" Missing mandatory config [\\\" + cfKey + \\\"]\\\");\\r\\n        }\\r\\n        return cfValue;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * get CloseableHttpClient\\r\\n     *\\r\\n     * @return trusted httpClient\\r\\n     */\\r\\n    public  CloseableHttpClient getCloseableHttpClient()\\r\\n    {\\r\\n        CloseableHttpClient httpClient = null;\\r\\n        try {\\r\\n            httpClient = HttpClients.custom().\\r\\n                    setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).\\r\\n                    setSSLContext(new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy()\\r\\n                    {\\r\\n                        public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException\\r\\n                        {\\r\\n                            return true;\\r\\n                        }\\r\\n                    }).build()).build();\\r\\n        } catch (Exception e) {\\r\\n            log.error(\\\"KeyManagementException in creating http client instance\\\", e);\\r\\n        }\\r\\n        return httpClient;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Set Data for Neolane WS\\r\\n     *\\r\\n     * @param listServiceInstance the list of serviceInstance\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private void setWSData(List<ServiceInstance> listServiceInstance) throws BusinessException {\\r\\n\\r\\n        Date nowDate = new Date();\\r\\n\\r\\n        if (listServiceInstance != null) {\\r\\n\\r\\n            for (ServiceInstance serviceInstance : listServiceInstance) {\\r\\n                Subscription subscription = serviceInstance.getSubscription();\\r\\n                List<ServiceInstance> listServiceSearchLicence = subscription.getServiceInstances();\\r\\n                String offerType = \\\"FNAC+\\\";\\r\\n                for (ServiceInstance serviceSearchLicence : listServiceSearchLicence) {\\r\\n                    if (serviceSearchLicence == null) {\\r\\n                        throw new BusinessException(\\\"NeolaneCustomerLife_J0_Script : serviceSearchLicence is null\\\");\\r\\n                    }\\r\\n                    if (\\\"SE_FD_LICENCE\\\".equalsIgnoreCase(serviceSearchLicence.getCode())) {\\r\\n                        offerType = \\\"SERENITE\\\";\\r\\n                    }\\r\\n                }\\r\\n\\r\\n                String ws_tryBuyEndDate = \\\"\\\";\\r\\n                if (\\\"FNAC+\\\".equals(offerType)) {\\r\\n                    Long trialDuratien = (Long) cfiService.getInheritedCFValue(subscription, \\\"CF_OF_SU_FD_TRY_DURATION\\\");\\r\\n                    if (trialDuratien == null) {\\r\\n                        trialDuratien = 0L;\\r\\n                    }\\r\\n                    Date subscriptionDate = subscription.getSubscriptionDate();\\r\\n                    if (subscriptionDate != null) {\\r\\n\\r\\n                        Date endOfTrialDateJourJ = DateUtils.addDaysToDate(subscriptionDate, trialDuratien.intValue() + BEFORE_TRY_END_DATE) ;\\r\\n                        Date endOfTrialDateJourPlusUn = DateUtils.addDaysToDate(subscriptionDate, trialDuratien.intValue() + BEFORE_TRY_END_DATE + 1) ;\\r\\n\\r\\n                        if ((endOfTrialDateJourJ.compareTo(nowDate) <= 0) && (endOfTrialDateJourPlusUn.compareTo(nowDate) > 0)) {\\r\\n\\r\\n\\r\\n                            UserAccount userAccount = subscription.getUserAccount();\\r\\n                            if (userAccount == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J0_Script : userAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n                            BillingAccount billingAccount = userAccount.getBillingAccount();\\r\\n                            if (billingAccount == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J0_Script : billingAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n                            CustomerAccount customerAccount = billingAccount.getCustomerAccount();\\r\\n\\r\\n                            ContactInformation contactInformation = userAccount.getContactInformation();\\r\\n                            if (contactInformation == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J0_Script : contactInformation is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n                            String ws_email = contactInformation.getEmail();\\r\\n                            ws_email = (ws_email == null) ? \\\"\\\" : ws_email;\\r\\n\\r\\n                            String ws_address = ws_email;\\r\\n\\r\\n                            String ws_culture = CULTURE;\\r\\n\\r\\n                            String ws_cellphone = \\\"\\\";\\r\\n\\r\\n                            Calendar expirationDateCalendar = Calendar.getInstance();\\r\\n                            expirationDateCalendar.setTime(nowDate);\\r\\n                            expirationDateCalendar.add(Calendar.HOUR_OF_DAY, 12);\\r\\n                            String ws_expirationDate = DateUtils.formatDateWithPattern(expirationDateCalendar.getTime(), DATE_PATTERN);\\r\\n\\r\\n                            String ws_originalDate = DateUtils.formatDateWithPattern(nowDate, DATE_PATTERN);\\r\\n\\r\\n\\r\\n                            String ws_rcpId = \\\"-2\\\";\\r\\n\\r\\n                            String ws_enseigne = \\\"\\\";\\r\\n                            boolean enseigneTest = false;\\r\\n                            Seller seller = subscription.getSeller();\\r\\n                            Seller seller_N_1 = null;\\r\\n                            Seller seller_N_2 = null;\\r\\n                            if (seller != null) {\\r\\n                                seller_N_1 = seller.getSeller();\\r\\n                                if (seller_N_1 != null) {\\r\\n                                    seller_N_2 = seller_N_1.getSeller();\\r\\n                                    if (seller_N_2 != null) {\\r\\n                                        if (seller_N_2.getCode() != null) {\\r\\n                                            enseigneTest = true;\\r\\n                                        }\\r\\n                                    }\\r\\n                                }\\r\\n                            }\\r\\n                            if (enseigneTest) {\\r\\n                                ws_enseigne = seller_N_2.getCode();\\r\\n                            } else {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J0_Script : enseigne is undefined / subscription code = \\\" + subscription.getCode());\\r\\n                            }\\r\\n\\r\\n                            boolean nameOk = false;\\r\\n                            Customer customer = null;\\r\\n                            Name name = null;\\r\\n                            Title title = null;\\r\\n                            if (customerAccount != null) {\\r\\n                                customer = customerAccount.getCustomer();\\r\\n                                if (customer != null) {\\r\\n                                    name = customer.getName();\\r\\n                                    if (name != null) {\\r\\n                                        nameOk = true;\\r\\n                                    }\\r\\n                                }\\r\\n                            }\\r\\n\\r\\n                            if (nameOk == false) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J0_Script : problem with name / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n                            title = name.getTitle();\\r\\n                            String ws_gender = \\\"\\\";\\r\\n                            if (title != null && title.getCode() != null) {\\r\\n                                ws_gender = title.getCode();\\r\\n                            }\\r\\n\\r\\n                            String ws_firstName = (name.getFirstName() == null) ? \\\"\\\" : name.getFirstName();\\r\\n                            String ws_lastName = (name.getLastName() == null) ? \\\"\\\" : name.getLastName();\\r\\n\\r\\n                            String ws_sendBySMS = \\\"false\\\";\\r\\n\\r\\n                            String ws_sendByMail = \\\"true\\\";\\r\\n\\r\\n                            OfferTemplate offer = subscription.getOffer();\\r\\n                            if (offer == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J0_Script : offer is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n                            String ws_offerLabel = (offer.getName() == null) ? \\\"\\\" : offer.getName();\\r\\n\\r\\n                            String ws_contractStatus = \\\"\\\";\\r\\n                            if (subscription.getStatus() == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J0_Script : subscription.status is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n\\r\\n                            switch (subscription.getStatus()) {\\r\\n                                case CREATED:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_CREATED;\\r\\n                                    break;\\r\\n                                case ACTIVE:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_ACTIVE;\\r\\n                                    break;\\r\\n                                case CANCELED:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_CANCELED;\\r\\n                                    break;\\r\\n                                case RESILIATED:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_RESILIATED;\\r\\n                                    break;\\r\\n                                case CLOSED:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_CLOSED;\\r\\n                                    break;\\r\\n                                case SUSPENDED:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_SUSPENDED;\\r\\n                                    break;\\r\\n                                default:\\r\\n                                    ws_contractStatus = \\\"\\\";\\r\\n                            }\\r\\n\\r\\n                            String ws_contractNumber = subscription.getCode();\\r\\n\\r\\n                            String ws_cardNumber = \\\"\\\";\\r\\n                            String ws_serenityUrl = \\\"\\\";\\r\\n\\r\\n                            if (StringUtils.isBlank(cfiService.getInheritedCFValue(subscription, \\\"CF_SU_FD_CARD_NUMBER\\\"))) {\\r\\n                                ws_cardNumber = \\\"\\\";\\r\\n                            } else {\\r\\n                                ws_cardNumber = (String) cfiService.getInheritedCFValue(subscription, \\\"CF_SU_FD_CARD_NUMBER\\\");\\r\\n                            }\\r\\n\\r\\n                            String ws_adhNumber = \\\"\\\";\\r\\n\\r\\n                            final String selfCareUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_SELFCARE_NCLS, true);\\r\\n                            String ws_urlSelfcare = \\\"\\\";\\r\\n                            if (!StringUtils.isBlank(selfCareUrl)) {\\r\\n                                ws_urlSelfcare = selfCareUrl;\\r\\n                            }\\r\\n\\r\\n                            String ws_engagmentEndDate = DateUtils.formatDateWithPattern(subscription.getEndAgreementDate(),DATE_PATTERN_BODY);\\r\\n\\r\\n                            String ws_subAmount = \\\"\\\";\\r\\n                            if (cfiService.getInheritedCFValue(subscription.getOffer(), \\\"CF_OF_FD_PRICE\\\") != null) {\\r\\n                                ws_subAmount = String.valueOf(cfiService.getInheritedCFValue(subscription.getOffer(), \\\"CF_OF_FD_PRICE\\\"));\\r\\n                            }\\r\\n\\r\\n                            String ws_cbValidityDate = \\\"\\\";\\r\\n                            String ws_paymentMode = \\\"\\\";\\r\\n                            String ws_rejectDate = \\\"\\\";\\r\\n                            String ws_rejectedInvoiceNb = \\\"\\\";\\r\\n                            String ws_rejectedAmountTTC = \\\"\\\";\\r\\n                            String ws_reason = \\\"\\\";\\r\\n                            String ws_amountDrawn = \\\"\\\";\\r\\n                            String ws_withdrawalDate = \\\"\\\";\\r\\n                            String ws_oneTimeCBPaymentDate = \\\"\\\";\\r\\n                            String ws_oneTimePaymentAmount = \\\"\\\";\\r\\n                            String ws_refundDate = \\\"\\\";\\r\\n                            String ws_refundAmount = \\\"\\\";\\r\\n                            String ws_discountEntryDate = \\\"\\\";\\r\\n                            String ws_discountAmount = \\\"\\\";\\r\\n                            String ws_transacAutorisationNb = \\\"\\\";\\r\\n                            String ws_rum = \\\"\\\";\\r\\n                            String ws_ics = \\\"\\\";\\r\\n                            String ws_legalEntityName = \\\"\\\";\\r\\n\\r\\n                            PaymentMethod preferredMethod = null;\\r\\n\\r\\n                            preferredMethod = customerAccount.getPreferredPaymentMethod();\\r\\n\\r\\n                            if (preferredMethod instanceof DDPaymentMethod) {\\r\\n                                ws_rum = ((DDPaymentMethod) preferredMethod).getMandateIdentification();\\r\\n                            }\\r\\n\\r\\n                            Seller entiteJuridique = seller_N_1;\\r\\n                            ws_legalEntityName = entiteJuridique.getDescription();\\r\\n\\r\\n                            ws_ics = (String) cfiService.getInheritedCFValue(entiteJuridique, \\\"CF_S_FD_ICS\\\");\\r\\n\\r\\n                            String ws_activationDate = \\\"\\\";\\r\\n                            String ws_rterminationDate = \\\"\\\";\\r\\n                            String ws_terminationReason = \\\"\\\";\\r\\n                            String ws_trActivationDate = \\\"\\\";\\r\\n                            String ws_trDeactivationDate = \\\"\\\";\\r\\n\\r\\n                            SubscriptionRenewal subscriptionRenewal = subscription.getSubscriptionRenewal();\\r\\n                            if (subscriptionRenewal == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J0_Script : subscriptionRenewal is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n\\r\\n                            ws_trDeactivationDate = DateUtils.formatDateWithPattern(subscriptionRenewal.getAutoRenewDate(), DATE_PATTERN_BODY);\\r\\n\\r\\n                            String ws_template = \\\"\\\";\\r\\n\\r\\n                            if (subscriptionRenewal.isAutoRenew()) {\\r\\n                                ws_template = \\\"CONVER_OPENCELL_FPL\\\";\\r\\n                                ws_rterminationDate = \\\"\\\";\\r\\n                                ws_trDeactivationDate = \\\"\\\";\\r\\n                                ws_activationDate = \\\"\\\";\\r\\n                                Date endOfTrialDate = DateUtils.addDaysToDate(subscriptionDate, trialDuratien.intValue()) ;\\r\\n                                ws_tryBuyEndDate = DateUtils.formatDateWithPattern(endOfTrialDate, DATE_PATTERN_BODY);\\r\\n                            } else {\\r\\n                                ws_template = \\\"RESIL_OPENCELL_NCV\\\";\\r\\n                                if (StringUtils.isBlank(subscription.getTerminationDate())) {\\r\\n                                    Date endOfTrialDate = DateUtils.addDaysToDate(subscriptionDate, trialDuratien.intValue()) ;\\r\\n                                    ws_tryBuyEndDate = DateUtils.formatDateWithPattern(endOfTrialDate, DATE_PATTERN_BODY);\\r\\n                                } else {\\r\\n                                    Date termination = subscription.getTerminationDate();\\r\\n                                    ws_tryBuyEndDate = DateUtils.formatDateWithPattern(termination, DATE_PATTERN_BODY);\\r\\n\\r\\n                                }\\r\\n                                ws_subAmount = \\\"\\\";\\r\\n                                ws_withdrawalDate = \\\"\\\";\\r\\n                                ws_activationDate = \\\"\\\";\\r\\n                                ws_rterminationDate = ws_tryBuyEndDate;\\r\\n                                ws_engagmentEndDate = \\\"\\\";\\r\\n                            }\\r\\n\\r\\n                            String soapEnvBody =\\r\\n\\r\\n                                    \\\"<urn:Submit><urn:sessiontoken></urn:sessiontoken><urn:elemCtx><ctx \\\" + \\\" address=\\\\\\\"\\\" + ws_address + \\\"\\\\\\\"\\\" + \\\" culture=\\\\\\\"\\\" + ws_culture + \\\"\\\\\\\"\\\"\\r\\n                                            + \\\" sendByMail=\\\\\\\"\\\" + ws_sendByMail + \\\"\\\\\\\"\\\" + \\\" sendBySMS=\\\\\\\"\\\" + ws_sendBySMS + \\\"\\\\\\\"\\\" + \\\" cellphone=\\\\\\\"\\\" + ws_cellphone + \\\"\\\\\\\"\\\"\\r\\n                                            + \\\" expirationDate=\\\\\\\"\\\" + ws_expirationDate + \\\"\\\\\\\"\\\" + \\\" originalDate=\\\\\\\"\\\" + ws_originalDate + \\\"\\\\\\\"\\\" + \\\" rcpId=\\\\\\\"\\\" + ws_rcpId + \\\"\\\\\\\"\\\"\\r\\n                                            + \\\" template=\\\\\\\"\\\" + ws_template + \\\"\\\\\\\"\\\" + \\\" xmlns=\\\\\\\"\\\\\\\">\\\" + \\\"<CUSTOMER> \\\" + \\\"<Enseigne>\\\" + ws_enseigne + \\\"</Enseigne>\\\" + \\\"<Gender>\\\" + ws_gender\\r\\n                                            + \\\"</Gender>\\\" + \\\"<FirstName>\\\" + ws_firstName + \\\"</FirstName>\\\" + \\\"<LastName>\\\" + ws_lastName + \\\"</LastName>\\\" + \\\"<Email>\\\" + ws_email\\r\\n                                            + \\\"</Email>\\\" + \\\"<SendBySMS>\\\" + ws_sendBySMS + \\\"</SendBySMS>\\\" + \\\"<sendByMail>\\\" + ws_sendByMail + \\\"</sendByMail>\\\" + \\\"<ContractNumber>\\\"\\r\\n                                            + ws_contractNumber + \\\"</ContractNumber>\\\" + \\\"<offerLabel>\\\" + ws_offerLabel + \\\"</offerLabel>\\\" + \\\"<ContractStatus>\\\" + ws_contractStatus\\r\\n                                            + \\\"</ContractStatus>\\\" + \\\"<CardNumber>\\\" + ws_cardNumber + \\\"</CardNumber>\\\" + \\\"<AdhNumber>\\\" + ws_adhNumber + \\\"</AdhNumber>\\\" + \\\"<SelfCareUrl>\\\"\\r\\n                                            + ws_urlSelfcare + \\\"</SelfCareUrl>\\\" + \\\"<SerenityUrl>\\\" + ws_serenityUrl + \\\"</SerenityUrl>\\\" + \\\"<EngagmentEndDate>\\\" + ws_engagmentEndDate\\r\\n                                            + \\\"</EngagmentEndDate>\\\" + \\\"<TryBuyEndDate>\\\" + ws_tryBuyEndDate + \\\"</TryBuyEndDate>\\\" + \\\"<SubAmount>\\\" + ws_subAmount + \\\"</SubAmount>\\\"\\r\\n                                            + \\\"</CUSTOMER> \\\" + \\\"<INVOICE> \\\" + \\\"<CBValidityDate>\\\" + ws_cbValidityDate + \\\"</CBValidityDate>\\\" + \\\"<PaymentMode>\\\" + ws_paymentMode\\r\\n                                            + \\\"</PaymentMode>\\\" + \\\"<RejectDate>\\\" + ws_rejectDate + \\\"</RejectDate>\\\" + \\\"<RejectedInvoiceNb>\\\" + ws_rejectedInvoiceNb\\r\\n                                            + \\\"</RejectedInvoiceNb>\\\" + \\\"<RejectedAmountTTC>\\\" + ws_rejectedAmountTTC + \\\"</RejectedAmountTTC>\\\" + \\\"<Reason>\\\" + ws_reason + \\\"</Reason>\\\"\\r\\n                                            + \\\"<AmountDrawn>\\\" + ws_amountDrawn + \\\"</AmountDrawn>\\\" + \\\"<WithdrawalDate>\\\" + ws_withdrawalDate + \\\"</WithdrawalDate>\\\"\\r\\n                                            + \\\"<OneTimeCBPaymentDate>\\\" + ws_oneTimeCBPaymentDate + \\\"</OneTimeCBPaymentDate>\\\" + \\\"<OneTimePaymentAmount>\\\" + ws_oneTimePaymentAmount\\r\\n                                            + \\\"</OneTimePaymentAmount>\\\" + \\\"<RefundDate>\\\" + ws_refundDate + \\\"</RefundDate>\\\" + \\\"<RefundAmount>\\\" + ws_refundAmount + \\\"</RefundAmount>\\\"\\r\\n                                            + \\\"<DiscountEntryDate>\\\" + ws_discountEntryDate + \\\"</DiscountEntryDate>\\\" + \\\"<DiscountAmount>\\\" + ws_discountAmount + \\\"</DiscountAmount>\\\"\\r\\n                                            + \\\"<TransacAutorisationNb>\\\" + ws_transacAutorisationNb + \\\"</TransacAutorisationNb>\\\" + \\\"<Rum>\\\" + ws_rum + \\\"</Rum>\\\" + \\\"<Ics>\\\" + ws_ics\\r\\n                                            + \\\"</Ics>\\\" + \\\"<LegalEntityName>\\\" + ws_legalEntityName + \\\"</LegalEntityName>\\\" + \\\"</INVOICE>\\\" + \\\"<TERMINATION>\\\" + \\\"<ActivationDate>\\\"\\r\\n                                            + ws_activationDate + \\\"</ActivationDate>\\\" + \\\"<TerminationDate>\\\" + ws_rterminationDate + \\\"</TerminationDate>\\\" + \\\"<TerminationReason>\\\"\\r\\n                                            + ws_terminationReason + \\\"</TerminationReason>\\\" + \\\"</TERMINATION>\\\" + \\\"<TACITRENEWAL>\\\" + \\\"<TrActivationDate>\\\" + ws_trActivationDate\\r\\n                                            + \\\"</TrActivationDate>\\\" + \\\"<TrDeactivationDate>\\\" + ws_trDeactivationDate + \\\"</TrDeactivationDate>\\\" + \\\"</TACITRENEWAL>\\\"\\r\\n                                            + \\\"</ctx></urn:elemCtx></urn:Submit>\\\";\\r\\n\\r\\n                            String response = callWebService(soapEnvBody);\\r\\n                            log.info(\\\"response = \\\" + response);\\r\\n                            log.info(\\\"soapEnvBody = \\\" + soapEnvBody);\\r\\n                        }\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n        }\\r\\n    }\\r\\n}\",\n    \"executionRoles\": [],\n    \"sourcingRoles\": []\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/scriptInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"scriptInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLife_J10_Script",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										},
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"org.meveo.service.script.NeolaneCustomerLife_J10_Script\",\n    \"description\": \"NeolaneCustomerLife_J10 Script\",\n    \"type\": \"JAVA\",\n    \"script\": \"package org.meveo.service.script;\\r\\n\\r\\nimport org.apache.http.client.methods.CloseableHttpResponse;\\r\\nimport org.apache.http.client.methods.HttpPost;\\r\\nimport org.apache.http.conn.ssl.NoopHostnameVerifier;\\r\\nimport org.apache.http.conn.ssl.SSLContextBuilder;\\r\\nimport org.apache.http.conn.ssl.TrustStrategy;\\r\\nimport org.apache.http.entity.StringEntity;\\r\\nimport org.apache.http.impl.client.CloseableHttpClient;\\r\\nimport org.apache.http.impl.client.HttpClients;\\r\\nimport org.meveo.admin.exception.BusinessException;\\r\\nimport org.meveo.commons.utils.StringUtils;\\r\\nimport org.meveo.model.ICustomFieldEntity;\\r\\nimport org.meveo.model.admin.Seller;\\r\\nimport org.meveo.model.billing.BillingAccount;\\r\\nimport org.meveo.model.billing.ServiceInstance;\\r\\nimport org.meveo.model.billing.Subscription;\\r\\nimport org.meveo.model.billing.SubscriptionRenewal;\\r\\nimport org.meveo.model.billing.UserAccount;\\r\\nimport org.meveo.model.catalog.OfferTemplate;\\r\\nimport org.meveo.model.crm.Customer;\\r\\nimport org.meveo.model.crm.Provider;\\r\\nimport org.meveo.model.payments.CustomerAccount;\\r\\nimport org.meveo.model.payments.DDPaymentMethod;\\r\\nimport org.meveo.model.payments.PaymentMethod;\\r\\nimport org.meveo.model.shared.ContactInformation;\\r\\nimport org.meveo.model.shared.DateUtils;\\r\\nimport org.meveo.model.shared.Name;\\r\\nimport org.meveo.model.shared.Title;\\r\\nimport org.meveo.service.billing.impl.ServiceInstanceService;\\r\\nimport org.meveo.service.crm.impl.CustomFieldInstanceService;\\r\\nimport org.meveo.service.crm.impl.ProviderService;\\r\\n\\r\\nimport java.io.IOException;\\r\\nimport java.security.cert.CertificateException;\\r\\nimport java.security.cert.X509Certificate;\\r\\nimport java.util.Calendar;\\r\\nimport java.util.Date;\\r\\nimport java.util.HashMap;\\r\\nimport java.util.List;\\r\\nimport java.util.Map;\\r\\n\\r\\n/**\\r\\n * Appel le web service Neolane\\r\\n *    Mail de pr\\u00E9venance de r\\u00E9siliation ou de renouvellement\\r\\n *    A J-10 avant la date de fin de l'essai\\r\\n *\\r\\n * @author Mounir Bahije\\r\\n */\\r\\npublic class NeolaneCustomerLife_J10_Script extends Script {\\r\\n\\r\\n    private CustomFieldInstanceService cfiService = (CustomFieldInstanceService) getServiceInterface(\\\"CustomFieldInstanceService\\\");\\r\\n    private ServiceInstanceService serviceInstanceService = (ServiceInstanceService) getServiceInterface(\\\"ServiceInstanceService\\\");\\r\\n    private ProviderService providerService = (ProviderService) getServiceInterface(ProviderService.class.getSimpleName());\\r\\n    private Provider appProvider = providerService.getProvider();\\r\\n\\r\\n    private static final String CULTURE = \\\"fr-FR\\\";\\r\\n    private static final String DATE_PATTERN = \\\"yyyy/MM/dd HH:mm:ss\\\";\\r\\n    private static final String DATE_PATTERN_BODY = \\\"dd/MM/yyyy\\\";\\r\\n\\r\\n    private static final String CF_FD_URL_WS_NCLS = \\\"CF_FD_URL_WS_NCLS\\\";\\r\\n    private static final String CF_FD_ACTION_URI_WS_NCLS = \\\"CF_FD_ACTION_URI_WS_NCLS\\\";\\r\\n    private static final String CF_FD_URL_SELFCARE_NCLS = \\\"CF_FD_URL_SELFCARE_NCLS\\\";\\r\\n    private static final String SUBSCRIPTION_CREATED = \\\"0\\\";\\r\\n    private static final String SUBSCRIPTION_ACTIVE = \\\"1\\\";\\r\\n    private static final String SUBSCRIPTION_SUSPENDED = \\\"2\\\";\\r\\n    private static final String SUBSCRIPTION_RESILIATED = \\\"3\\\";\\r\\n    private static final String SUBSCRIPTION_CANCELED = \\\"4\\\";\\r\\n    private static final String SUBSCRIPTION_CLOSED = \\\"5\\\";\\r\\n\\r\\n    private static final int BEFORE_TRY_END_DATE = -10;\\r\\n\\r\\n    @Override\\r\\n    public void execute(Map<String, Object> methodContext) throws BusinessException {\\r\\n\\r\\n\\r\\n        String searchField = \\\"%\\\" + \\\"REC_MAIN\\\";\\r\\n\\r\\n        String query = String.format(\\\"select  si  from ServiceInstance  si WHERE si.code like '%s'\\\", searchField);\\r\\n        Map<String, Object> params = new HashMap<>();\\r\\n        List<ServiceInstance> listServiceInstance = (List<ServiceInstance>) serviceInstanceService.executeSelectQuery(query.toString(), params);\\r\\n        methodContext.clear();\\r\\n        setWSData(listServiceInstance);\\r\\n\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Call Neolane WS\\r\\n     *\\r\\n     * @param soapEnvBody\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private String callWebService(String soapEnvBody) throws BusinessException {\\r\\n        String body =\\r\\n                \\\"<?xml version=\\\\\\\"1.0\\\\\\\" encoding=\\\\\\\"UTF-8\\\\\\\"?><soapenv:Envelope xmlns:soapenv=\\\\\\\"http://schemas.xmlsoap.org/soap/envelope/\\\\\\\" xmlns:urn=\\\\\\\"urn:nms:rtMsg\\\\\\\"><soapenv:Header/><soapenv:Body>\\\"\\r\\n                        + soapEnvBody + \\\"</soapenv:Body></soapenv:Envelope>\\\";\\r\\n        StringEntity stringEntity = new StringEntity(body, \\\"UTF-8\\\");\\r\\n\\r\\n        final String wsUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_WS_NCLS, true);\\r\\n        final String actionUri = (String) this.fetchCFConfigValue(appProvider, CF_FD_ACTION_URI_WS_NCLS, true);\\r\\n\\r\\n        // Request parameters and other properties.\\r\\n        HttpPost httpPost = new HttpPost(wsUrl);\\r\\n        httpPost.setEntity(stringEntity);\\r\\n        httpPost.setHeader(\\\"SOAPAction\\\", actionUri);\\r\\n\\r\\n        // Execute and get the response.\\r\\n        CloseableHttpClient httpClient = getCloseableHttpClient();\\r\\n        CloseableHttpResponse response = null;\\r\\n        try {\\r\\n            log.info(\\\"we want to sent to this address = \\\" + actionUri);\\r\\n            log.info(\\\"This body = \\\" + body);\\r\\n            response = httpClient.execute(httpPost);\\r\\n            boolean responseOk = false;\\r\\n            if (response != null) {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    if (response.getStatusLine().getStatusCode() == 200) {\\r\\n                        responseOk = true;\\r\\n                        log.info(\\\"In NeolaneCustomerLife_J10_Script : body sent and it's Ok\\\");\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n            if (responseOk) {\\r\\n                log.info(\\\"In NeolaneCustomerLife_J10_Script : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                return \\\"OK\\\";\\r\\n            } else {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    log.error(\\\"In NeolaneCustomerLife_J10_Script : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                } else {\\r\\n                    log.error(\\\"In NeolaneCustomerLife_J10_Script : response.getStatusLine() = null \\\");\\r\\n                }\\r\\n                return \\\"KO\\\";\\r\\n            }\\r\\n        } catch (IOException e) {\\r\\n            log.error(\\\"Exception in NeolaneCustomerLife_J10_Script :\\\", e);\\r\\n        }\\r\\n        return \\\"KO\\\";\\r\\n    }\\r\\n\\r\\n\\r\\n    /**\\r\\n     * fetch CF Config Value\\r\\n     *\\r\\n     * @param entity\\r\\n     * @param cfKey\\r\\n     * @param isMandatory\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private Object fetchCFConfigValue(ICustomFieldEntity entity, String cfKey, boolean isMandatory) throws BusinessException {\\r\\n        Object cfValue = cfiService.getCFValue(entity, cfKey);\\r\\n        if (isMandatory && (cfValue == null || (cfValue instanceof String && org.apache.commons.lang3.StringUtils.isEmpty(String.valueOf(cfValue))))) {\\r\\n            throw new BusinessException(\\\" Missing mandatory config [\\\" + cfKey + \\\"]\\\");\\r\\n        }\\r\\n        return cfValue;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * get CloseableHttpClient\\r\\n     *\\r\\n     * @return trusted httpClient\\r\\n     */\\r\\n    public  CloseableHttpClient getCloseableHttpClient()\\r\\n    {\\r\\n        CloseableHttpClient httpClient = null;\\r\\n        try {\\r\\n            httpClient = HttpClients.custom().\\r\\n                    setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).\\r\\n                    setSSLContext(new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy()\\r\\n                    {\\r\\n                        public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException\\r\\n                        {\\r\\n                            return true;\\r\\n                        }\\r\\n                    }).build()).build();\\r\\n        } catch (Exception e) {\\r\\n            log.error(\\\"KeyManagementException in creating http client instance\\\", e);\\r\\n        }\\r\\n        return httpClient;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Set Data for Neolane WS\\r\\n     *\\r\\n     * @param listServiceInstance the list of serviceInstance\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private void setWSData(List<ServiceInstance> listServiceInstance) throws BusinessException {\\r\\n\\r\\n        Date nowDate = new Date();\\r\\n\\r\\n        if (listServiceInstance != null) {\\r\\n            for (ServiceInstance serviceInstance : listServiceInstance) {\\r\\n\\r\\n                Subscription subscription = serviceInstance.getSubscription();\\r\\n\\r\\n                List<ServiceInstance> listServiceSearchLicence = subscription.getServiceInstances();\\r\\n                String offerType = \\\"FNAC+\\\";\\r\\n                for (ServiceInstance serviceSearchLicence : listServiceSearchLicence) {\\r\\n                    if (serviceSearchLicence == null) {\\r\\n                        log.error(\\\"NeolaneCustomerLife_J10_Script : serviceSearchLicence is null / subscription code = \\\" + subscription.getCode());\\r\\n                        continue;\\r\\n                    }\\r\\n                    if (\\\"SE_FD_LICENCE\\\".equalsIgnoreCase(serviceSearchLicence.getCode())) {\\r\\n                        offerType = \\\"SERENITE\\\";\\r\\n                    }\\r\\n                }\\r\\n\\r\\n                String ws_tryBuyEndDate = \\\"\\\";\\r\\n                if (\\\"FNAC+\\\".equals(offerType)) {\\r\\n                    Long trialDuratien = (Long) cfiService.getInheritedCFValue(subscription, \\\"CF_OF_SU_FD_TRY_DURATION\\\");\\r\\n                    if (trialDuratien == null) {\\r\\n                        trialDuratien = 0L;\\r\\n                    }\\r\\n                    Date subscriptionDate = subscription.getSubscriptionDate();\\r\\n                    if (subscriptionDate != null) {\\r\\n\\r\\n                        Date endOfTrialDateJourJ = DateUtils.addDaysToDate(subscriptionDate, trialDuratien.intValue() + BEFORE_TRY_END_DATE) ;\\r\\n                        Date endOfTrialDateJourPlusUn = DateUtils.addDaysToDate(subscriptionDate, trialDuratien.intValue() + BEFORE_TRY_END_DATE + 1) ;\\r\\n\\r\\n                        if ((endOfTrialDateJourJ.compareTo(nowDate) <= 0) && (endOfTrialDateJourPlusUn.compareTo(nowDate) > 0)) {\\r\\n\\r\\n\\r\\n\\r\\n                            Date endOfTrialDate = DateUtils.addDaysToDate(subscriptionDate, trialDuratien.intValue()) ;\\r\\n                            ws_tryBuyEndDate = DateUtils.formatDateWithPattern(endOfTrialDate, DATE_PATTERN_BODY);\\r\\n\\r\\n\\r\\n                            UserAccount userAccount = subscription.getUserAccount();\\r\\n                            if (userAccount == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J10_Script : userAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n                            BillingAccount billingAccount = userAccount.getBillingAccount();\\r\\n                            if (billingAccount == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J10_Script : billingAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n                            CustomerAccount customerAccount = billingAccount.getCustomerAccount();\\r\\n                            if (customerAccount == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J10_Script : customerAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n\\r\\n                            ContactInformation contactInformation = userAccount.getContactInformation();\\r\\n                            if (contactInformation == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J10_Script : contactInformation is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n\\r\\n                            String ws_email = contactInformation.getEmail();\\r\\n                            ws_email = (ws_email == null) ? \\\"\\\" : ws_email;\\r\\n\\r\\n                            String ws_address = ws_email;\\r\\n\\r\\n                            String ws_culture = CULTURE;\\r\\n\\r\\n                            String ws_cellphone = \\\"\\\";\\r\\n\\r\\n                            Calendar expirationDateCalendar = Calendar.getInstance();\\r\\n                            expirationDateCalendar.setTime(nowDate);\\r\\n                            expirationDateCalendar.add(Calendar.HOUR_OF_DAY, 12);\\r\\n                            String ws_expirationDate = DateUtils.formatDateWithPattern(expirationDateCalendar.getTime(), DATE_PATTERN);\\r\\n\\r\\n                            String ws_originalDate = DateUtils.formatDateWithPattern(nowDate, DATE_PATTERN);\\r\\n\\r\\n\\r\\n                            String ws_rcpId = \\\"-2\\\";\\r\\n\\r\\n                            String ws_enseigne = \\\"\\\";\\r\\n                            boolean enseigneTest = false;\\r\\n                            Seller seller = subscription.getSeller();\\r\\n                            Seller seller_N_1 = null;\\r\\n                            Seller seller_N_2 = null;\\r\\n                            if (seller != null) {\\r\\n                                seller_N_1 = seller.getSeller();\\r\\n                                if (seller_N_1 != null) {\\r\\n                                    seller_N_2 = seller_N_1.getSeller();\\r\\n                                    if (seller_N_2 != null) {\\r\\n                                        if (seller_N_2.getCode() != null) {\\r\\n                                            enseigneTest = true;\\r\\n                                        }\\r\\n                                    }\\r\\n                                }\\r\\n                            }\\r\\n                            if (enseigneTest) {\\r\\n                                ws_enseigne = seller_N_2.getCode();\\r\\n                            } else {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J10_Script : enseigne is undefined / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n\\r\\n                            boolean nameOk = false;\\r\\n                            Customer customer = null;\\r\\n                            Name name = null;\\r\\n                            Title title = null;\\r\\n                            if (customerAccount != null) {\\r\\n                                customer = customerAccount.getCustomer();\\r\\n                                if (customer != null) {\\r\\n                                    name = customer.getName();\\r\\n                                    if (name != null) {\\r\\n                                        nameOk = true;\\r\\n                                    }\\r\\n                                }\\r\\n                            }\\r\\n\\r\\n                            if (nameOk == false) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J10_Script : problem with name / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n                            title = name.getTitle();\\r\\n                            String ws_gender = \\\"\\\";\\r\\n                            if (title != null && title.getCode() != null) {\\r\\n                                ws_gender = title.getCode();\\r\\n                            }\\r\\n\\r\\n                            String ws_firstName = (name.getFirstName() == null) ? \\\"\\\" : name.getFirstName();\\r\\n                            String ws_lastName = (name.getLastName() == null) ? \\\"\\\" : name.getLastName();\\r\\n\\r\\n                            String ws_sendBySMS = \\\"false\\\";\\r\\n\\r\\n                            String ws_sendByMail = \\\"true\\\";\\r\\n\\r\\n                            OfferTemplate offer = subscription.getOffer();\\r\\n                            if (offer == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J10_Script : offer is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n                            String ws_offerLabel = (offer.getName() == null) ? \\\"\\\" : offer.getName();\\r\\n\\r\\n                            String ws_contractStatus = \\\"\\\";\\r\\n                            if (subscription.getStatus() == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J10_Script : subscription.status is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n                            switch (subscription.getStatus()) {\\r\\n                                case CREATED:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_CREATED;\\r\\n                                    break;\\r\\n                                case ACTIVE:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_ACTIVE;\\r\\n                                    break;\\r\\n                                case CANCELED:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_CANCELED;\\r\\n                                    break;\\r\\n                                case RESILIATED:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_RESILIATED;\\r\\n                                    break;\\r\\n                                case CLOSED:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_CLOSED;\\r\\n                                    break;\\r\\n                                case SUSPENDED:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_SUSPENDED;\\r\\n                                    break;\\r\\n                                default:\\r\\n                                    ws_contractStatus = \\\"\\\";\\r\\n                            }\\r\\n\\r\\n                            String ws_contractNumber = subscription.getCode();\\r\\n\\r\\n                            String ws_cardNumber = \\\"\\\";\\r\\n                            String ws_serenityUrl = \\\"\\\";\\r\\n\\r\\n                            if (StringUtils.isBlank(cfiService.getInheritedCFValue(subscription, \\\"CF_SU_FD_CARD_NUMBER\\\"))) {\\r\\n                                ws_cardNumber = \\\"\\\";\\r\\n                            } else {\\r\\n                                ws_cardNumber = (String) cfiService.getInheritedCFValue(subscription, \\\"CF_SU_FD_CARD_NUMBER\\\");\\r\\n                            }\\r\\n\\r\\n                            String ws_adhNumber = \\\"\\\";\\r\\n\\r\\n                            final String selfCareUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_SELFCARE_NCLS, true);\\r\\n                            String ws_urlSelfcare = \\\"\\\";\\r\\n                            if (!StringUtils.isBlank(selfCareUrl)) {\\r\\n                                ws_urlSelfcare = selfCareUrl;\\r\\n                            }\\r\\n\\r\\n                            String ws_engagmentEndDate = DateUtils.formatDateWithPattern(subscription.getEndAgreementDate(), DATE_PATTERN_BODY);\\r\\n\\r\\n                            if (subscription.getOffer() == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J10_Script : subscription.getOffer() is null / subscription code = \\\" + subscription.getCode());\\r\\n                                throw new BusinessException(\\\"NeolaneCustomerLife_J10_Script : subscription.getOffer() is null\\\");\\r\\n                            }\\r\\n                            String ws_subAmount = \\\"\\\";\\r\\n                            if (cfiService.getInheritedCFValue(subscription.getOffer(), \\\"CF_OF_FD_PRICE\\\") != null) {\\r\\n                                ws_subAmount = String.valueOf(cfiService.getInheritedCFValue(subscription.getOffer(), \\\"CF_OF_FD_PRICE\\\"));\\r\\n                            }\\r\\n\\r\\n                            String ws_cbValidityDate = \\\"\\\";\\r\\n                            String ws_paymentMode = \\\"\\\";\\r\\n                            String ws_rejectDate = \\\"\\\";\\r\\n                            String ws_rejectedInvoiceNb = \\\"\\\";\\r\\n                            String ws_rejectedAmountTTC = \\\"\\\";\\r\\n                            String ws_reason = \\\"\\\";\\r\\n                            String ws_amountDrawn = \\\"\\\";\\r\\n                            String ws_withdrawalDate = \\\"\\\";\\r\\n                            String ws_oneTimeCBPaymentDate = \\\"\\\";\\r\\n                            String ws_oneTimePaymentAmount = \\\"\\\";\\r\\n                            String ws_refundDate = \\\"\\\";\\r\\n                            String ws_refundAmount = \\\"\\\";\\r\\n                            String ws_discountEntryDate = \\\"\\\";\\r\\n                            String ws_discountAmount = \\\"\\\";\\r\\n                            String ws_transacAutorisationNb = \\\"\\\";\\r\\n                            String ws_rum = \\\"\\\";\\r\\n                            String ws_ics = \\\"\\\";\\r\\n                            String ws_legalEntityName = \\\"\\\";\\r\\n\\r\\n                            PaymentMethod preferredMethod = null;\\r\\n                            preferredMethod = customerAccount.getPreferredPaymentMethod();\\r\\n\\r\\n                            if (preferredMethod instanceof DDPaymentMethod) {\\r\\n                                ws_rum = ((DDPaymentMethod) preferredMethod).getMandateIdentification();\\r\\n                            }\\r\\n\\r\\n                            Seller entiteJuridique = seller_N_1;\\r\\n                            ws_legalEntityName = entiteJuridique.getDescription();\\r\\n\\r\\n                            ws_ics = (String) cfiService.getInheritedCFValue(entiteJuridique, \\\"CF_S_FD_ICS\\\");\\r\\n\\r\\n                            Date nextInvoiceDate = billingAccount.getNextInvoiceDate();\\r\\n                            ws_withdrawalDate = DateUtils.formatDateWithPattern(nextInvoiceDate, DATE_PATTERN_BODY);\\r\\n\\r\\n                            String ws_activationDate = DateUtils.formatDateWithPattern(serviceInstance.getSubscriptionDate(),DATE_PATTERN_BODY);\\r\\n\\r\\n                            String ws_rterminationDate = \\\"\\\";\\r\\n                            String ws_terminationReason = \\\"\\\";\\r\\n                            String ws_trActivationDate = \\\"\\\";\\r\\n\\r\\n                            SubscriptionRenewal subscriptionRenewal = subscription.getSubscriptionRenewal();\\r\\n                            if (subscriptionRenewal == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_J10_Script : subscriptionRenewal is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n\\r\\n                            String ws_trDeactivationDate = DateUtils.formatDateWithPattern(subscriptionRenewal.getAutoRenewDate(), DATE_PATTERN_BODY);\\r\\n\\r\\n                            String ws_template = \\\"\\\";\\r\\n                            if (subscriptionRenewal.isAutoRenew()) {\\r\\n                                ws_template = \\\"RENOU_OPENCELL_PRV\\\";\\r\\n                                ws_trDeactivationDate = \\\"\\\";\\r\\n                            } else {\\r\\n                                ws_template = \\\"RESIL_OPENCELL_NTR\\\";\\r\\n                                ws_tryBuyEndDate = \\\"\\\";\\r\\n                                ws_subAmount = \\\"\\\";\\r\\n                                ws_withdrawalDate = \\\"\\\";\\r\\n                                ws_activationDate = \\\"\\\";\\r\\n                                ws_rterminationDate = ws_tryBuyEndDate;\\r\\n                            }\\r\\n\\r\\n                            String soapEnvBody =\\r\\n\\r\\n                                    \\\"<urn:Submit><urn:sessiontoken></urn:sessiontoken><urn:elemCtx><ctx \\\" + \\\" address=\\\\\\\"\\\" + ws_address + \\\"\\\\\\\"\\\" + \\\" culture=\\\\\\\"\\\" + ws_culture + \\\"\\\\\\\"\\\"\\r\\n                                            + \\\" sendByMail=\\\\\\\"\\\" + ws_sendByMail + \\\"\\\\\\\"\\\" + \\\" sendBySMS=\\\\\\\"\\\" + ws_sendBySMS + \\\"\\\\\\\"\\\" + \\\" cellphone=\\\\\\\"\\\" + ws_cellphone + \\\"\\\\\\\"\\\"\\r\\n                                            + \\\" expirationDate=\\\\\\\"\\\" + ws_expirationDate + \\\"\\\\\\\"\\\" + \\\" originalDate=\\\\\\\"\\\" + ws_originalDate + \\\"\\\\\\\"\\\" + \\\" rcpId=\\\\\\\"\\\" + ws_rcpId + \\\"\\\\\\\"\\\"\\r\\n                                            + \\\" template=\\\\\\\"\\\" + ws_template + \\\"\\\\\\\"\\\" + \\\" xmlns=\\\\\\\"\\\\\\\">\\\" + \\\"<CUSTOMER> \\\" + \\\"<Enseigne>\\\" + ws_enseigne + \\\"</Enseigne>\\\" + \\\"<Gender>\\\" + ws_gender\\r\\n                                            + \\\"</Gender>\\\" + \\\"<FirstName>\\\" + ws_firstName + \\\"</FirstName>\\\" + \\\"<LastName>\\\" + ws_lastName + \\\"</LastName>\\\" + \\\"<Email>\\\" + ws_email\\r\\n                                            + \\\"</Email>\\\" + \\\"<SendBySMS>\\\" + ws_sendBySMS + \\\"</SendBySMS>\\\" + \\\"<sendByMail>\\\" + ws_sendByMail + \\\"</sendByMail>\\\" + \\\"<ContractNumber>\\\"\\r\\n                                            + ws_contractNumber + \\\"</ContractNumber>\\\" + \\\"<offerLabel>\\\" + ws_offerLabel + \\\"</offerLabel>\\\" + \\\"<ContractStatus>\\\" + ws_contractStatus\\r\\n                                            + \\\"</ContractStatus>\\\" + \\\"<CardNumber>\\\" + ws_cardNumber + \\\"</CardNumber>\\\" + \\\"<AdhNumber>\\\" + ws_adhNumber + \\\"</AdhNumber>\\\" + \\\"<SelfCareUrl>\\\"\\r\\n                                            + ws_urlSelfcare + \\\"</SelfCareUrl>\\\" + \\\"<SerenityUrl>\\\" + ws_serenityUrl + \\\"</SerenityUrl>\\\" + \\\"<EngagmentEndDate>\\\" + ws_engagmentEndDate\\r\\n                                            + \\\"</EngagmentEndDate>\\\" + \\\"<TryBuyEndDate>\\\" + ws_tryBuyEndDate + \\\"</TryBuyEndDate>\\\" + \\\"<SubAmount>\\\" + ws_subAmount + \\\"</SubAmount>\\\"\\r\\n                                            + \\\"</CUSTOMER> \\\" + \\\"<INVOICE> \\\" + \\\"<CBValidityDate>\\\" + ws_cbValidityDate + \\\"</CBValidityDate>\\\" + \\\"<PaymentMode>\\\" + ws_paymentMode\\r\\n                                            + \\\"</PaymentMode>\\\" + \\\"<RejectDate>\\\" + ws_rejectDate + \\\"</RejectDate>\\\" + \\\"<RejectedInvoiceNb>\\\" + ws_rejectedInvoiceNb\\r\\n                                            + \\\"</RejectedInvoiceNb>\\\" + \\\"<RejectedAmountTTC>\\\" + ws_rejectedAmountTTC + \\\"</RejectedAmountTTC>\\\" + \\\"<Reason>\\\" + ws_reason + \\\"</Reason>\\\"\\r\\n                                            + \\\"<AmountDrawn>\\\" + ws_amountDrawn + \\\"</AmountDrawn>\\\" + \\\"<WithdrawalDate>\\\" + ws_withdrawalDate + \\\"</WithdrawalDate>\\\"\\r\\n                                            + \\\"<OneTimeCBPaymentDate>\\\" + ws_oneTimeCBPaymentDate + \\\"</OneTimeCBPaymentDate>\\\" + \\\"<OneTimePaymentAmount>\\\" + ws_oneTimePaymentAmount\\r\\n                                            + \\\"</OneTimePaymentAmount>\\\" + \\\"<RefundDate>\\\" + ws_refundDate + \\\"</RefundDate>\\\" + \\\"<RefundAmount>\\\" + ws_refundAmount + \\\"</RefundAmount>\\\"\\r\\n                                            + \\\"<DiscountEntryDate>\\\" + ws_discountEntryDate + \\\"</DiscountEntryDate>\\\" + \\\"<DiscountAmount>\\\" + ws_discountAmount + \\\"</DiscountAmount>\\\"\\r\\n                                            + \\\"<TransacAutorisationNb>\\\" + ws_transacAutorisationNb + \\\"</TransacAutorisationNb>\\\" + \\\"<Rum>\\\" + ws_rum + \\\"</Rum>\\\" + \\\"<Ics>\\\" + ws_ics\\r\\n                                            + \\\"</Ics>\\\" + \\\"<LegalEntityName>\\\" + ws_legalEntityName + \\\"</LegalEntityName>\\\" + \\\"</INVOICE>\\\" + \\\"<TERMINATION>\\\" + \\\"<ActivationDate>\\\"\\r\\n                                            + ws_activationDate + \\\"</ActivationDate>\\\" + \\\"<TerminationDate>\\\" + ws_rterminationDate + \\\"</TerminationDate>\\\" + \\\"<TerminationReason>\\\"\\r\\n                                            + ws_terminationReason + \\\"</TerminationReason>\\\" + \\\"</TERMINATION>\\\" + \\\"<TACITRENEWAL>\\\" + \\\"<TrActivationDate>\\\" + ws_trActivationDate\\r\\n                                            + \\\"</TrActivationDate>\\\" + \\\"<TrDeactivationDate>\\\" + ws_trDeactivationDate + \\\"</TrDeactivationDate>\\\" + \\\"</TACITRENEWAL>\\\"\\r\\n                                            + \\\"</ctx></urn:elemCtx></urn:Submit>\\\";\\r\\n\\r\\n\\r\\n                            String response = callWebService(soapEnvBody);\\r\\n                            log.info(\\\"response = \\\" + response);\\r\\n                            log.info(\\\"soapEnvBody = \\\" + soapEnvBody);\\r\\n                        }\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n        }\\r\\n    }\\r\\n}\",\n    \"executionRoles\": [],\n    \"sourcingRoles\": []\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/scriptInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"scriptInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLife_CB_Script",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										},
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"org.meveo.service.script.NeolaneCustomerLife_CB_Script\",\n    \"description\": \"NeolaneCustomerLife_CB Script\",\n    \"type\": \"JAVA\",\n    \"script\": \"package org.meveo.service.script;\\r\\n\\r\\nimport org.apache.http.client.methods.CloseableHttpResponse;\\r\\nimport org.apache.http.client.methods.HttpPost;\\r\\nimport org.apache.http.conn.ssl.NoopHostnameVerifier;\\r\\nimport org.apache.http.conn.ssl.SSLContextBuilder;\\r\\nimport org.apache.http.conn.ssl.TrustStrategy;\\r\\nimport org.apache.http.entity.StringEntity;\\r\\nimport org.apache.http.impl.client.CloseableHttpClient;\\r\\nimport org.apache.http.impl.client.HttpClients;\\r\\nimport org.meveo.admin.exception.BusinessException;\\r\\nimport org.meveo.commons.utils.StringUtils;\\r\\nimport org.meveo.model.ICustomFieldEntity;\\r\\nimport org.meveo.model.admin.Seller;\\r\\nimport org.meveo.model.billing.BillingAccount;\\r\\nimport org.meveo.model.billing.ServiceInstance;\\r\\nimport org.meveo.model.billing.Subscription;\\r\\nimport org.meveo.model.billing.UserAccount;\\r\\nimport org.meveo.model.catalog.OfferTemplate;\\r\\nimport org.meveo.model.crm.Customer;\\r\\nimport org.meveo.model.crm.Provider;\\r\\nimport org.meveo.model.payments.CardPaymentMethod;\\r\\nimport org.meveo.model.payments.CustomerAccount;\\r\\nimport org.meveo.model.payments.PaymentMethod;\\r\\nimport org.meveo.model.payments.PaymentMethodEnum;\\r\\nimport org.meveo.model.shared.ContactInformation;\\r\\nimport org.meveo.model.shared.DateUtils;\\r\\nimport org.meveo.model.shared.Name;\\r\\nimport org.meveo.model.shared.Title;\\r\\nimport org.meveo.service.billing.impl.ServiceInstanceService;\\r\\nimport org.meveo.service.crm.impl.CustomFieldInstanceService;\\r\\nimport org.meveo.service.crm.impl.ProviderService;\\r\\n\\r\\nimport java.io.IOException;\\r\\nimport java.security.cert.CertificateException;\\r\\nimport java.security.cert.X509Certificate;\\r\\nimport java.text.SimpleDateFormat;\\r\\nimport java.util.Calendar;\\r\\nimport java.util.Date;\\r\\nimport java.util.HashMap;\\r\\nimport java.util.List;\\r\\nimport java.util.Map;\\r\\n\\r\\n/**\\r\\n * Appel le web service Neolane\\r\\n *    Mail de pr\\u00E9venance expiration CB \\u00E0 j-30\\r\\n *\\r\\n * @author Mounir Bahije\\r\\n */\\r\\npublic class NeolaneCustomerLife_CB_Script extends Script {\\r\\n\\r\\n    private CustomFieldInstanceService cfiService = (CustomFieldInstanceService) getServiceInterface(\\\"CustomFieldInstanceService\\\");\\r\\n    private ServiceInstanceService serviceInstanceService = (ServiceInstanceService) getServiceInterface(\\\"ServiceInstanceService\\\");\\r\\n    private ProviderService providerService = (ProviderService) getServiceInterface(ProviderService.class.getSimpleName());\\r\\n    private Provider appProvider = providerService.getProvider();\\r\\n\\r\\n    private static final String CULTURE = \\\"fr-FR\\\";\\r\\n    private static final String DATE_PATTERN = \\\"yyyy/MM/dd HH:mm:ss\\\";\\r\\n    private static final String DATE_PATTERN_BODY = \\\"dd/MM/yyyy\\\";\\r\\n    private static final String DATE_PATTERN_CB = \\\"MM/yy\\\";\\r\\n\\r\\n    private static final String CF_FD_URL_WS_NCLS = \\\"CF_FD_URL_WS_NCLS\\\";\\r\\n    private static final String CF_FD_ACTION_URI_WS_NCLS = \\\"CF_FD_ACTION_URI_WS_NCLS\\\";\\r\\n    private static final String CF_FD_URL_SELFCARE_NCLS = \\\"CF_FD_URL_SELFCARE_NCLS\\\";\\r\\n\\r\\n    private static final String SUBSCRIPTION_CREATED = \\\"0\\\";\\r\\n    private static final String SUBSCRIPTION_ACTIVE = \\\"1\\\";\\r\\n    private static final String SUBSCRIPTION_SUSPENDED = \\\"2\\\";\\r\\n    private static final String SUBSCRIPTION_RESILIATED = \\\"3\\\";\\r\\n    private static final String SUBSCRIPTION_CANCELED = \\\"4\\\";\\r\\n    private static final String SUBSCRIPTION_CLOSED = \\\"5\\\";\\r\\n\\r\\n    private static final String PAYMENT_MODE_CB = \\\"CB\\\";\\r\\n\\r\\n    private static final int BEFORE_CB_EXPIRATION_DATE_30 = 30;\\r\\n\\r\\n    @Override\\r\\n    public void execute(Map<String, Object> methodContext) throws BusinessException {\\r\\n\\r\\n        String searchField = \\\"%\\\" + \\\"REC_MAIN\\\";\\r\\n        String query = String.format(\\\"select  si  from ServiceInstance  si WHERE si.code like '%s'\\\", searchField);\\r\\n        Map<String, Object> params = new HashMap<>();\\r\\n        List<ServiceInstance> listServiceInstance = (List<ServiceInstance>) serviceInstanceService.executeSelectQuery(query.toString(), params);\\r\\n        methodContext.clear();\\r\\n        setWSData(listServiceInstance);\\r\\n\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * fetch CF Config Value\\r\\n     *\\r\\n     * @param entity\\r\\n     * @param cfKey\\r\\n     * @param isMandatory\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private Object fetchCFConfigValue(ICustomFieldEntity entity, String cfKey, boolean isMandatory) throws BusinessException {\\r\\n        Object cfValue = cfiService.getCFValue(entity, cfKey);\\r\\n        if (isMandatory && (cfValue == null || (cfValue instanceof String && org.apache.commons.lang3.StringUtils.isEmpty(String.valueOf(cfValue))))) {\\r\\n            throw new BusinessException(\\\" Missing mandatory config [\\\" + cfKey + \\\"]\\\");\\r\\n        }\\r\\n        return cfValue;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Call Neolane WS\\r\\n     *\\r\\n     * @param soapEnvBody\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private String callWebService(String soapEnvBody) throws BusinessException {\\r\\n\\r\\n        String body =\\r\\n                \\\"<?xml version=\\\\\\\"1.0\\\\\\\" encoding=\\\\\\\"UTF-8\\\\\\\"?><soapenv:Envelope xmlns:soapenv=\\\\\\\"http://schemas.xmlsoap.org/soap/envelope/\\\\\\\" \\\" +\\r\\n                        \\\"xmlns:urn=\\\\\\\"urn:nms:rtMsg\\\\\\\"><soapenv:Header/><soapenv:Body>\\\"\\r\\n                        + soapEnvBody + \\\"</soapenv:Body></soapenv:Envelope>\\\";\\r\\n\\r\\n        StringEntity stringEntity = new StringEntity(body, \\\"UTF-8\\\");\\r\\n\\r\\n        final String wsUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_WS_NCLS, true);\\r\\n        final String actionUri = (String) this.fetchCFConfigValue(appProvider, CF_FD_ACTION_URI_WS_NCLS, true);\\r\\n\\r\\n        // Request parameters and other properties.\\r\\n        HttpPost httpPost = new HttpPost(wsUrl);\\r\\n        httpPost.setEntity(stringEntity);\\r\\n        httpPost.setHeader(\\\"SOAPAction\\\", actionUri);\\r\\n\\r\\n        // Execute and get the response.\\r\\n        CloseableHttpClient httpClient = getCloseableHttpClient();\\r\\n        CloseableHttpResponse response = null;\\r\\n        try {\\r\\n\\r\\n            log.info(\\\"we want to sent to this address = \\\" + actionUri);\\r\\n            log.info(\\\"This body = \\\" + body);\\r\\n\\r\\n            response = httpClient.execute(httpPost);\\r\\n            boolean responseOk = false;\\r\\n            if (response != null) {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    if (response.getStatusLine().getStatusCode() == 200) {\\r\\n                        responseOk = true;\\r\\n                        log.info(\\\"In NeolaneCustomerLife_CB_Script : body sent and it's Ok\\\");\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n            if (responseOk) {\\r\\n                log.info(\\\"In NeolaneCustomerLife_CB_Script : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                return \\\"OK\\\";\\r\\n            } else {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    log.error(\\\"In NeolaneCustomerLife_CB_Script : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                } else {\\r\\n                    log.error(\\\"In NeolaneCustomerLife_CB_Script : response.getStatusLine() = null \\\");\\r\\n                }\\r\\n                return \\\"KO\\\";\\r\\n            }\\r\\n\\r\\n        } catch (IOException e) {\\r\\n            log.error(\\\"Exception in EndSubscriptionScript :\\\", e);\\r\\n        }\\r\\n        return \\\"KO\\\";\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * get CloseableHttpClient\\r\\n     *\\r\\n     * @return trusted httpClient\\r\\n     */\\r\\n    public  CloseableHttpClient getCloseableHttpClient()\\r\\n    {\\r\\n        CloseableHttpClient httpClient = null;\\r\\n        try {\\r\\n            httpClient = HttpClients.custom().\\r\\n                    setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).\\r\\n                    setSSLContext(new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy()\\r\\n                    {\\r\\n                        public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException\\r\\n                        {\\r\\n                            return true;\\r\\n                        }\\r\\n                    }).build()).build();\\r\\n        } catch (Exception e) {\\r\\n            log.error(\\\"KeyManagementException in creating http client instance\\\", e);\\r\\n        }\\r\\n        return httpClient;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Set Data for Neolane WS\\r\\n     *\\r\\n     * @param listServiceInstance the list of serviceInstance\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private void setWSData(List<ServiceInstance> listServiceInstance) throws BusinessException {\\r\\n\\r\\n        Date nowDate = new Date();\\r\\n\\r\\n        if (listServiceInstance != null) {\\r\\n            for (ServiceInstance serviceInstance : listServiceInstance) {\\r\\n                Subscription subscription = serviceInstance.getSubscription();\\r\\n                if (subscription == null) {\\r\\n                    log.error(\\\"NeolaneCustomerLife_CB_Script : subscription is null\\\");\\r\\n                    continue;\\r\\n                }\\r\\n                UserAccount userAccount = subscription.getUserAccount();\\r\\n                if (userAccount == null) {\\r\\n                    log.error(\\\"NeolaneCustomerLife_CB_Script : userAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                    continue;\\r\\n                }\\r\\n                BillingAccount billingAccount = userAccount.getBillingAccount();\\r\\n                if (billingAccount == null) {\\r\\n                    log.error(\\\"NeolaneCustomerLife_CB_Script : billingAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                    continue;\\r\\n                }\\r\\n                CustomerAccount customerAccount = billingAccount.getCustomerAccount();\\r\\n                if (customerAccount == null) {\\r\\n                    log.error(\\\"NeolaneCustomerLife_CB_Script : customerAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                    continue;\\r\\n                }\\r\\n                PaymentMethod paymentMethod = customerAccount.getPreferredPaymentMethod();\\r\\n                if (PaymentMethodEnum.CARD.equals(paymentMethod.getPaymentType())) {\\r\\n\\r\\n                    String cbExpirationDateStr = ((CardPaymentMethod) paymentMethod).getExpirationMonthAndYear();\\r\\n                    Date cbExpirationDate = DateUtils.parseDateWithPattern(cbExpirationDateStr, DATE_PATTERN_CB);\\r\\n                    Date cbExpirationDateJourJ_30 = DateUtils.addDaysToDate(cbExpirationDate, -BEFORE_CB_EXPIRATION_DATE_30);\\r\\n                    Date cbExpirationDateJourJ_29 = DateUtils.addDaysToDate(cbExpirationDate, -BEFORE_CB_EXPIRATION_DATE_30 + 1);\\r\\n                    if ((cbExpirationDateJourJ_30.compareTo(nowDate) <= 0) && (cbExpirationDateJourJ_29.compareTo(nowDate) > 0)) {\\r\\n                        List<ServiceInstance> listServiceSearchLicence = subscription.getServiceInstances();\\r\\n                        if (listServiceSearchLicence == null) {\\r\\n                            log.error(\\\"NeolaneCustomerLife_CB_Script : services of subscription is null / subscription code = \\\" + subscription.getCode());\\r\\n                            continue;\\r\\n                        }\\r\\n                        String licence = \\\"\\\";\\r\\n                        String offerType = \\\"FNAC+\\\";\\r\\n                        for (ServiceInstance serviceSearchLicence : listServiceSearchLicence) {\\r\\n                            if (serviceSearchLicence == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLife_CB_Script : serviceSearchLicence is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n                            if (\\\"SE_FD_LICENCE\\\".equalsIgnoreCase(serviceSearchLicence.getCode())) {\\r\\n                                offerType = \\\"SERENITE\\\";\\r\\n                                licence = (String) cfiService.getInheritedCFValue(serviceSearchLicence, \\\"CF_SE_FD_LICENCE_NUMBER\\\");\\r\\n                            }\\r\\n                        }\\r\\n                        ContactInformation contactInformation = userAccount.getContactInformation();\\r\\n                        if (contactInformation == null) {\\r\\n                            log.error(\\\"NeolaneCustomerLife_CB_Script : contactInformation is null / subscription code = \\\" + subscription.getCode());\\r\\n                            continue;\\r\\n                        }\\r\\n\\r\\n                        String email = contactInformation.getEmail();\\r\\n                        email = (email == null) ? \\\"\\\" : email;\\r\\n\\r\\n                        String ws_address = email;\\r\\n\\r\\n                        String ws_culture = CULTURE;\\r\\n\\r\\n                        String ws_sendByMail = \\\"true\\\";\\r\\n\\r\\n                        String ws_sendBySMS = \\\"false\\\";\\r\\n\\r\\n                        String cellphone = contactInformation.getMobile();\\r\\n                        if (StringUtils.isBlank(cellphone)) {\\r\\n                            cellphone = \\\"\\\";\\r\\n                        }\\r\\n                        String ws_cellphone = cellphone;\\r\\n\\r\\n                        SimpleDateFormat fd = new SimpleDateFormat(DATE_PATTERN);\\r\\n                        SimpleDateFormat fdBody = new SimpleDateFormat(DATE_PATTERN_BODY);\\r\\n\\r\\n                        Calendar expirationDateCalendar = Calendar.getInstance();\\r\\n                        expirationDateCalendar.setTime(nowDate);\\r\\n                        expirationDateCalendar.add(Calendar.HOUR_OF_DAY, 12);\\r\\n                        String ws_expirationDate = DateUtils.formatDateWithPattern(expirationDateCalendar.getTime(), DATE_PATTERN);\\r\\n\\r\\n                        String ws_originalDate = DateUtils.formatDateWithPattern(nowDate, DATE_PATTERN);\\r\\n\\r\\n\\r\\n                        String ws_rcpId = \\\"-2\\\";\\r\\n\\r\\n                        String ws_template = \\\"EXPCB_OPENCELL_J30\\\";\\r\\n\\r\\n                        String ws_enseigne = \\\"\\\";\\r\\n                        boolean enseigneTest = false;\\r\\n                        Seller seller = subscription.getSeller();\\r\\n                        Seller seller_N_1 = null;\\r\\n                        Seller seller_N_2 = null;\\r\\n                        if (seller != null) {\\r\\n                            seller_N_1 = seller.getSeller();\\r\\n                            if (seller_N_1 != null) {\\r\\n                                seller_N_2 = seller_N_1.getSeller();\\r\\n                                if (seller_N_2 != null) {\\r\\n                                    if (seller_N_2.getCode() != null) {\\r\\n                                        enseigneTest = true;\\r\\n                                    }\\r\\n                                }\\r\\n                            }\\r\\n                        }\\r\\n                        if (enseigneTest) {\\r\\n                            ws_enseigne = seller_N_2.getCode();\\r\\n                        } else {\\r\\n                            log.error(\\\"NeolaneCustomerLife_CB_Script : enseigne is undefined / subscription code = \\\" + subscription.getCode());\\r\\n                        }\\r\\n\\r\\n                        boolean nameOk = false;\\r\\n                        Customer customer = null;\\r\\n                        Name name = null;\\r\\n                        Title title = null;\\r\\n                        if (customerAccount != null) {\\r\\n                            customer = customerAccount.getCustomer();\\r\\n                            if (customer != null) {\\r\\n                                name = customer.getName();\\r\\n                                if (name != null) {\\r\\n                                    nameOk = true;\\r\\n                                }\\r\\n                            }\\r\\n                        }\\r\\n\\r\\n                        if (nameOk == false) {\\r\\n                            log.error(\\\"NeolaneCustomerLife_CB_10_Script : problem with name / subscription code = \\\" + subscription.getCode());\\r\\n                            continue;\\r\\n                        }\\r\\n                        title = name.getTitle();\\r\\n                        String ws_gender = \\\"\\\";\\r\\n                        if (title != null && title.getCode() != null) {\\r\\n                            ws_gender = title.getCode();\\r\\n                        }\\r\\n\\r\\n                        String ws_firstName = (name.getFirstName() == null) ? \\\"\\\" : name.getFirstName();\\r\\n                        String ws_lastName = (name.getLastName() == null) ? \\\"\\\" : name.getLastName();\\r\\n\\r\\n                        String ws_email = email;\\r\\n\\r\\n                        String ws_contractNumber = subscription.getCode();\\r\\n\\r\\n                        OfferTemplate offer = subscription.getOffer();\\r\\n                        if (offer == null) {\\r\\n                            log.error(\\\"NeolaneCustomerLife_CB_Script : offer is null / subscription code = \\\" + subscription.getCode());\\r\\n                            continue;\\r\\n                        }\\r\\n                        String ws_offerLabel = (offer.getName() == null) ? \\\"\\\" : offer.getName();\\r\\n\\r\\n                        String ws_contractStatus = \\\"\\\";\\r\\n                        if (subscription.getStatus() == null) {\\r\\n                            log.error(\\\"NeolaneCustomerLife_CB_Script : subscription.status is null / subscription code = \\\" + subscription.getCode());\\r\\n                            continue;\\r\\n                        }\\r\\n\\r\\n                        switch(subscription.getStatus()) {\\r\\n                            case CREATED:\\r\\n                                ws_contractStatus = SUBSCRIPTION_CREATED;\\r\\n                                break;\\r\\n                            case ACTIVE:\\r\\n                                ws_contractStatus = SUBSCRIPTION_ACTIVE;\\r\\n                                break;\\r\\n                            case CANCELED:\\r\\n                                ws_contractStatus = SUBSCRIPTION_CANCELED;\\r\\n                                break;\\r\\n                            case RESILIATED:\\r\\n                                ws_contractStatus = SUBSCRIPTION_RESILIATED;\\r\\n                                break;\\r\\n                            case CLOSED:\\r\\n                                ws_contractStatus = SUBSCRIPTION_CLOSED;\\r\\n                                break;\\r\\n                            case SUSPENDED:\\r\\n                                ws_contractStatus = SUBSCRIPTION_SUSPENDED;\\r\\n                                break;\\r\\n                            default:\\r\\n                                ws_contractStatus = \\\"\\\";\\r\\n                        }\\r\\n\\r\\n                        String ws_cardNumber = \\\"\\\";\\r\\n                        String ws_serenityUrl = \\\"\\\";\\r\\n                        if (\\\"SERENITE\\\".equals(offerType)) {\\r\\n                            ws_cardNumber = licence;\\r\\n                        } else {\\r\\n                            if (StringUtils.isBlank(cfiService.getInheritedCFValue(subscription, \\\"CF_SU_FD_CARD_NUMBER\\\"))) {\\r\\n                                ws_cardNumber = \\\"\\\";\\r\\n                            } else {\\r\\n                                ws_cardNumber = (String) cfiService.getInheritedCFValue(subscription, \\\"CF_SU_FD_CARD_NUMBER\\\");\\r\\n                            }\\r\\n                        }\\r\\n\\r\\n                        String ws_adhNumber = \\\"\\\";\\r\\n\\r\\n                        final String selfCareUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_SELFCARE_NCLS, true);\\r\\n                        String ws_urlSelfcare = \\\"\\\";\\r\\n                        if (!StringUtils.isBlank(selfCareUrl)) {\\r\\n                            ws_urlSelfcare = selfCareUrl;\\r\\n                        }\\r\\n\\r\\n                        String ws_engagmentEndDate = DateUtils.formatDateWithPattern(subscription.getEndAgreementDate(), DATE_PATTERN_BODY);\\r\\n\\r\\n                        String ws_tryBuyEndDate = \\\"\\\";\\r\\n\\r\\n                        String ws_subAmount = \\\"0\\\";\\r\\n                        if (cfiService.getInheritedCFValue(subscription.getOffer(), \\\"CF_OF_FD_PRICE\\\") != null) {\\r\\n                            ws_subAmount = String.valueOf(cfiService.getInheritedCFValue(subscription.getOffer(), \\\"CF_OF_FD_PRICE\\\"));\\r\\n                        }\\r\\n\\r\\n                        String ws_cbValidityDate = fdBody.format(cbExpirationDate);\\r\\n                        String ws_paymentMode = PAYMENT_MODE_CB;\\r\\n                        String ws_rejectDate = \\\"\\\";\\r\\n                        String ws_rejectedInvoiceNb = \\\"\\\";\\r\\n                        String ws_rejectedAmountTTC = \\\"\\\";\\r\\n                        String ws_reason = \\\"\\\";\\r\\n                        String ws_amountDrawn = \\\"\\\";\\r\\n                        String ws_withdrawalDate = \\\"\\\";\\r\\n                        String ws_oneTimeCBPaymentDate = \\\"\\\";\\r\\n                        String ws_oneTimePaymentAmount = \\\"\\\";\\r\\n                        String ws_refundDate = \\\"\\\";\\r\\n                        String ws_refundAmount = \\\"\\\";\\r\\n                        String ws_discountEntryDate = \\\"\\\";\\r\\n                        String ws_discountAmount = \\\"\\\";\\r\\n                        String ws_transacAutorisationNb = \\\"\\\";\\r\\n                        String ws_rum = \\\"\\\";\\r\\n                        String ws_ics = \\\"\\\";\\r\\n                        String ws_legalEntityName = \\\"\\\";\\r\\n                        String ws_activationDate = \\\"\\\";\\r\\n                        String ws_rterminationDate = \\\"\\\";\\r\\n                        String ws_terminationReason = \\\"\\\";\\r\\n                        String ws_trActivationDate = \\\"\\\";\\r\\n                        String ws_trDeactivationDate = \\\"\\\";\\r\\n\\r\\n                        String soapEnvBody =\\r\\n\\r\\n                                \\\"<urn:Submit><urn:sessiontoken></urn:sessiontoken><urn:elemCtx><ctx \\\" + \\\" address=\\\\\\\"\\\" + ws_address + \\\"\\\\\\\"\\\" + \\\" culture=\\\\\\\"\\\" + ws_culture + \\\"\\\\\\\"\\\"\\r\\n                                        + \\\" sendByMail=\\\\\\\"\\\" + ws_sendByMail + \\\"\\\\\\\"\\\" + \\\" sendBySMS=\\\\\\\"\\\" + ws_sendBySMS + \\\"\\\\\\\"\\\" + \\\" cellphone=\\\\\\\"\\\" + ws_cellphone + \\\"\\\\\\\"\\\"\\r\\n                                        + \\\" expirationDate=\\\\\\\"\\\" + ws_expirationDate + \\\"\\\\\\\"\\\" + \\\" originalDate=\\\\\\\"\\\" + ws_originalDate + \\\"\\\\\\\"\\\" + \\\" rcpId=\\\\\\\"\\\" + ws_rcpId + \\\"\\\\\\\"\\\"\\r\\n                                        + \\\" template=\\\\\\\"\\\" + ws_template + \\\"\\\\\\\"\\\" + \\\" xmlns=\\\\\\\"\\\\\\\">\\\" + \\\"<CUSTOMER> \\\" + \\\"<Enseigne>\\\" + ws_enseigne + \\\"</Enseigne>\\\" + \\\"<Gender>\\\" + ws_gender\\r\\n                                        + \\\"</Gender>\\\" + \\\"<FirstName>\\\" + ws_firstName + \\\"</FirstName>\\\" + \\\"<LastName>\\\" + ws_lastName + \\\"</LastName>\\\" + \\\"<Email>\\\" + ws_email\\r\\n                                        + \\\"</Email>\\\" + \\\"<SendBySMS>\\\" + ws_sendBySMS + \\\"</SendBySMS>\\\" + \\\"<sendByMail>\\\" + ws_sendByMail + \\\"</sendByMail>\\\" + \\\"<ContractNumber>\\\"\\r\\n                                        + ws_contractNumber + \\\"</ContractNumber>\\\" + \\\"<offerLabel>\\\" + ws_offerLabel + \\\"</offerLabel>\\\" + \\\"<ContractStatus>\\\" + ws_contractStatus\\r\\n                                        + \\\"</ContractStatus>\\\" + \\\"<CardNumber>\\\" + ws_cardNumber + \\\"</CardNumber>\\\" + \\\"<AdhNumber>\\\" + ws_adhNumber + \\\"</AdhNumber>\\\" + \\\"<SelfCareUrl>\\\"\\r\\n                                        + ws_urlSelfcare + \\\"</SelfCareUrl>\\\" + \\\"<SerenityUrl>\\\" + ws_serenityUrl + \\\"</SerenityUrl>\\\" + \\\"<EngagmentEndDate>\\\" + ws_engagmentEndDate\\r\\n                                        + \\\"</EngagmentEndDate>\\\" + \\\"<TryBuyEndDate>\\\" + ws_tryBuyEndDate + \\\"</TryBuyEndDate>\\\" + \\\"<SubAmount>\\\" + ws_subAmount + \\\"</SubAmount>\\\"\\r\\n                                        + \\\"</CUSTOMER> \\\" + \\\"<INVOICE> \\\" + \\\"<CBValidityDate>\\\" + ws_cbValidityDate + \\\"</CBValidityDate>\\\" + \\\"<PaymentMode>\\\" + ws_paymentMode\\r\\n                                        + \\\"</PaymentMode>\\\" + \\\"<RejectDate>\\\" + ws_rejectDate + \\\"</RejectDate>\\\" + \\\"<RejectedInvoiceNb>\\\" + ws_rejectedInvoiceNb\\r\\n                                        + \\\"</RejectedInvoiceNb>\\\" + \\\"<RejectedAmountTTC>\\\" + ws_rejectedAmountTTC + \\\"</RejectedAmountTTC>\\\" + \\\"<Reason>\\\" + ws_reason + \\\"</Reason>\\\"\\r\\n                                        + \\\"<AmountDrawn>\\\" + ws_amountDrawn + \\\"</AmountDrawn>\\\" + \\\"<WithdrawalDate>\\\" + ws_withdrawalDate + \\\"</WithdrawalDate>\\\"\\r\\n                                        + \\\"<OneTimeCBPaymentDate>\\\" + ws_oneTimeCBPaymentDate + \\\"</OneTimeCBPaymentDate>\\\" + \\\"<OneTimePaymentAmount>\\\" + ws_oneTimePaymentAmount\\r\\n                                        + \\\"</OneTimePaymentAmount>\\\" + \\\"<RefundDate>\\\" + ws_refundDate + \\\"</RefundDate>\\\" + \\\"<RefundAmount>\\\" + ws_refundAmount + \\\"</RefundAmount>\\\"\\r\\n                                        + \\\"<DiscountEntryDate>\\\" + ws_discountEntryDate + \\\"</DiscountEntryDate>\\\" + \\\"<DiscountAmount>\\\" + ws_discountAmount + \\\"</DiscountAmount>\\\"\\r\\n                                        + \\\"<TransacAutorisationNb>\\\" + ws_transacAutorisationNb + \\\"</TransacAutorisationNb>\\\" + \\\"<Rum>\\\" + ws_rum + \\\"</Rum>\\\" + \\\"<Ics>\\\" + ws_ics\\r\\n                                        + \\\"</Ics>\\\" + \\\"<LegalEntityName>\\\" + ws_legalEntityName + \\\"</LegalEntityName>\\\" + \\\"</INVOICE>\\\" + \\\"<TERMINATION>\\\" + \\\"<ActivationDate>\\\"\\r\\n                                        + ws_activationDate + \\\"</ActivationDate>\\\" + \\\"<TerminationDate>\\\" + ws_rterminationDate + \\\"</TerminationDate>\\\" + \\\"<TerminationReason>\\\"\\r\\n                                        + ws_terminationReason + \\\"</TerminationReason>\\\" + \\\"</TERMINATION>\\\" + \\\"<TACITRENEWAL>\\\" + \\\"<TrActivationDate>\\\" + ws_trActivationDate\\r\\n                                        + \\\"</TrActivationDate>\\\" + \\\"<TrDeactivationDate>\\\" + ws_trDeactivationDate + \\\"</TrDeactivationDate>\\\" + \\\"</TACITRENEWAL>\\\"\\r\\n                                        + \\\"</ctx></urn:elemCtx></urn:Submit>\\\";\\r\\n\\r\\n                        String response = callWebService(soapEnvBody);\\r\\n\\r\\n                        log.info(\\\"response = \\\" + response);\\r\\n                        log.info(\\\"soapEnvBody = \\\" + soapEnvBody);\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n        }\\r\\n    }\\r\\n}\",\n    \"executionRoles\": [],\n    \"sourcingRoles\": []\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/scriptInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"scriptInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLife_CB_10_Script",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										},
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"org.meveo.service.script.NeolaneCustomerLife_CB_10_Script\",\n    \"description\": \"NeolaneCustomerLife_CB_10 Script\",\n    \"type\": \"JAVA\",\n    \"script\": \"package org.meveo.service.script;\\r\\n\\r\\nimport org.apache.http.client.methods.CloseableHttpResponse;\\r\\nimport org.apache.http.client.methods.HttpPost;\\r\\nimport org.apache.http.conn.ssl.NoopHostnameVerifier;\\r\\nimport org.apache.http.conn.ssl.SSLContextBuilder;\\r\\nimport org.apache.http.conn.ssl.TrustStrategy;\\r\\nimport org.apache.http.entity.StringEntity;\\r\\nimport org.apache.http.impl.client.CloseableHttpClient;\\r\\nimport org.apache.http.impl.client.HttpClients;\\r\\nimport org.meveo.admin.exception.BusinessException;\\r\\nimport org.meveo.commons.utils.StringUtils;\\r\\nimport org.meveo.model.ICustomFieldEntity;\\r\\nimport org.meveo.model.admin.Seller;\\r\\nimport org.meveo.model.billing.Invoice;\\r\\nimport org.meveo.model.billing.ServiceInstance;\\r\\nimport org.meveo.model.billing.Subscription;\\r\\nimport org.meveo.model.billing.UserAccount;\\r\\nimport org.meveo.model.billing.BillingAccount;\\r\\nimport org.meveo.model.catalog.OfferTemplate;\\r\\nimport org.meveo.model.crm.Customer;\\r\\nimport org.meveo.model.crm.Provider;\\r\\n\\r\\nimport org.meveo.model.payments.CustomerAccount;\\r\\nimport org.meveo.model.payments.PaymentMethod;\\r\\nimport org.meveo.model.payments.PaymentMethodEnum;\\r\\nimport org.meveo.model.payments.CardPaymentMethod;\\r\\nimport org.meveo.model.payments.AccountOperation;\\r\\nimport org.meveo.model.payments.MatchingStatusEnum;\\r\\nimport org.meveo.model.payments.RejectedPayment;\\r\\nimport org.meveo.model.shared.ContactInformation;\\r\\nimport org.meveo.model.shared.DateUtils;\\r\\nimport org.meveo.model.shared.Name;\\r\\nimport org.meveo.model.shared.Title;\\r\\nimport org.meveo.service.billing.impl.ServiceInstanceService;\\r\\nimport org.meveo.service.crm.impl.CustomFieldInstanceService;\\r\\nimport org.meveo.service.crm.impl.ProviderService;\\r\\n\\r\\nimport java.io.IOException;\\r\\nimport java.security.cert.CertificateException;\\r\\nimport java.security.cert.X509Certificate;\\r\\nimport java.util.Map;\\r\\nimport java.util.HashMap;\\r\\nimport java.util.List;\\r\\nimport java.util.Date;\\r\\nimport java.util.Calendar;\\r\\n\\r\\n/**\\r\\n * Appel le web service Neolane\\r\\n *    Mail de pr\\u00E9venance expiration CB \\u00E0 j-10\\r\\n *\\r\\n * @author Mounir Bahije\\r\\n */\\r\\npublic class NeolaneCustomerLife_CB_10_Script extends Script {\\r\\n\\r\\n    private CustomFieldInstanceService cfiService = (CustomFieldInstanceService) getServiceInterface(\\\"CustomFieldInstanceService\\\");\\r\\n    private ServiceInstanceService serviceInstanceService = (ServiceInstanceService) getServiceInterface(\\\"ServiceInstanceService\\\");\\r\\n    private ProviderService providerService = (ProviderService) getServiceInterface(ProviderService.class.getSimpleName());\\r\\n    private Provider appProvider = providerService.getProvider();\\r\\n\\r\\n    private static final String CULTURE = \\\"fr-FR\\\";\\r\\n    private static final String DATE_PATTERN = \\\"yyyy/MM/dd HH:mm:ss\\\";\\r\\n    private static final String DATE_PATTERN_BODY = \\\"dd/MM/yyyy\\\";\\r\\n    private static final String DATE_PATTERN_CB = \\\"MM/yy\\\";\\r\\n\\r\\n    private static final String CF_FD_URL_WS_NCLS = \\\"CF_FD_URL_WS_NCLS\\\";\\r\\n    private static final String CF_FD_ACTION_URI_WS_NCLS = \\\"CF_FD_ACTION_URI_WS_NCLS\\\";\\r\\n    private static final String CF_FD_URL_SELFCARE_NCLS = \\\"CF_FD_URL_SELFCARE_NCLS\\\";\\r\\n\\r\\n    private static final String SUBSCRIPTION_CREATED = \\\"0\\\";\\r\\n    private static final String SUBSCRIPTION_ACTIVE = \\\"1\\\";\\r\\n    private static final String SUBSCRIPTION_SUSPENDED = \\\"2\\\";\\r\\n    private static final String SUBSCRIPTION_RESILIATED = \\\"3\\\";\\r\\n    private static final String SUBSCRIPTION_CANCELED = \\\"4\\\";\\r\\n    private static final String SUBSCRIPTION_CLOSED = \\\"5\\\";\\r\\n\\r\\n    private static final String PAYMENT_MODE_CB = \\\"CB\\\";\\r\\n\\r\\n    private static final int BEFORE_CB_EXPIRATION_DATE_10 = 10;\\r\\n\\r\\n    @Override\\r\\n    public void execute(Map<String, Object> methodContext) throws BusinessException {\\r\\n\\r\\n        String searchField = \\\"%\\\" + \\\"REC_MAIN\\\";\\r\\n        String query = String.format(\\\"select  si  from ServiceInstance  si WHERE si.code like '%s'\\\", searchField);\\r\\n        Map<String, Object> params = new HashMap<>();\\r\\n        List<ServiceInstance> listServiceInstance = (List<ServiceInstance>) serviceInstanceService.executeSelectQuery(query.toString(), params);\\r\\n        methodContext.clear();\\r\\n        setWSData(listServiceInstance);\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * fetch CF Config Value\\r\\n     *\\r\\n     * @param entity\\r\\n     * @param cfKey\\r\\n     * @param isMandatory\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private Object fetchCFConfigValue(ICustomFieldEntity entity, String cfKey, boolean isMandatory) throws BusinessException {\\r\\n        Object cfValue = cfiService.getCFValue(entity, cfKey);\\r\\n        if (isMandatory && (cfValue == null || (cfValue instanceof String && org.apache.commons.lang3.StringUtils.isEmpty(String.valueOf(cfValue))))) {\\r\\n            throw new BusinessException(\\\" Missing mandatory config [\\\" + cfKey + \\\"]\\\");\\r\\n        }\\r\\n        return cfValue;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Call Neolane WS\\r\\n     *\\r\\n     * @param soapEnvBody\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private String callWebService(String soapEnvBody) throws BusinessException {\\r\\n\\r\\n        String body =\\r\\n                \\\"<?xml version=\\\\\\\"1.0\\\\\\\" encoding=\\\\\\\"UTF-8\\\\\\\"?><soapenv:Envelope xmlns:soapenv=\\\\\\\"http://schemas.xmlsoap.org/soap/envelope/\\\\\\\" \\\" +\\r\\n                        \\\"xmlns:urn=\\\\\\\"urn:nms:rtMsg\\\\\\\"><soapenv:Header/><soapenv:Body>\\\"\\r\\n                        + soapEnvBody + \\\"</soapenv:Body></soapenv:Envelope>\\\";\\r\\n\\r\\n        StringEntity stringEntity = new StringEntity(body, \\\"UTF-8\\\");\\r\\n\\r\\n        final String wsUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_WS_NCLS, true);\\r\\n        final String actionUri = (String) this.fetchCFConfigValue(appProvider, CF_FD_ACTION_URI_WS_NCLS, true);\\r\\n\\r\\n        // Request parameters and other properties.\\r\\n        HttpPost httpPost = new HttpPost(wsUrl);\\r\\n        httpPost.setEntity(stringEntity);\\r\\n        httpPost.setHeader(\\\"SOAPAction\\\", actionUri);\\r\\n\\r\\n        // Execute and get the response.\\r\\n        CloseableHttpClient httpClient = getCloseableHttpClient();\\r\\n        CloseableHttpResponse response = null;\\r\\n        try {\\r\\n\\r\\n            log.info(\\\"we want to sent to this address = \\\" + actionUri);\\r\\n            log.info(\\\"This body = \\\" + body);\\r\\n\\r\\n            response = httpClient.execute(httpPost);\\r\\n            boolean responseOk = false;\\r\\n            if (response != null) {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    if (response.getStatusLine().getStatusCode() == 200) {\\r\\n                        responseOk = true;\\r\\n                        log.info(\\\"In NeolaneCustomerLife_CB_10_Script : body sent and it's Ok\\\");\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n            if (responseOk) {\\r\\n                log.info(\\\"In NeolaneCustomerLife_CB_10_Script : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                return \\\"OK\\\";\\r\\n            } else {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    log.error(\\\"In NeolaneCustomerLife_CB_10_Script : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                } else {\\r\\n                    log.error(\\\"In NeolaneCustomerLife_CB_10_Script : response.getStatusLine() = null \\\");\\r\\n                }\\r\\n                return \\\"KO\\\";\\r\\n            }\\r\\n\\r\\n        } catch (IOException e) {\\r\\n            log.error(\\\"Exception in EndSubscriptionScript :\\\", e);\\r\\n        }\\r\\n        return \\\"KO\\\";\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * get CloseableHttpClient\\r\\n     *\\r\\n     * @return trusted httpClient\\r\\n     */\\r\\n    public  CloseableHttpClient getCloseableHttpClient()\\r\\n    {\\r\\n        CloseableHttpClient httpClient = null;\\r\\n        try {\\r\\n            httpClient = HttpClients.custom().\\r\\n                    setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).\\r\\n                    setSSLContext(new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy()\\r\\n                    {\\r\\n                        public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException\\r\\n                        {\\r\\n                            return true;\\r\\n                        }\\r\\n                    }).build()).build();\\r\\n        } catch (Exception e) {\\r\\n            log.error(\\\"KeyManagementException in creating http client instance\\\", e);\\r\\n        }\\r\\n        return httpClient;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Set Data for Neolane WS\\r\\n     *\\r\\n     * @param listServiceInstance the list of serviceInstance\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private void setWSData(List<ServiceInstance> listServiceInstance) throws BusinessException {\\r\\n\\r\\n        if (listServiceInstance == null) {\\r\\n            return;\\r\\n        }\\r\\n\\r\\n        Date nowDate = new Date();\\r\\n\\r\\n        for (ServiceInstance serviceInstance : listServiceInstance) {\\r\\n            Subscription subscription = serviceInstance.getSubscription();\\r\\n            if (subscription == null) {\\r\\n                log.error(\\\"NeolaneCustomerLife_CB_10_Script : subscription is null\\\");\\r\\n                continue;\\r\\n            }\\r\\n            UserAccount userAccount = subscription.getUserAccount();\\r\\n            if (userAccount == null) {\\r\\n                log.error(\\\"NeolaneCustomerLife_CB_10_Script : userAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                continue;\\r\\n            }\\r\\n            BillingAccount billingAccount = userAccount.getBillingAccount();\\r\\n            if (billingAccount == null) {\\r\\n                log.error(\\\"NeolaneCustomerLife_CB_10_Script : billingAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                continue;\\r\\n            }\\r\\n            CustomerAccount customerAccount = billingAccount.getCustomerAccount();\\r\\n            if (customerAccount == null) {\\r\\n                log.error(\\\"NeolaneCustomerLife_CB_10_Script : customerAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                continue;\\r\\n            }\\r\\n            PaymentMethod paymentMethod = customerAccount.getPreferredPaymentMethod();\\r\\n            if (PaymentMethodEnum.CARD.equals(paymentMethod.getPaymentType())) {\\r\\n\\r\\n                String cbExpirationDateStr = ((CardPaymentMethod) paymentMethod).getExpirationMonthAndYear();\\r\\n                Date cbExpirationDate = DateUtils.parseDateWithPattern(cbExpirationDateStr, DATE_PATTERN_CB);\\r\\n                Date cbExpirationDateJourJ_10 = DateUtils.addDaysToDate(cbExpirationDate, -BEFORE_CB_EXPIRATION_DATE_10);\\r\\n                Date cbExpirationDateJourJ_09 = DateUtils.addDaysToDate(cbExpirationDate, -BEFORE_CB_EXPIRATION_DATE_10 + 1);\\r\\n                if ((cbExpirationDateJourJ_10.compareTo(nowDate) <= 0) && (cbExpirationDateJourJ_09.compareTo(nowDate) > 0)) {\\r\\n                    List<ServiceInstance> listServiceSearchLicence = subscription.getServiceInstances();\\r\\n                    if (listServiceSearchLicence == null) {\\r\\n                        log.error(\\\"NeolaneCustomerLife_CB_10_Script : services of subscription is null / subscription code = \\\" + subscription.getCode());\\r\\n                        continue;\\r\\n                    }\\r\\n                    String licence = \\\"\\\";\\r\\n                    String offerType = \\\"FNAC+\\\";\\r\\n                    for (ServiceInstance serviceSearchLicence : listServiceSearchLicence) {\\r\\n                        if (serviceSearchLicence == null) {\\r\\n                            log.error(\\\"NeolaneCustomerLife_CB_10_Script : serviceSearchLicence is null / subscription code = \\\" + subscription.getCode());\\r\\n                            continue;\\r\\n                        }\\r\\n                        if (\\\"SE_FD_LICENCE\\\".equalsIgnoreCase(serviceSearchLicence.getCode())) {\\r\\n                            offerType = \\\"SERENITE\\\";\\r\\n                            licence = (String) cfiService.getInheritedCFValue(serviceSearchLicence, \\\"CF_SE_FD_LICENCE_NUMBER\\\");\\r\\n                        }\\r\\n                    }\\r\\n                    ContactInformation contactInformation = userAccount.getContactInformation();\\r\\n                    if (contactInformation == null) {\\r\\n                        log.error(\\\"NeolaneCustomerLife_CB_10_Script : contactInformation is null / subscription code = \\\" + subscription.getCode());\\r\\n                        continue;\\r\\n                    }\\r\\n\\r\\n                    String email = contactInformation.getEmail();\\r\\n                    email = (email == null) ? \\\"\\\" : email;\\r\\n                    String ws_address = email;\\r\\n                    String ws_email = email;\\r\\n\\r\\n                    String ws_culture = CULTURE;\\r\\n                    String ws_sendByMail = \\\"true\\\";\\r\\n                    String ws_sendBySMS = \\\"false\\\";\\r\\n                    String ws_cellphone = contactInformation.getMobile();\\r\\n                    if (StringUtils.isBlank(ws_cellphone)) {\\r\\n                        ws_cellphone = \\\"\\\";\\r\\n                    }\\r\\n\\r\\n                    Calendar expirationDateCalendar = Calendar.getInstance();\\r\\n                    expirationDateCalendar.setTime(nowDate);\\r\\n                    expirationDateCalendar.add(Calendar.HOUR_OF_DAY, 12);\\r\\n                    String ws_expirationDate = DateUtils.formatDateWithPattern(expirationDateCalendar.getTime(), DATE_PATTERN);\\r\\n\\r\\n                    String ws_originalDate = DateUtils.formatDateWithPattern(nowDate, DATE_PATTERN);\\r\\n\\r\\n                    String ws_rcpId = \\\"-2\\\";\\r\\n\\r\\n                    String ws_template = \\\"EXPCB_OPENCELL_J10\\\";\\r\\n\\r\\n                    String ws_enseigne = \\\"\\\";\\r\\n                    boolean enseigneTest = false;\\r\\n                    Seller seller = subscription.getSeller();\\r\\n                    Seller seller_N_1 = null;\\r\\n                    Seller seller_N_2 = null;\\r\\n                    if (seller != null) {\\r\\n                        seller_N_1 = seller.getSeller();\\r\\n                        if (seller_N_1 != null) {\\r\\n                            seller_N_2 = seller_N_1.getSeller();\\r\\n                            if (seller_N_2 != null) {\\r\\n                                if (seller_N_2.getCode() != null) {\\r\\n                                    enseigneTest = true;\\r\\n                                }\\r\\n                            }\\r\\n                        }\\r\\n                    }\\r\\n                    if (enseigneTest) {\\r\\n                        ws_enseigne = seller_N_2.getCode();\\r\\n                    } else {\\r\\n                        log.error(\\\"NeolaneCustomerLife_CB_10_Script : enseigne is undefined / subscription code = \\\" + subscription.getCode());\\r\\n                    }\\r\\n\\r\\n                    boolean nameOk = false;\\r\\n                    Customer customer = null;\\r\\n                    Name name = null;\\r\\n                    Title title = null;\\r\\n                    if (customerAccount != null) {\\r\\n                        customer = customerAccount.getCustomer();\\r\\n                        if (customer != null) {\\r\\n                            name = customer.getName();\\r\\n                            if (name != null) {\\r\\n                                nameOk = true;\\r\\n                            }\\r\\n                        }\\r\\n                    }\\r\\n                    if (nameOk == false) {\\r\\n                        log.error(\\\"NeolaneCustomerLife_CB_10_Script : problem with name / subscription code = \\\" + subscription.getCode());\\r\\n                        continue;\\r\\n                    }\\r\\n                    title = name.getTitle();\\r\\n                    String ws_gender = \\\"\\\";\\r\\n                    if (title != null && title.getCode() != null) {\\r\\n                        ws_gender = title.getCode();\\r\\n                    }\\r\\n\\r\\n\\r\\n                    String ws_firstName = (name.getFirstName() == null) ? \\\"\\\" : name.getFirstName();\\r\\n                    String ws_lastName = (name.getLastName() == null) ? \\\"\\\" : name.getLastName();\\r\\n\\r\\n\\r\\n                    String ws_contractNumber = subscription.getCode();\\r\\n                    ws_contractNumber = (ws_contractNumber == null) ? \\\"\\\" : ws_contractNumber;\\r\\n\\r\\n                    OfferTemplate offer = subscription.getOffer();\\r\\n                    if (offer == null) {\\r\\n                        log.error(\\\"NeolaneCustomerLife_CB_10_Script : offer is null / subscription code = \\\" + subscription.getCode());\\r\\n                        continue;\\r\\n                    }\\r\\n                    String ws_offerLabel = (offer.getName() == null) ? \\\"\\\" : offer.getName();\\r\\n\\r\\n                    String ws_contractStatus = \\\"\\\";\\r\\n                    if (subscription.getStatus() == null) {\\r\\n                        log.error(\\\"NeolaneCustomerLife_CB_10_Script : subscription.status is null / subscription code = \\\" + subscription.getCode());\\r\\n                        continue;\\r\\n                    }\\r\\n\\r\\n                    switch(subscription.getStatus()) {\\r\\n                        case CREATED:\\r\\n                            ws_contractStatus = SUBSCRIPTION_CREATED;\\r\\n                            break;\\r\\n                        case ACTIVE:\\r\\n                            ws_contractStatus = SUBSCRIPTION_ACTIVE;\\r\\n                            break;\\r\\n                        case CANCELED:\\r\\n                            ws_contractStatus = SUBSCRIPTION_CANCELED;\\r\\n                            break;\\r\\n                        case RESILIATED:\\r\\n                            ws_contractStatus = SUBSCRIPTION_RESILIATED;\\r\\n                            break;\\r\\n                        case CLOSED:\\r\\n                            ws_contractStatus = SUBSCRIPTION_CLOSED;\\r\\n                            break;\\r\\n                        case SUSPENDED:\\r\\n                            ws_contractStatus = SUBSCRIPTION_SUSPENDED;\\r\\n                            break;\\r\\n                        default:\\r\\n                            ws_contractStatus = \\\"\\\";\\r\\n                    }\\r\\n\\r\\n                    String ws_cardNumber = \\\"\\\";\\r\\n                    String ws_serenityUrl = \\\"\\\";\\r\\n                    if (\\\"SERENITE\\\".equals(offerType)) {\\r\\n                        ws_cardNumber = licence;\\r\\n                    } else {\\r\\n                        if (StringUtils.isBlank(cfiService.getInheritedCFValue(subscription, \\\"CF_SU_FD_CARD_NUMBER\\\"))) {\\r\\n                            ws_cardNumber = \\\"\\\";\\r\\n                        } else {\\r\\n                            ws_cardNumber = (String) cfiService.getInheritedCFValue(subscription, \\\"CF_SU_FD_CARD_NUMBER\\\");\\r\\n                        }\\r\\n                    }\\r\\n\\r\\n                    String ws_adhNumber = \\\"\\\";\\r\\n\\r\\n                    final String selfCareUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_SELFCARE_NCLS, true);\\r\\n                    String ws_urlSelfcare = \\\"\\\";\\r\\n                    if (!StringUtils.isBlank(selfCareUrl)) {\\r\\n                        ws_urlSelfcare = selfCareUrl;\\r\\n                    }\\r\\n\\r\\n                    String ws_engagmentEndDate = DateUtils.formatDateWithPattern(subscription.getEndAgreementDate(), DATE_PATTERN_BODY);\\r\\n\\r\\n                    String ws_tryBuyEndDate = \\\"\\\";\\r\\n\\r\\n                    String ws_subAmount = \\\"0\\\";\\r\\n                    if (cfiService.getInheritedCFValue(subscription.getOffer(), \\\"CF_OF_FD_PRICE\\\") != null) {\\r\\n                        ws_subAmount = String.valueOf(cfiService.getInheritedCFValue(subscription.getOffer(), \\\"CF_OF_FD_PRICE\\\"));\\r\\n                    }\\r\\n\\r\\n                    String ws_cbValidityDate = DateUtils.formatDateWithPattern(cbExpirationDate, DATE_PATTERN_BODY);\\r\\n                    String ws_paymentMode = PAYMENT_MODE_CB;\\r\\n                    String ws_rejectDate = \\\"\\\";\\r\\n                    String ws_rejectedInvoiceNb = \\\"\\\";\\r\\n                    String ws_rejectedAmountTTC = \\\"\\\";\\r\\n                    String ws_reason = \\\"\\\";\\r\\n\\r\\n\\r\\n                    List<AccountOperation> listAccountOperation = customerAccount.getAccountOperations();\\r\\n\\r\\n                    if (listAccountOperation != null) {\\r\\n                        for (AccountOperation accountOperation : listAccountOperation) {\\r\\n                            if (accountOperation != null) {\\r\\n                                if (MatchingStatusEnum.R == accountOperation.getMatchingStatus()) {\\r\\n                                    Date dateBefore20Days = DateUtils.addDaysToDate(nowDate, -20);\\r\\n                                    RejectedPayment rejectedPayment = accountOperation.getRejectedPayment();\\r\\n                                    if ((rejectedPayment != null) && (rejectedPayment.getRejectedDate() != null)) {\\r\\n                                        if (dateBefore20Days.compareTo(rejectedPayment.getRejectedDate()) < 0) {\\r\\n                                            ws_rejectDate = DateUtils.formatDateWithPattern(rejectedPayment.getRejectedDate(), DATE_PATTERN_BODY);\\r\\n                                            List invoices = accountOperation.getInvoices();\\r\\n                                            if (invoices != null) {\\r\\n                                                if (invoices.size() > 0) {\\r\\n                                                    Invoice rejectedInvoice = (Invoice) invoices.get(0);\\r\\n                                                    ws_rejectedInvoiceNb = rejectedInvoice.getInvoiceNumber();\\r\\n                                                    ws_rejectedAmountTTC = String.valueOf(rejectedInvoice.getAmountWithTax());\\r\\n                                                    ws_reason = accountOperation.getRejectedPayment().getRejectedCode();\\r\\n                                                }\\r\\n                                            }\\r\\n                                        }\\r\\n                                    }\\r\\n                                }\\r\\n                            }\\r\\n                        }\\r\\n                    }\\r\\n\\r\\n\\r\\n                    String ws_amountDrawn = \\\"\\\";\\r\\n                    String ws_withdrawalDate = \\\"\\\";\\r\\n                    String ws_oneTimeCBPaymentDate = \\\"\\\";\\r\\n                    String ws_oneTimePaymentAmount = \\\"\\\";\\r\\n                    String ws_refundDate = \\\"\\\";\\r\\n                    String ws_refundAmount = \\\"\\\";\\r\\n                    String ws_discountEntryDate = \\\"\\\";\\r\\n                    String ws_discountAmount = \\\"\\\";\\r\\n                    String ws_transacAutorisationNb = \\\"\\\";\\r\\n                    String ws_rum = \\\"\\\";\\r\\n                    String ws_ics = \\\"\\\";\\r\\n                    String ws_legalEntityName = \\\"\\\";\\r\\n                    String ws_activationDate = \\\"\\\";\\r\\n                    String ws_rterminationDate = \\\"\\\";\\r\\n                    String ws_terminationReason = \\\"\\\";\\r\\n                    String ws_trActivationDate = \\\"\\\";\\r\\n                    String ws_trDeactivationDate = \\\"\\\";\\r\\n\\r\\n                    String soapEnvBody =\\r\\n\\r\\n                            \\\"<urn:Submit><urn:sessiontoken></urn:sessiontoken><urn:elemCtx><ctx \\\" + \\\" address=\\\\\\\"\\\" + ws_address + \\\"\\\\\\\"\\\" + \\\" culture=\\\\\\\"\\\" + ws_culture + \\\"\\\\\\\"\\\"\\r\\n                                    + \\\" sendByMail=\\\\\\\"\\\" + ws_sendByMail + \\\"\\\\\\\"\\\" + \\\" sendBySMS=\\\\\\\"\\\" + ws_sendBySMS + \\\"\\\\\\\"\\\" + \\\" cellphone=\\\\\\\"\\\" + ws_cellphone + \\\"\\\\\\\"\\\"\\r\\n                                    + \\\" expirationDate=\\\\\\\"\\\" + ws_expirationDate + \\\"\\\\\\\"\\\" + \\\" originalDate=\\\\\\\"\\\" + ws_originalDate + \\\"\\\\\\\"\\\" + \\\" rcpId=\\\\\\\"\\\" + ws_rcpId + \\\"\\\\\\\"\\\"\\r\\n                                    + \\\" template=\\\\\\\"\\\" + ws_template + \\\"\\\\\\\"\\\" + \\\" xmlns=\\\\\\\"\\\\\\\">\\\" + \\\"<CUSTOMER> \\\" + \\\"<Enseigne>\\\" + ws_enseigne + \\\"</Enseigne>\\\" + \\\"<Gender>\\\" + ws_gender\\r\\n                                    + \\\"</Gender>\\\" + \\\"<FirstName>\\\" + ws_firstName + \\\"</FirstName>\\\" + \\\"<LastName>\\\" + ws_lastName + \\\"</LastName>\\\" + \\\"<Email>\\\" + ws_email\\r\\n                                    + \\\"</Email>\\\" + \\\"<SendBySMS>\\\" + ws_sendBySMS + \\\"</SendBySMS>\\\" + \\\"<sendByMail>\\\" + ws_sendByMail + \\\"</sendByMail>\\\" + \\\"<ContractNumber>\\\"\\r\\n                                    + ws_contractNumber + \\\"</ContractNumber>\\\" + \\\"<offerLabel>\\\" + ws_offerLabel + \\\"</offerLabel>\\\" + \\\"<ContractStatus>\\\" + ws_contractStatus\\r\\n                                    + \\\"</ContractStatus>\\\" + \\\"<CardNumber>\\\" + ws_cardNumber + \\\"</CardNumber>\\\" + \\\"<AdhNumber>\\\" + ws_adhNumber + \\\"</AdhNumber>\\\" + \\\"<SelfCareUrl>\\\"\\r\\n                                    + ws_urlSelfcare + \\\"</SelfCareUrl>\\\" + \\\"<SerenityUrl>\\\" + ws_serenityUrl + \\\"</SerenityUrl>\\\" + \\\"<EngagmentEndDate>\\\" + ws_engagmentEndDate\\r\\n                                    + \\\"</EngagmentEndDate>\\\" + \\\"<TryBuyEndDate>\\\" + ws_tryBuyEndDate + \\\"</TryBuyEndDate>\\\" + \\\"<SubAmount>\\\" + ws_subAmount + \\\"</SubAmount>\\\"\\r\\n                                    + \\\"</CUSTOMER> \\\" + \\\"<INVOICE> \\\" + \\\"<CBValidityDate>\\\" + ws_cbValidityDate + \\\"</CBValidityDate>\\\" + \\\"<PaymentMode>\\\" + ws_paymentMode\\r\\n                                    + \\\"</PaymentMode>\\\" + \\\"<RejectDate>\\\" + ws_rejectDate + \\\"</RejectDate>\\\" + \\\"<RejectedInvoiceNb>\\\" + ws_rejectedInvoiceNb\\r\\n                                    + \\\"</RejectedInvoiceNb>\\\" + \\\"<RejectedAmountTTC>\\\" + ws_rejectedAmountTTC + \\\"</RejectedAmountTTC>\\\" + \\\"<Reason>\\\" + ws_reason + \\\"</Reason>\\\"\\r\\n                                    + \\\"<AmountDrawn>\\\" + ws_amountDrawn + \\\"</AmountDrawn>\\\" + \\\"<WithdrawalDate>\\\" + ws_withdrawalDate + \\\"</WithdrawalDate>\\\"\\r\\n                                    + \\\"<OneTimeCBPaymentDate>\\\" + ws_oneTimeCBPaymentDate + \\\"</OneTimeCBPaymentDate>\\\" + \\\"<OneTimePaymentAmount>\\\" + ws_oneTimePaymentAmount\\r\\n                                    + \\\"</OneTimePaymentAmount>\\\" + \\\"<RefundDate>\\\" + ws_refundDate + \\\"</RefundDate>\\\" + \\\"<RefundAmount>\\\" + ws_refundAmount + \\\"</RefundAmount>\\\"\\r\\n                                    + \\\"<DiscountEntryDate>\\\" + ws_discountEntryDate + \\\"</DiscountEntryDate>\\\" + \\\"<DiscountAmount>\\\" + ws_discountAmount + \\\"</DiscountAmount>\\\"\\r\\n                                    + \\\"<TransacAutorisationNb>\\\" + ws_transacAutorisationNb + \\\"</TransacAutorisationNb>\\\" + \\\"<Rum>\\\" + ws_rum + \\\"</Rum>\\\" + \\\"<Ics>\\\" + ws_ics\\r\\n                                    + \\\"</Ics>\\\" + \\\"<LegalEntityName>\\\" + ws_legalEntityName + \\\"</LegalEntityName>\\\" + \\\"</INVOICE>\\\" + \\\"<TERMINATION>\\\" + \\\"<ActivationDate>\\\"\\r\\n                                    + ws_activationDate + \\\"</ActivationDate>\\\" + \\\"<TerminationDate>\\\" + ws_rterminationDate + \\\"</TerminationDate>\\\" + \\\"<TerminationReason>\\\"\\r\\n                                    + ws_terminationReason + \\\"</TerminationReason>\\\" + \\\"</TERMINATION>\\\" + \\\"<TACITRENEWAL>\\\" + \\\"<TrActivationDate>\\\" + ws_trActivationDate\\r\\n                                    + \\\"</TrActivationDate>\\\" + \\\"<TrDeactivationDate>\\\" + ws_trDeactivationDate + \\\"</TrDeactivationDate>\\\" + \\\"</TACITRENEWAL>\\\"\\r\\n                                    + \\\"</ctx></urn:elemCtx></urn:Submit>\\\";\\r\\n\\r\\n                    String response = callWebService(soapEnvBody);\\r\\n\\r\\n                    log.info(\\\"response = \\\" + response);\\r\\n                    log.info(\\\"soapEnvBody = \\\" + soapEnvBody);\\r\\n                }\\r\\n            }\\r\\n        }\\r\\n    }\\r\\n}\",\n    \"executionRoles\": [],\n    \"sourcingRoles\": []\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/scriptInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"scriptInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLifeEndContractScript",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										},
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"org.meveo.service.script.NeolaneCustomerLifeEndContractScript\",\n    \"description\": \"NeolaneCustomerLifeEndContract Script\",\n    \"type\": \"JAVA\",\n    \"script\": \"package org.meveo.service.script;\\r\\n\\r\\nimport org.apache.http.HttpResponse;\\r\\nimport org.apache.http.StatusLine;\\r\\nimport org.apache.http.client.methods.HttpPost;\\r\\nimport org.apache.http.conn.ssl.NoopHostnameVerifier;\\r\\nimport org.apache.http.conn.ssl.SSLContextBuilder;\\r\\nimport org.apache.http.conn.ssl.TrustStrategy;\\r\\nimport org.apache.http.entity.StringEntity;\\r\\nimport org.apache.http.impl.client.CloseableHttpClient;\\r\\nimport org.apache.http.impl.client.HttpClients;\\r\\nimport org.meveo.admin.exception.BusinessException;\\r\\nimport org.meveo.admin.exception.ImportInvoiceException;\\r\\nimport org.meveo.admin.exception.InvoiceExistException;\\r\\nimport org.meveo.api.dto.invoice.GenerateInvoiceRequestDto;\\r\\nimport org.meveo.commons.utils.StringUtils;\\r\\nimport org.meveo.model.ICustomFieldEntity;\\r\\nimport org.meveo.model.admin.Seller;\\r\\nimport org.meveo.model.billing.BillingAccount;\\r\\nimport org.meveo.model.billing.Invoice;\\r\\nimport org.meveo.model.billing.ServiceInstance;\\r\\nimport org.meveo.model.billing.SubCategoryInvoiceAgregate;\\r\\nimport org.meveo.model.billing.Subscription;\\r\\nimport org.meveo.model.billing.SubscriptionRenewal;\\r\\nimport org.meveo.model.billing.UserAccount;\\r\\nimport org.meveo.model.catalog.OfferTemplate;\\r\\nimport org.meveo.model.crm.Customer;\\r\\nimport org.meveo.model.crm.Provider;\\r\\nimport org.meveo.model.payments.CustomerAccount;\\r\\nimport org.meveo.model.payments.PaymentMethod;\\r\\nimport org.meveo.model.payments.PaymentMethodEnum;\\r\\nimport org.meveo.model.shared.ContactInformation;\\r\\nimport org.meveo.model.shared.DateUtils;\\r\\nimport org.meveo.model.shared.Name;\\r\\nimport org.meveo.model.shared.Title;\\r\\nimport org.meveo.service.billing.impl.InvoiceService;\\r\\nimport org.meveo.service.billing.impl.ServiceInstanceService;\\r\\nimport org.meveo.service.crm.impl.CustomFieldInstanceService;\\r\\nimport org.meveo.service.crm.impl.ProviderService;\\r\\n\\r\\nimport java.io.IOException;\\r\\nimport java.math.BigDecimal;\\r\\nimport java.math.RoundingMode;\\r\\nimport java.security.cert.CertificateException;\\r\\nimport java.security.cert.X509Certificate;\\r\\nimport java.util.Calendar;\\r\\nimport java.util.Date;\\r\\nimport java.util.HashMap;\\r\\nimport java.util.List;\\r\\nimport java.util.Map;\\r\\n\\r\\n/**\\r\\n * Appel le web service Neolane\\r\\n *    Mail de pr\\u00E9venance de fin d'adh\\u00E9sion\\r\\n *    Mail de confirmation de renouvellement\\r\\n *\\r\\n * @author Mounir Bahije\\r\\n */\\r\\n\\r\\npublic class NeolaneCustomerLifeEndContractScript extends Script {\\r\\n\\r\\n    private CustomFieldInstanceService cfiService = (CustomFieldInstanceService) getServiceInterface(\\\"CustomFieldInstanceService\\\");\\r\\n    private ServiceInstanceService serviceInstanceService = (ServiceInstanceService) getServiceInterface(\\\"ServiceInstanceService\\\");\\r\\n    private ProviderService providerService = (ProviderService) getServiceInterface(ProviderService.class.getSimpleName());\\r\\n    private Provider appProvider = providerService.getProvider();\\r\\n    private InvoiceService invoiceService = (InvoiceService) getServiceInterface(InvoiceService.class.getSimpleName());\\r\\n\\r\\n    private static final String CULTURE = \\\"fr-FR\\\";\\r\\n    private static final String DATE_PATTERN = \\\"yyyy/MM/dd HH:mm:ss\\\";\\r\\n    private static final String DATE_PATTERN_BODY = \\\"dd/MM/yyyy\\\";\\r\\n\\r\\n    private static final String CF_FD_URL_WS_NCLS = \\\"CF_FD_URL_WS_NCLS\\\";\\r\\n    private static final String CF_FD_ACTION_URI_WS_NCLS = \\\"CF_FD_ACTION_URI_WS_NCLS\\\";\\r\\n    private static final String CF_FD_URL_SELFCARE_NCLS = \\\"CF_FD_URL_SELFCARE_NCLS\\\";\\r\\n\\r\\n    private static final String SUBSCRIPTION_CREATED = \\\"0\\\";\\r\\n    private static final String SUBSCRIPTION_ACTIVE = \\\"1\\\";\\r\\n    private static final String SUBSCRIPTION_SUSPENDED = \\\"2\\\";\\r\\n    private static final String SUBSCRIPTION_RESILIATED = \\\"3\\\";\\r\\n    private static final String SUBSCRIPTION_CANCELED = \\\"4\\\";\\r\\n    private static final String SUBSCRIPTION_CLOSED = \\\"5\\\";\\r\\n\\r\\n    private static final int BEFORE_END_CONTRACT_DATE_90 = 90;\\r\\n    private static final int BEFORE_END_CONTRACT_DATE_30 = 30;\\r\\n    private static final int BEFORE_END_CONTRACT_DATE_00 = 0;\\r\\n\\r\\n    @Override\\r\\n    public void execute(Map<String, Object> methodContext) throws BusinessException {\\r\\n\\r\\n\\r\\n        String searchField = \\\"%\\\" + \\\"REC_MAIN\\\";\\r\\n        String query = String.format(\\\"select  si  from ServiceInstance  si WHERE si.code like '%s'\\\", searchField);\\r\\n        Map<String, Object> params = new HashMap<>();\\r\\n        List<ServiceInstance> listServiceInstance = (List<ServiceInstance>) serviceInstanceService.executeSelectQuery(query.toString(), params);\\r\\n        methodContext.clear();\\r\\n\\r\\n        setWSData(listServiceInstance);\\r\\n\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * fetch CF Config Value\\r\\n     *\\r\\n     * @param entity\\r\\n     * @param cfKey\\r\\n     * @param isMandatory\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private Object fetchCFConfigValue(ICustomFieldEntity entity, String cfKey, boolean isMandatory) throws BusinessException {\\r\\n        Object cfValue = cfiService.getCFValue(entity, cfKey);\\r\\n        if (isMandatory && (cfValue == null || (cfValue instanceof String && org.apache.commons.lang3.StringUtils.isEmpty(String.valueOf(cfValue))))) {\\r\\n            throw new BusinessException(\\\" Missing mandatory config [\\\" + cfKey + \\\"]\\\");\\r\\n        }\\r\\n        return cfValue;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Call Neolane WS\\r\\n     *\\r\\n     * @param soapEnvBody\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private String callWebService(String soapEnvBody) throws BusinessException {\\r\\n\\r\\n        String body =\\r\\n                \\\"<?xml version=\\\\\\\"1.0\\\\\\\" encoding=\\\\\\\"UTF-8\\\\\\\"?><soapenv:Envelope xmlns:soapenv=\\\\\\\"http://schemas.xmlsoap.org/soap/envelope/\\\\\\\" xmlns:urn=\\\\\\\"urn:nms:rtMsg\\\\\\\"><soapenv:Header/><soapenv:Body>\\\"\\r\\n                        + soapEnvBody + \\\"</soapenv:Body></soapenv:Envelope>\\\";\\r\\n\\r\\n        StringEntity stringEntity = new StringEntity(body, \\\"UTF-8\\\");\\r\\n\\r\\n        final String wsUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_WS_NCLS, true);\\r\\n        final String actionUri = (String) this.fetchCFConfigValue(appProvider, CF_FD_ACTION_URI_WS_NCLS, true);\\r\\n\\r\\n        // Request parameters and other properties.\\r\\n        HttpPost httpPost = new HttpPost(wsUrl);\\r\\n        httpPost.setEntity(stringEntity);\\r\\n        httpPost.setHeader(\\\"SOAPAction\\\", actionUri);\\r\\n\\r\\n        // Execute and get the response.\\r\\n        CloseableHttpClient httpClient = getCloseableHttpClient();\\r\\n        HttpResponse response = null;\\r\\n        try {\\r\\n\\r\\n            log.info(\\\"we want to sent to this address = \\\" + actionUri);\\r\\n            log.info(\\\"This body = \\\" + body);\\r\\n\\r\\n            response = httpClient.execute(httpPost);\\r\\n            boolean responseOk = false;\\r\\n            if (response != null) {\\r\\n                StatusLine statusLine = response.getStatusLine();\\r\\n                if (statusLine != null) {\\r\\n                    int statusCode = statusLine.getStatusCode();\\r\\n                    if (statusCode == 200) {\\r\\n                        responseOk = true;\\r\\n                        log.info(\\\"body sent and it's Ok\\\");\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n            if (responseOk) {\\r\\n                log.info(\\\"In NeolaneCustomerLifeEndContractScript : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                return \\\"OK\\\";\\r\\n            } else {\\r\\n                log.error(\\\"In NeolaneCustomerLifeEndContractScript : Status Code of response is not 200 \\\");\\r\\n                return \\\"KO\\\";\\r\\n            }\\r\\n\\r\\n        } catch (IOException e) {\\r\\n            log.error(\\\"Exception in EndSubscriptionScript :\\\", e);\\r\\n        }\\r\\n        return \\\"KO\\\";\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * get CloseableHttpClient\\r\\n     *\\r\\n     * @return trusted httpClient\\r\\n     */\\r\\n    public CloseableHttpClient getCloseableHttpClient()\\r\\n    {\\r\\n        CloseableHttpClient httpClient = null;\\r\\n        try {\\r\\n            httpClient = HttpClients.custom().\\r\\n                    setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).\\r\\n                    setSSLContext(new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy()\\r\\n                    {\\r\\n                        public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException\\r\\n                        {\\r\\n                            return true;\\r\\n                        }\\r\\n                    }).build()).build();\\r\\n        } catch (Exception e) {\\r\\n            log.error(\\\"KeyManagementException in creating http client instance\\\", e);\\r\\n        }\\r\\n        return httpClient;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Set Data for Neolane WS\\r\\n     *\\r\\n     * @param listServiceInstance the list of serviceInstance\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private void setWSData(List<ServiceInstance> listServiceInstance) throws BusinessException {\\r\\n\\r\\n        Date nowDate = new Date();\\r\\n\\r\\n        if (listServiceInstance != null) {\\r\\n            for (ServiceInstance serviceInstance : listServiceInstance) {\\r\\n                Subscription subscription = serviceInstance.getSubscription();\\r\\n                if (subscription == null) {\\r\\n                    log.error(\\\"NeolaneCustomerLifeEndContractScript : subscription is null\\\");\\r\\n                    continue;\\r\\n                }\\r\\n\\r\\n                Date endContractDate = subscription.getSubscribedTillDate();\\r\\n                Date endContractDate_90 = DateUtils.addDaysToDate(endContractDate, -BEFORE_END_CONTRACT_DATE_90);\\r\\n                Date endContractDate_89 = DateUtils.addDaysToDate(endContractDate, -BEFORE_END_CONTRACT_DATE_90 + 1);\\r\\n                Date endContractDate_30 = DateUtils.addDaysToDate(endContractDate, -BEFORE_END_CONTRACT_DATE_30);\\r\\n                Date endContractDate_29 = DateUtils.addDaysToDate(endContractDate, -BEFORE_END_CONTRACT_DATE_30 + 1);\\r\\n                Date endContractDate_00 = DateUtils.addDaysToDate(endContractDate, -BEFORE_END_CONTRACT_DATE_00);\\r\\n                Date endContractDate_01 = DateUtils.addDaysToDate(endContractDate, -BEFORE_END_CONTRACT_DATE_00 + 1);\\r\\n\\r\\n                boolean isDateAtEndContract_90 = DateUtils.isTodayWithinPeriod(endContractDate_90, endContractDate_89);\\r\\n                boolean isDateAtEndContract_30 = DateUtils.isTodayWithinPeriod(endContractDate_30, endContractDate_29);\\r\\n                boolean isDateAtEndContract_00 = DateUtils.isTodayWithinPeriod(endContractDate_00, endContractDate_01);\\r\\n\\r\\n                UserAccount userAccount = subscription.getUserAccount();\\r\\n                if (userAccount == null) {\\r\\n                    log.error(\\\"NeolaneCustomerLifeEndContractScript : userAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                    continue;\\r\\n                }\\r\\n                BillingAccount billingAccount = userAccount.getBillingAccount();\\r\\n                if (billingAccount == null) {\\r\\n                    log.error(\\\"NeolaneCustomerLifeEndContractScript : billingAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                    continue;\\r\\n                }\\r\\n                CustomerAccount customerAccount = billingAccount.getCustomerAccount();\\r\\n                if (customerAccount == null) {\\r\\n                    log.error(\\\"NeolaneCustomerLifeEndContractScript : customerAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                    continue;\\r\\n                }\\r\\n\\r\\n                SubscriptionRenewal subscriptionRenewal = subscription.getSubscriptionRenewal();\\r\\n                if ( subscriptionRenewal == null) {\\r\\n                    log.error(\\\"NeolaneCustomerLifeEndContractScript : subscription.getSubscriptionRenewal() is null / subscription code = \\\" + subscription.getCode());\\r\\n                    continue;\\r\\n                }\\r\\n\\r\\n                if (subscriptionRenewal.isAutoRenew()) {\\r\\n                    if (isDateAtEndContract_90 || isDateAtEndContract_30 || isDateAtEndContract_00) {\\r\\n\\r\\n                        List<ServiceInstance> listServiceSearchLicence = subscription.getServiceInstances();\\r\\n                        if (listServiceSearchLicence == null) {\\r\\n                            log.error(\\\"NeolaneCustomerLifeEndContractScript : services of subscription is null / subscription code = \\\" + subscription.getCode());\\r\\n                            continue;\\r\\n                        }\\r\\n                        String licence = \\\"\\\";\\r\\n                        String offerType = \\\"FNAC+\\\";\\r\\n                        for (ServiceInstance serviceSearchLicence : listServiceSearchLicence) {\\r\\n                            if (serviceSearchLicence == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLifeEndContractScript : serviceSearchLicence is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n                            if (\\\"SE_FD_LICENCE\\\".equalsIgnoreCase(serviceSearchLicence.getCode())) {\\r\\n                                offerType = \\\"SERENITE\\\";\\r\\n                                licence = (String) cfiService.getInheritedCFValue(serviceSearchLicence, \\\"CF_SE_FD_LICENCE_NUMBER\\\");\\r\\n                            }\\r\\n                        }\\r\\n                        ContactInformation contactInformation = userAccount.getContactInformation();\\r\\n                        if (contactInformation == null) {\\r\\n                            log.error(\\\"NeolaneCustomerLifeEndContractScript : contactInformation is null / subscription code = \\\" + subscription.getCode());\\r\\n                            continue;\\r\\n                        }\\r\\n\\r\\n                        String email = contactInformation.getEmail();\\r\\n                        email = (email == null) ? \\\"\\\" : email;\\r\\n\\r\\n                        String ws_address = email;\\r\\n\\r\\n                        String ws_culture = CULTURE;\\r\\n\\r\\n                        String ws_sendByMail = \\\"true\\\";\\r\\n\\r\\n                        String ws_sendBySMS = \\\"false\\\";\\r\\n\\r\\n                        String cellphone = contactInformation.getMobile();\\r\\n                        if (StringUtils.isBlank(cellphone)) {\\r\\n                            cellphone = \\\"\\\";\\r\\n                        }\\r\\n                        String ws_cellphone = cellphone;\\r\\n\\r\\n                        Calendar expirationDateCalendar = Calendar.getInstance();\\r\\n                        expirationDateCalendar.setTime(nowDate);\\r\\n                        expirationDateCalendar.add(Calendar.HOUR_OF_DAY, 12);\\r\\n                        String ws_expirationDate = DateUtils.formatDateWithPattern(expirationDateCalendar.getTime(), DATE_PATTERN);\\r\\n\\r\\n                        String ws_originalDate = DateUtils.formatDateWithPattern(nowDate, DATE_PATTERN);\\r\\n\\r\\n\\r\\n                        String ws_rcpId = \\\"-2\\\";\\r\\n\\r\\n                        String ws_template = \\\"\\\";\\r\\n                        if (isDateAtEndContract_90) {\\r\\n                            ws_template = \\\"FINTR_OPENCELL_A3M\\\";\\r\\n                        }\\r\\n                        if (isDateAtEndContract_30) {\\r\\n                            ws_template = \\\"FINTR_OPENCELL_A1M\\\";\\r\\n                        }\\r\\n                        if (isDateAtEndContract_00) {\\r\\n                            ws_template = \\\"RENOU_OPENCELL_CNF\\\";\\r\\n                        }\\r\\n\\r\\n                        String ws_enseigne = \\\"\\\";\\r\\n                        boolean enseigneTest = false;\\r\\n                        Seller seller = subscription.getSeller();\\r\\n                        Seller seller_N_1 = null;\\r\\n                        Seller seller_N_2 = null;\\r\\n                        if (seller != null) {\\r\\n                            seller_N_1 = seller.getSeller();\\r\\n                            if (seller_N_1 != null) {\\r\\n                                seller_N_2 = seller_N_1.getSeller();\\r\\n                                if (seller_N_2 != null) {\\r\\n                                    if (seller_N_2.getCode() != null) {\\r\\n                                        enseigneTest = true;\\r\\n                                    }\\r\\n                                }\\r\\n                            }\\r\\n                        }\\r\\n                        if (enseigneTest) {\\r\\n                            ws_enseigne = seller_N_2.getCode();\\r\\n                        } else {\\r\\n                            log.error(\\\"NeolaneCustomerLifeEndContractScript : enseigne is undefined / subscription code = \\\" + subscription.getCode());\\r\\n                            continue;\\r\\n                        }\\r\\n\\r\\n                        boolean nameOk = false;\\r\\n                        Customer customer = null;\\r\\n                        Name name = null;\\r\\n                        Title title = null;\\r\\n                        if (customerAccount != null) {\\r\\n                            customer = customerAccount.getCustomer();\\r\\n                            if (customer != null) {\\r\\n                                name = customer.getName();\\r\\n                                if (name != null) {\\r\\n                                    nameOk = true;\\r\\n                                }\\r\\n                            }\\r\\n                        }\\r\\n\\r\\n                        if (nameOk == false) {\\r\\n                            log.error(\\\"NeolaneCustomerLifeEndContractScript : problem with name / subscription code = \\\" + subscription.getCode());\\r\\n                            continue;\\r\\n                        }\\r\\n                        title = name.getTitle();\\r\\n                        String ws_gender = \\\"\\\";\\r\\n                        if (title != null && title.getCode() != null) {\\r\\n                            ws_gender = title.getCode();\\r\\n                        }\\r\\n\\r\\n                        String ws_firstName = (name.getFirstName() == null) ? \\\"\\\" : name.getFirstName();\\r\\n                        String ws_lastName = (name.getLastName() == null) ? \\\"\\\" : name.getLastName();\\r\\n\\r\\n                        String ws_email = email;\\r\\n\\r\\n                        String ws_contractNumber = subscription.getCode();\\r\\n\\r\\n                        OfferTemplate offer = subscription.getOffer();\\r\\n                        if (offer == null) {\\r\\n                            log.error(\\\"NeolaneCustomerLifeEndContractScript : offer is null / subscription code = \\\" + subscription.getCode());\\r\\n                            continue;\\r\\n                        }\\r\\n                        String ws_offerLabel = (offer.getName() == null) ? \\\"\\\" : offer.getName();\\r\\n\\r\\n\\r\\n                        String ws_contractStatus = \\\"\\\";\\r\\n                        if (subscription.getStatus() == null) {\\r\\n                            log.error(\\\"NeolaneCustomerLifeEndContractScript : subscription.status is null / subscription code = \\\" + subscription.getCode());\\r\\n                            continue;\\r\\n                        }\\r\\n\\r\\n                        switch (subscription.getStatus()) {\\r\\n                            case CREATED:\\r\\n                                ws_contractStatus = SUBSCRIPTION_CREATED;\\r\\n                                break;\\r\\n                            case ACTIVE:\\r\\n                                ws_contractStatus = SUBSCRIPTION_ACTIVE;\\r\\n                                break;\\r\\n                            case CANCELED:\\r\\n                                ws_contractStatus = SUBSCRIPTION_CANCELED;\\r\\n                                break;\\r\\n                            case RESILIATED:\\r\\n                                ws_contractStatus = SUBSCRIPTION_RESILIATED;\\r\\n                                break;\\r\\n                            case CLOSED:\\r\\n                                ws_contractStatus = SUBSCRIPTION_CLOSED;\\r\\n                                break;\\r\\n                            case SUSPENDED:\\r\\n                                ws_contractStatus = SUBSCRIPTION_SUSPENDED;\\r\\n                                break;\\r\\n                            default:\\r\\n                                ws_contractStatus = \\\"\\\";\\r\\n                        }\\r\\n\\r\\n                        String ws_cardNumber = \\\"\\\";\\r\\n                        if (\\\"SERENITE\\\".equals(offerType)) {\\r\\n                            ws_cardNumber = licence;\\r\\n                        } else {\\r\\n                            if (StringUtils.isBlank(cfiService.getInheritedCFValue(subscription, \\\"CF_SU_FD_CARD_NUMBER\\\"))) {\\r\\n                                ws_cardNumber = \\\"\\\";\\r\\n                            } else {\\r\\n                                ws_cardNumber = (String) cfiService.getInheritedCFValue(subscription, \\\"CF_SU_FD_CARD_NUMBER\\\");\\r\\n                            }\\r\\n                        }\\r\\n\\r\\n                        String ws_serenityUrl = \\\"\\\";\\r\\n                        String ws_adhNumber = \\\"\\\";\\r\\n\\r\\n                        final String selfCareUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_SELFCARE_NCLS, true);\\r\\n                        String ws_urlSelfcare = \\\"\\\";\\r\\n                        if (!StringUtils.isBlank(selfCareUrl)) {\\r\\n                            ws_urlSelfcare = selfCareUrl;\\r\\n                        }\\r\\n\\r\\n                        String ws_engagmentEndDate = DateUtils.formatDateWithPattern(subscription.getEndAgreementDate(), DATE_PATTERN_BODY);\\r\\n\\r\\n                        String ws_tryBuyEndDate = \\\"\\\";\\r\\n\\r\\n                        String ws_subAmount = \\\"0\\\";\\r\\n                        if (cfiService.getInheritedCFValue(subscription.getOffer(), \\\"CF_OF_FD_PRICE\\\") != null) {\\r\\n                            ws_subAmount = String.valueOf(cfiService.getInheritedCFValue(subscription.getOffer(), \\\"CF_OF_FD_PRICE\\\"));\\r\\n                        }\\r\\n\\r\\n                        String ws_cbValidityDate = \\\"\\\";\\r\\n\\r\\n                        String ws_paymentMode = \\\"\\\";\\r\\n                        PaymentMethod preferredPaymentMethod = customerAccount.getPreferredPaymentMethod();\\r\\n                        if (preferredPaymentMethod != null) {\\r\\n                            PaymentMethodEnum paymentType = preferredPaymentMethod.getPaymentType();\\r\\n                            if (paymentType != null) {\\r\\n                                if ((PaymentMethodEnum.DIRECTDEBIT == paymentType) || (PaymentMethodEnum.WIRETRANSFER == paymentType)) {\\r\\n                                    ws_paymentMode = \\\"SEPA\\\";\\r\\n                                } else if (PaymentMethodEnum.CARD == paymentType) {\\r\\n                                    ws_paymentMode = \\\"CB\\\";\\r\\n                                }\\r\\n                            }\\r\\n                        }\\r\\n\\r\\n                        String ws_rejectDate = \\\"\\\";\\r\\n                        String ws_rejectedInvoiceNb = \\\"\\\";\\r\\n                        String ws_rejectedAmountTTC = \\\"\\\";\\r\\n                        String ws_reason = \\\"\\\";\\r\\n                        String ws_amountDrawn = \\\"\\\";\\r\\n                        String ws_withdrawalDate = \\\"\\\";\\r\\n\\r\\n                        GenerateInvoiceRequestDto generateInvoiceRequestDto = new GenerateInvoiceRequestDto();\\r\\n\\r\\n                        generateInvoiceRequestDto.setTargetType(\\\"BillingAccount\\\");\\r\\n                        generateInvoiceRequestDto.setTargetCode(billingAccount.getCode());\\r\\n                        generateInvoiceRequestDto.setInvoicingDate(new Date());\\r\\n                        generateInvoiceRequestDto.setLastTransactionDate(DateUtils.addDaysToDate(new Date(), 1));\\r\\n                        generateInvoiceRequestDto.setGenerateXML(false);\\r\\n                        generateInvoiceRequestDto.setGeneratePDF(false);\\r\\n                        generateInvoiceRequestDto.setGenerateAO(false);\\r\\n                        generateInvoiceRequestDto.setIgnoreInvoicingThreshold(true);\\r\\n\\r\\n                        BigDecimal totalDiscount = new BigDecimal(\\\"0\\\");\\r\\n                        try {\\r\\n\\r\\n                            List<Invoice> listInvoice = invoiceService.generateInvoice(billingAccount, generateInvoiceRequestDto, null, true);\\r\\n\\r\\n                            if (listInvoice != null) {\\r\\n\\r\\n                                for (int i = 0; i < listInvoice.size(); i++) {\\r\\n                                    Invoice invoice = (Invoice) (listInvoice.get(i));\\r\\n\\r\\n                                    List<SubCategoryInvoiceAgregate> discountAgregates = invoice.getDiscountAgregates();\\r\\n                                    if (discountAgregates != null) {\\r\\n                                        for (int j = 0; j < discountAgregates.size(); j++) {\\r\\n                                            SubCategoryInvoiceAgregate subCategoryInvoiceAgregate = discountAgregates.get(j);\\r\\n                                            totalDiscount.add(subCategoryInvoiceAgregate.getAmountWithoutTax());\\r\\n                                        }\\r\\n                                    }\\r\\n                                }\\r\\n                            }\\r\\n\\r\\n                            if (listInvoice != null) {\\r\\n                                for (Invoice invoice : listInvoice) {\\r\\n                                    invoiceService.cancelInvoice(invoice);\\r\\n                                    invoiceService.commit();\\r\\n                                }\\r\\n                            }\\r\\n\\r\\n                        } catch (InvoiceExistException e) {\\r\\n                            log.error(\\\"In NeolaneCustomerLifeEndContractScript InvoiceExistException = \\\" + e);\\r\\n                        } catch (ImportInvoiceException e) {\\r\\n                            log.error(\\\"In NeolaneCustomerLifeEndContractScript ImportInvoiceException = \\\" + e);\\r\\n                        }\\r\\n\\r\\n                        if (!\\\"0\\\".equals(ws_subAmount)) {\\r\\n                            BigDecimal ws_subAmountValue = new BigDecimal(ws_subAmount);\\r\\n                            ws_subAmountValue.add(totalDiscount);\\r\\n                            ws_amountDrawn = (ws_subAmountValue.setScale(2, RoundingMode.DOWN)).toString();\\r\\n                            Date withdrawalDate = billingAccount.getNextInvoiceDate();\\r\\n                            ws_withdrawalDate = DateUtils.formatDateWithPattern(withdrawalDate, DATE_PATTERN_BODY);\\r\\n                        }\\r\\n\\r\\n                        String ws_oneTimeCBPaymentDate = \\\"\\\";\\r\\n                        String ws_oneTimePaymentAmount = \\\"\\\";\\r\\n                        String ws_refundDate = \\\"\\\";\\r\\n                        String ws_refundAmount = \\\"\\\";\\r\\n                        String ws_discountEntryDate = \\\"\\\";\\r\\n                        String ws_discountAmount = \\\"\\\";\\r\\n                        String ws_transacAutorisationNb = \\\"\\\";\\r\\n                        String ws_rum = \\\"\\\";\\r\\n                        String ws_ics = \\\"\\\";\\r\\n                        String ws_legalEntityName = \\\"\\\";\\r\\n                        String ws_activationDate = \\\"\\\";\\r\\n                        String ws_rterminationDate = \\\"\\\";\\r\\n                        String ws_terminationReason = \\\"\\\";\\r\\n                        String ws_trActivationDate = \\\"\\\";\\r\\n\\r\\n                        if (isDateAtEndContract_90 || isDateAtEndContract_30 ) {\\r\\n                            ws_trActivationDate = DateUtils.formatDateWithPattern(subscriptionRenewal.getAutoRenewDate(), DATE_PATTERN_BODY);\\r\\n                        }\\r\\n                        String ws_trDeactivationDate = \\\"\\\";\\r\\n\\r\\n                        String soapEnvBody =\\r\\n\\r\\n                                \\\"<urn:Submit><urn:sessiontoken></urn:sessiontoken><urn:elemCtx><ctx \\\" + \\\" address=\\\\\\\"\\\" + ws_address + \\\"\\\\\\\"\\\" + \\\" culture=\\\\\\\"\\\" + ws_culture + \\\"\\\\\\\"\\\" + \\\" sendByMail=\\\\\\\"\\\" + ws_sendByMail + \\\"\\\\\\\"\\\" + \\\" sendBySMS=\\\\\\\"\\\" + ws_sendBySMS + \\\"\\\\\\\"\\\" + \\\" cellphone=\\\\\\\"\\\" + ws_cellphone + \\\"\\\\\\\"\\\"\\r\\n                                        + \\\" expirationDate=\\\\\\\"\\\" + ws_expirationDate + \\\"\\\\\\\"\\\" + \\\" originalDate=\\\\\\\"\\\" + ws_originalDate + \\\"\\\\\\\"\\\" + \\\" rcpId=\\\\\\\"\\\" + ws_rcpId + \\\"\\\\\\\"\\\" + \\\" template=\\\\\\\"\\\" + ws_template + \\\"\\\\\\\"\\\"\\r\\n                                        + \\\" xmlns=\\\\\\\"\\\\\\\">\\\" + \\\"<CUSTOMER> \\\" + \\\"<Enseigne>\\\" + ws_enseigne + \\\"</Enseigne>\\\" + \\\"<Gender>\\\" + ws_gender + \\\"</Gender>\\\" + \\\"<FirstName>\\\" + ws_firstName + \\\"</FirstName>\\\" + \\\"<LastName>\\\" + ws_lastName + \\\"</LastName>\\\" + \\\"<Email>\\\" + ws_email\\r\\n                                        + \\\"</Email>\\\" + \\\"<SendBySMS>\\\" + ws_sendBySMS + \\\"</SendBySMS>\\\" + \\\"<sendByMail>\\\" + ws_sendByMail + \\\"</sendByMail>\\\" + \\\"<ContractNumber>\\\" + ws_contractNumber + \\\"</ContractNumber>\\\"\\r\\n                                        + \\\"<offerLabel>\\\" + ws_offerLabel + \\\"</offerLabel>\\\" + \\\"<ContractStatus>\\\" + ws_contractStatus + \\\"</ContractStatus>\\\" + \\\"<CardNumber>\\\" + ws_cardNumber + \\\"</CardNumber>\\\" + \\\"<AdhNumber>\\\" + ws_adhNumber + \\\"</AdhNumber>\\\" + \\\"<SelfCareUrl>\\\"\\r\\n                                        + ws_urlSelfcare + \\\"</SelfCareUrl>\\\" + \\\"<SerenityUrl>\\\" + ws_serenityUrl + \\\"</SerenityUrl>\\\" + \\\"<EngagmentEndDate>\\\" + ws_engagmentEndDate + \\\"</EngagmentEndDate>\\\" + \\\"<TryBuyEndDate>\\\"\\r\\n                                        + ws_tryBuyEndDate + \\\"</TryBuyEndDate>\\\" + \\\"<SubAmount>\\\" + ws_subAmount + \\\"</SubAmount>\\\" + \\\"</CUSTOMER> \\\" + \\\"<INVOICE> \\\" + \\\"<CBValidityDate>\\\" + ws_cbValidityDate + \\\"</CBValidityDate>\\\" + \\\"<PaymentMode>\\\" + ws_paymentMode\\r\\n                                        + \\\"</PaymentMode>\\\" + \\\"<RejectDate>\\\" + ws_rejectDate + \\\"</RejectDate>\\\" + \\\"<RejectedInvoiceNb>\\\" + ws_rejectedInvoiceNb + \\\"</RejectedInvoiceNb>\\\" + \\\"<RejectedAmountTTC>\\\" + ws_rejectedAmountTTC\\r\\n                                        + \\\"</RejectedAmountTTC>\\\" + \\\"<Reason>\\\" + ws_reason + \\\"</Reason>\\\" + \\\"<AmountDrawn>\\\" + ws_amountDrawn + \\\"</AmountDrawn>\\\" + \\\"<WithdrawalDate>\\\" + ws_withdrawalDate + \\\"</WithdrawalDate>\\\"\\r\\n                                        + \\\"<OneTimeCBPaymentDate>\\\" + ws_oneTimeCBPaymentDate + \\\"</OneTimeCBPaymentDate>\\\" + \\\"<OneTimePaymentAmount>\\\" + ws_oneTimePaymentAmount + \\\"</OneTimePaymentAmount>\\\" + \\\"<RefundDate>\\\" + ws_refundDate + \\\"</RefundDate>\\\"\\r\\n                                        + \\\"<RefundAmount>\\\" + ws_refundAmount + \\\"</RefundAmount>\\\" + \\\"<DiscountEntryDate>\\\" + ws_discountEntryDate + \\\"</DiscountEntryDate>\\\" + \\\"<DiscountAmount>\\\" + ws_discountAmount + \\\"</DiscountAmount>\\\"\\r\\n                                        + \\\"<TransacAutorisationNb>\\\" + ws_transacAutorisationNb + \\\"</TransacAutorisationNb>\\\" + \\\"<Rum>\\\" + ws_rum + \\\"</Rum>\\\" + \\\"<Ics>\\\" + ws_ics + \\\"</Ics>\\\" + \\\"<LegalEntityName>\\\" + ws_legalEntityName\\r\\n                                        + \\\"</LegalEntityName>\\\" + \\\"</INVOICE>\\\" + \\\"<TERMINATION>\\\" + \\\"<ActivationDate>\\\" + ws_activationDate + \\\"</ActivationDate>\\\" + \\\"<TerminationDate>\\\" + ws_rterminationDate + \\\"</TerminationDate>\\\" + \\\"<TerminationReason>\\\"\\r\\n                                        + ws_terminationReason + \\\"</TerminationReason>\\\" + \\\"</TERMINATION>\\\" + \\\"<TACITRENEWAL>\\\" + \\\"<TrActivationDate>\\\" + ws_trActivationDate + \\\"</TrActivationDate>\\\" + \\\"<TrDeactivationDate>\\\" + ws_trDeactivationDate\\r\\n                                        + \\\"</TrDeactivationDate>\\\" + \\\"</TACITRENEWAL>\\\" + \\\"</ctx></urn:elemCtx></urn:Submit>\\\";\\r\\n\\r\\n                        String response = callWebService(soapEnvBody);\\r\\n\\r\\n                        log.info(\\\"response = \\\" + response);\\r\\n                        log.info(\\\"soapEnvBody = \\\" + soapEnvBody);\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n        }\\r\\n    }\\r\\n}\",\n    \"executionRoles\": [],\n    \"sourcingRoles\": []\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/scriptInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"scriptInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLifeFirstRejectScript",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										},
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"org.meveo.service.script.NeolaneCustomerLifeFirstRejectScript\",\n    \"description\": \"NeolaneCustomerLifeFirstReject Script\",\n    \"type\": \"JAVA\",\n    \"script\": \"package org.meveo.service.script;\\r\\n\\r\\nimport org.apache.http.HttpResponse;\\r\\nimport org.apache.http.StatusLine;\\r\\nimport org.apache.http.client.methods.HttpPost;\\r\\nimport org.apache.http.conn.ssl.NoopHostnameVerifier;\\r\\nimport org.apache.http.conn.ssl.SSLContextBuilder;\\r\\nimport org.apache.http.conn.ssl.TrustStrategy;\\r\\nimport org.apache.http.entity.StringEntity;\\r\\nimport org.apache.http.impl.client.CloseableHttpClient;\\r\\nimport org.apache.http.impl.client.HttpClients;\\r\\nimport org.meveo.admin.exception.BusinessException;\\r\\nimport org.meveo.admin.exception.ImportInvoiceException;\\r\\nimport org.meveo.admin.exception.InvoiceExistException;\\r\\nimport org.meveo.api.dto.invoice.GenerateInvoiceRequestDto;\\r\\nimport org.meveo.commons.utils.StringUtils;\\r\\nimport org.meveo.model.ICustomFieldEntity;\\r\\nimport org.meveo.model.billing.BillingAccount;\\r\\nimport org.meveo.model.billing.Invoice;\\r\\nimport org.meveo.model.billing.SubCategoryInvoiceAgregate;\\r\\nimport org.meveo.model.billing.Subscription;\\r\\nimport org.meveo.model.billing.UserAccount;\\r\\nimport org.meveo.model.catalog.OfferTemplate;\\r\\nimport org.meveo.model.crm.Customer;\\r\\nimport org.meveo.model.crm.Provider;\\r\\nimport org.meveo.model.jobs.JobInstance;\\r\\nimport org.meveo.model.payments.AccountOperation;\\r\\nimport org.meveo.model.payments.CardPaymentMethod;\\r\\nimport org.meveo.model.payments.CustomerAccount;\\r\\nimport org.meveo.model.payments.PaymentMethod;\\r\\nimport org.meveo.model.payments.PaymentMethodEnum;\\r\\nimport org.meveo.model.payments.RejectedPayment;\\r\\nimport org.meveo.model.shared.ContactInformation;\\r\\nimport org.meveo.model.shared.DateUtils;\\r\\nimport org.meveo.model.shared.Name;\\r\\nimport org.meveo.model.shared.Title;\\r\\nimport org.meveo.service.billing.impl.InvoiceService;\\r\\nimport org.meveo.service.billing.impl.SubscriptionService;\\r\\nimport org.meveo.service.crm.impl.CustomFieldInstanceService;\\r\\nimport org.meveo.service.crm.impl.ProviderService;\\r\\nimport org.meveo.service.payments.impl.AccountOperationService;\\r\\n\\r\\nimport java.io.IOException;\\r\\nimport java.math.BigDecimal;\\r\\nimport java.math.RoundingMode;\\r\\nimport java.security.cert.CertificateException;\\r\\nimport java.security.cert.X509Certificate;\\r\\nimport java.util.Calendar;\\r\\nimport java.util.Date;\\r\\nimport java.util.HashMap;\\r\\nimport java.util.List;\\r\\nimport java.util.Map;\\r\\n\\r\\n/**\\r\\n * Appel le web service Neolane\\r\\n *    Relance g\\u00E9n\\u00E9rique 1er rejet sur clients actifs / r\\u00E9sili\\u00E9s\\r\\n *\\r\\n * @author Mounir Bahije\\r\\n */\\r\\npublic class NeolaneCustomerLifeFirstRejectScript extends Script {\\r\\n\\r\\n    private CustomFieldInstanceService cfiService = (CustomFieldInstanceService) getServiceInterface(\\\"CustomFieldInstanceService\\\");\\r\\n    private ProviderService providerService = (ProviderService) getServiceInterface(ProviderService.class.getSimpleName());\\r\\n    private Provider appProvider = providerService.getProvider();\\r\\n    private InvoiceService invoiceService = (InvoiceService) getServiceInterface(\\\"InvoiceService\\\");\\r\\n    private SubscriptionService subscriptionService = (SubscriptionService) getServiceInterface(\\\"SubscriptionService\\\");\\r\\n    private AccountOperationService accountOperationService = (AccountOperationService) getServiceInterface(\\\"AccountOperationService\\\");\\r\\n    private JobInstance job = null;\\r\\n\\r\\n    private static final String CULTURE = \\\"fr-FR\\\";\\r\\n    private static final String DATE_PATTERN = \\\"yyyy/MM/dd HH:mm:ss\\\";\\r\\n    private static final String DATE_PATTERN_BODY = \\\"dd/MM/yyyy\\\";\\r\\n    private static final String DATE_PATTERN_CB = \\\"MM/yy\\\";\\r\\n\\r\\n    private static final String CF_FD_URL_WS_NCLS = \\\"CF_FD_URL_WS_NCLS\\\";\\r\\n    private static final String CF_FD_ACTION_URI_WS_NCLS = \\\"CF_FD_ACTION_URI_WS_NCLS\\\";\\r\\n    private static final String CF_FD_URL_SELFCARE_NCLS = \\\"CF_FD_URL_SELFCARE_NCLS\\\";\\r\\n\\r\\n    private static final String SUBSCRIPTION_CREATED = \\\"0\\\";\\r\\n    private static final String SUBSCRIPTION_ACTIVE = \\\"1\\\";\\r\\n    private static final String SUBSCRIPTION_SUSPENDED = \\\"2\\\";\\r\\n    private static final String SUBSCRIPTION_RESILIATED = \\\"3\\\";\\r\\n    private static final String SUBSCRIPTION_CANCELED = \\\"4\\\";\\r\\n    private static final String SUBSCRIPTION_CLOSED = \\\"5\\\";\\r\\n\\r\\n    private static final String PAYMENT_MODE_CB = \\\"CB\\\";\\r\\n    private static final String PAYMENT_MODE_SEPA = \\\"SEPA\\\";\\r\\n\\r\\n    @Override\\r\\n    public void execute(Map<String, Object> methodContext) throws BusinessException {\\r\\n\\r\\n        Date fromDate = null;\\r\\n        Date toDate = null;\\r\\n\\r\\n        job = (JobInstance) methodContext.get(Script.CONTEXT_ENTITY);\\r\\n\\r\\n        Long bulkTreatmentStart = (Long) job.getCfValue(\\\"REJECT_BULK_START\\\");\\r\\n        Long bulkTreatmentEnd = (Long) job.getCfValue(\\\"REJECT_BULK_END\\\");\\r\\n\\r\\n        Date bulkTreatmentStartDate = getBulkTreatmentDate(bulkTreatmentStart);\\r\\n        Date bulkTreatmentEndDate = getBulkTreatmentDate(bulkTreatmentEnd);\\r\\n\\r\\n        if (bulkTreatmentStartDate == null){\\r\\n            return;\\r\\n        }\\r\\n\\r\\n        fromDate = bulkTreatmentStartDate;\\r\\n        if (bulkTreatmentEndDate == null){\\r\\n            toDate = DateUtils.addDaysToDate(bulkTreatmentStartDate, 1);\\r\\n        } else {\\r\\n            toDate = DateUtils.addDaysToDate(bulkTreatmentEndDate, 1);\\r\\n        }\\r\\n\\r\\n        String queryStr = \\\"Select ao from AccountOperation as ao  where ao.rejectedDate >= :fromDate and ao.rejectedDate < :toDate and  \\\" + \\\"ao.occCode = :occCode1 or ao.occCode =:occCode2 ORDER BY ao.rejectedDate DESC\\\";\\r\\n        Map<String, Object> params = new HashMap<String, Object>();\\r\\n        params.put(\\\"fromDate\\\", fromDate);\\r\\n        params.put(\\\"toDate\\\", toDate);\\r\\n        params.put(\\\"occCode1\\\", \\\"REJ_CRD\\\");\\r\\n        params.put(\\\"occCode2\\\", \\\"REJ_DDT\\\");\\r\\n        List<AccountOperation> listAO = (List<AccountOperation>) accountOperationService.executeSelectQuery(queryStr.toString(), params);\\r\\n\\r\\n        Map<String, Long> mapSubscriptionAO = new HashMap<String, Long>();\\r\\n        for (AccountOperation accountOperation : listAO) {\\r\\n            Subscription subscriptionI = getSubFromAo(accountOperation);\\r\\n            if (subscriptionI != null) {\\r\\n                mapSubscriptionAO.put(subscriptionI.getCode(), Long.valueOf(accountOperation.getId()));\\r\\n            }\\r\\n        }\\r\\n\\r\\n        setWSData(mapSubscriptionAO);\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * fetch CF Config Value\\r\\n     *\\r\\n     * @param entity\\r\\n     * @param cfKey\\r\\n     * @param isMandatory\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private Object fetchCFConfigValue(ICustomFieldEntity entity, String cfKey, boolean isMandatory) throws BusinessException {\\r\\n        Object cfValue = cfiService.getCFValue(entity, cfKey);\\r\\n        if (isMandatory && (cfValue == null || (cfValue instanceof String && org.apache.commons.lang3.StringUtils.isEmpty(String.valueOf(cfValue))))) {\\r\\n            throw new BusinessException(\\\" Missing mandatory config [\\\" + cfKey + \\\"]\\\");\\r\\n        }\\r\\n        return cfValue;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Call Neolane WS\\r\\n     *\\r\\n     * @param soapEnvBody\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private String callWebService(String soapEnvBody) throws BusinessException {\\r\\n\\r\\n        String body =\\r\\n                \\\"<?xml version=\\\\\\\"1.0\\\\\\\" encoding=\\\\\\\"UTF-8\\\\\\\"?><soapenv:Envelope xmlns:soapenv=\\\\\\\"http://schemas.xmlsoap.org/soap/envelope/\\\\\\\" \\\" +\\r\\n                        \\\"xmlns:urn=\\\\\\\"urn:nms:rtMsg\\\\\\\"><soapenv:Header/><soapenv:Body>\\\"\\r\\n                        + soapEnvBody + \\\"</soapenv:Body></soapenv:Envelope>\\\";\\r\\n\\r\\n        StringEntity stringEntity = new StringEntity(body, \\\"UTF-8\\\");\\r\\n\\r\\n        final String wsUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_WS_NCLS, true);\\r\\n        final String actionUri = (String) this.fetchCFConfigValue(appProvider, CF_FD_ACTION_URI_WS_NCLS, true);\\r\\n\\r\\n        // Request parameters and other properties.\\r\\n        HttpPost httpPost = new HttpPost(wsUrl);\\r\\n        httpPost.setEntity(stringEntity);\\r\\n        httpPost.setHeader(\\\"SOAPAction\\\", actionUri);\\r\\n\\r\\n        // Execute and get the response.\\r\\n        CloseableHttpClient httpClient = getCloseableHttpClient();\\r\\n\\r\\n        HttpResponse response = null;\\r\\n        try {\\r\\n\\r\\n            log.info(\\\"we want to sent to this address = \\\" + actionUri);\\r\\n            log.info(\\\"This body = \\\" + body);\\r\\n\\r\\n            response = httpClient.execute(httpPost);\\r\\n            boolean responseOk = false;\\r\\n            if (response != null) {\\r\\n                StatusLine statusLine = response.getStatusLine();\\r\\n                if (statusLine != null) {\\r\\n                    int statusCode = statusLine.getStatusCode();\\r\\n                    if (statusCode == 200) {\\r\\n                        responseOk = true;\\r\\n                        log.info(\\\"body sent and it's Ok\\\");\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n            if (responseOk) {\\r\\n                log.info(\\\"In NeolaneCustomerLifeFirstRejectScript : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                return \\\"OK\\\";\\r\\n            } else {\\r\\n                log.error(\\\"In NeolaneCustomerLifeFirstRejectScript : Status Code of response is not 200 \\\");\\r\\n                return \\\"KO\\\";\\r\\n            }\\r\\n\\r\\n        } catch (IOException e) {\\r\\n            log.error(\\\"Exception in EndSubscriptionScript :\\\", e);\\r\\n        }\\r\\n        return \\\"KO\\\";\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * get CloseableHttpClient\\r\\n     *\\r\\n     * @return trusted httpClient\\r\\n     */\\r\\n    public CloseableHttpClient getCloseableHttpClient() {\\r\\n        CloseableHttpClient httpClient = null;\\r\\n        try {\\r\\n            httpClient = HttpClients.custom().\\r\\n                    setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).\\r\\n                    setSSLContext(new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {\\r\\n                        public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {\\r\\n                            return true;\\r\\n                        }\\r\\n                    }).build()).build();\\r\\n        } catch (Exception e) {\\r\\n            log.error(\\\"KeyManagementException in creating http client instance\\\", e);\\r\\n        }\\r\\n        return httpClient;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * get Subscription From AO\\r\\n     *\\r\\n     * @param ao\\r\\n     * @return\\r\\n     */\\r\\n    private Subscription getSubFromAo(AccountOperation ao) {\\r\\n        if (ao != null) {\\r\\n            if (ao.getCustomerAccount() != null && ao.getCustomerAccount().getBillingAccounts() != null && !ao.getCustomerAccount().getBillingAccounts().isEmpty()) {\\r\\n                BillingAccount ba = ao.getCustomerAccount().getBillingAccounts().get(0);\\r\\n                if (ba != null && ba.getUsersAccounts() != null && !ba.getUsersAccounts().isEmpty()) {\\r\\n                    UserAccount ua = ba.getUsersAccounts().get(0);\\r\\n                    if (ua != null && ua.getSubscriptions() != null && !ua.getSubscriptions().isEmpty()) {\\r\\n                        return ua.getSubscriptions().get(0);\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n        }\\r\\n        return null;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     *  get Bulk Treatment Date\\r\\n     *\\r\\n     * @param bulkTreatment\\r\\n     * @return\\r\\n     */\\r\\n    private Date getBulkTreatmentDate(Long bulkTreatment) {\\r\\n\\r\\n        Integer dayIndex = null;\\r\\n        Date bulkTreatmentDate = null;\\r\\n\\r\\n        if (bulkTreatment != null) {\\r\\n            dayIndex = bulkTreatment.intValue();\\r\\n        } else {\\r\\n            return bulkTreatmentDate;\\r\\n        }\\r\\n\\r\\n        Calendar bulkTreatmentCal = Calendar.getInstance();\\r\\n        bulkTreatmentCal.set(Calendar.HOUR_OF_DAY, 0);\\r\\n        bulkTreatmentCal.set(Calendar.MINUTE, 0);\\r\\n        bulkTreatmentCal.set(Calendar.SECOND, 0);\\r\\n        bulkTreatmentDate = bulkTreatmentCal.getTime();\\r\\n\\r\\n        bulkTreatmentDate = DateUtils.setDayToDate(bulkTreatmentDate, dayIndex);\\r\\n        return bulkTreatmentDate;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Set Data for Neolane WS\\r\\n     *\\r\\n     * @param mapSubscriptionAO the map of (subscriptionCode , firstRejectId)\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private void setWSData(Map<String, Long> mapSubscriptionAO) throws BusinessException {\\r\\n\\r\\n        Date nowDate = new Date();\\r\\n\\r\\n        for (Map.Entry<String, Long> entry : mapSubscriptionAO.entrySet()) {\\r\\n\\r\\n            String subscriptionCode = entry.getKey();\\r\\n            Long accountOperationId = entry.getValue();\\r\\n\\r\\n            String ws_rejectDate = \\\"\\\";\\r\\n            String ws_rejectedInvoiceNb = \\\"\\\";\\r\\n            String ws_rejectedAmountTTC = \\\"\\\";\\r\\n            String ws_reason = \\\"\\\";\\r\\n\\r\\n            Subscription subscription = subscriptionService.findByCode(subscriptionCode);\\r\\n            AccountOperation accountOperation = accountOperationService.findById(accountOperationId);\\r\\n            if (subscription == null || accountOperation == null) {\\r\\n                continue;\\r\\n            }\\r\\n\\r\\n            RejectedPayment rejectedPayment = (RejectedPayment) accountOperation;\\r\\n            Date rejectedDate = rejectedPayment.getRejectedDate();\\r\\n            ws_rejectDate = DateUtils.formatDateWithPattern(rejectedDate, DATE_PATTERN_BODY);\\r\\n\\r\\n            Invoice invoice = null;\\r\\n            List<Invoice> invoices = rejectedPayment.getInvoices();\\r\\n            if (invoices != null) {\\r\\n                invoice = invoices.get(0);\\r\\n            }\\r\\n            if (invoice != null) {\\r\\n                ws_rejectedInvoiceNb = invoice.getInvoiceNumber();\\r\\n                BigDecimal invoiceAmountWithTax = invoice.getAmountWithTax();\\r\\n                if (invoiceAmountWithTax != null) {\\r\\n                    ws_rejectedAmountTTC = (invoiceAmountWithTax.setScale(2, RoundingMode.DOWN)).toString();\\r\\n\\r\\n                }\\r\\n            }\\r\\n            ws_reason = rejectedPayment.getRejectedCode();\\r\\n\\r\\n            UserAccount userAccount = subscription.getUserAccount();\\r\\n            if (userAccount == null) {\\r\\n                log.error(\\\"NeolaneCustomerLifeFirstRejectScript : userAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                continue;\\r\\n            }\\r\\n            BillingAccount billingAccount = userAccount.getBillingAccount();\\r\\n            if (billingAccount == null) {\\r\\n                log.error(\\\"NeolaneCustomerLifeFirstRejectScript : billingAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                continue;\\r\\n            }\\r\\n            CustomerAccount customerAccount = billingAccount.getCustomerAccount();\\r\\n            if (customerAccount == null) {\\r\\n                log.error(\\\"NeolaneCustomerLifeFirstRejectScript : customerAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                continue;\\r\\n            }\\r\\n\\r\\n            String ws_paymentMode = \\\"\\\";\\r\\n            String ws_cbValidityDate = \\\"\\\";\\r\\n            PaymentMethod preferredPaymentMethod = customerAccount.getPreferredPaymentMethod();\\r\\n            if (preferredPaymentMethod != null) {\\r\\n                PaymentMethodEnum paymentType = preferredPaymentMethod.getPaymentType();\\r\\n                if (paymentType != null) {\\r\\n                    if ((PaymentMethodEnum.DIRECTDEBIT == paymentType) || (PaymentMethodEnum.WIRETRANSFER == paymentType)) {\\r\\n                        ws_paymentMode = PAYMENT_MODE_SEPA;\\r\\n                    } else if (PaymentMethodEnum.CARD == paymentType) {\\r\\n                        ws_paymentMode = PAYMENT_MODE_CB;\\r\\n                        String cbExpirationDateStr = ((CardPaymentMethod) preferredPaymentMethod).getExpirationMonthAndYear();\\r\\n                        Date cbExpirationDate = DateUtils.parseDateWithPattern(cbExpirationDateStr, DATE_PATTERN_CB);\\r\\n                        ws_cbValidityDate = DateUtils.formatDateWithPattern(cbExpirationDate, DATE_PATTERN_BODY);\\r\\n\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n\\r\\n            ContactInformation contactInformation = userAccount.getContactInformation();\\r\\n            if (contactInformation == null) {\\r\\n                log.error(\\\"NeolaneCustomerLifeFirstRejectScript : contactInformation is null / subscription code = \\\" + subscription.getCode());\\r\\n                continue;\\r\\n            }\\r\\n\\r\\n            String email = contactInformation.getEmail();\\r\\n            email = (email == null) ? \\\"\\\" : email;\\r\\n\\r\\n            String ws_address = email;\\r\\n            String ws_culture = CULTURE;\\r\\n            String ws_sendByMail = \\\"true\\\";\\r\\n            String ws_sendBySMS = \\\"true\\\";\\r\\n            String cellphone = contactInformation.getMobile();\\r\\n            if (StringUtils.isBlank(cellphone)) {\\r\\n                cellphone = \\\"\\\";\\r\\n            }\\r\\n            String ws_cellphone = cellphone;\\r\\n\\r\\n            Calendar expirationDateCalendar = Calendar.getInstance();\\r\\n            expirationDateCalendar.setTime(nowDate);\\r\\n            expirationDateCalendar.add(Calendar.HOUR_OF_DAY, 12);\\r\\n            String ws_expirationDate = DateUtils.formatDateWithPattern(expirationDateCalendar.getTime(), DATE_PATTERN);\\r\\n\\r\\n            String ws_originalDate = DateUtils.formatDateWithPattern(nowDate, DATE_PATTERN);\\r\\n\\r\\n            String ws_rcpId = \\\"-2\\\";\\r\\n            String ws_template = \\\"RELAN_OPENCELL_IMP\\\";\\r\\n            String ws_enseigne = \\\"\\\";\\r\\n\\r\\n            boolean nameOk = false;\\r\\n            Customer customer = customerAccount.getCustomer();\\r\\n            Name name = null;\\r\\n            Title title = null;\\r\\n            if (customer != null && customer.getName() != null) {\\r\\n                name = customer.getName();\\r\\n                nameOk = true;\\r\\n            }\\r\\n\\r\\n            if (nameOk == false) {\\r\\n                log.error(\\\"NeolaneCustomerLifeFirstRejectScript : problem with name / subscription code = \\\" + subscription.getCode());\\r\\n                continue;\\r\\n            }\\r\\n            title = name.getTitle();\\r\\n            String ws_gender = \\\"\\\";\\r\\n            if (title != null && title.getCode() != null) {\\r\\n                ws_gender = title.getCode();\\r\\n            }\\r\\n            String ws_firstName = (name.getFirstName() == null) ? \\\"\\\" : name.getFirstName();\\r\\n            String ws_lastName = (name.getLastName() == null) ? \\\"\\\" : name.getLastName();\\r\\n            String ws_email = email;\\r\\n            String ws_contractNumber = subscription.getCode();\\r\\n            OfferTemplate offer = subscription.getOffer();\\r\\n            if (offer == null) {\\r\\n                log.error(\\\"NeolaneCustomerLifeFirstRejectScript : offer is null / subscription code = \\\" + subscription.getCode());\\r\\n                continue;\\r\\n            }\\r\\n            String ws_offerLabel = (offer.getName() == null) ? \\\"\\\" : offer.getName();\\r\\n            String ws_contractStatus = \\\"\\\";\\r\\n            if (subscription.getStatus() == null) {\\r\\n                log.error(\\\"NeolaneCustomerLifeFirstRejectScript : subscription.status is null / subscription code = \\\" + subscription.getCode());\\r\\n                continue;\\r\\n            }\\r\\n            switch (subscription.getStatus()) {\\r\\n                case CREATED:\\r\\n                    ws_contractStatus = SUBSCRIPTION_CREATED;\\r\\n                    break;\\r\\n                case ACTIVE:\\r\\n                    ws_contractStatus = SUBSCRIPTION_ACTIVE;\\r\\n                    break;\\r\\n                case CANCELED:\\r\\n                    ws_contractStatus = SUBSCRIPTION_CANCELED;\\r\\n                    break;\\r\\n                case RESILIATED:\\r\\n                    ws_contractStatus = SUBSCRIPTION_RESILIATED;\\r\\n                    break;\\r\\n                case CLOSED:\\r\\n                    ws_contractStatus = SUBSCRIPTION_CLOSED;\\r\\n                    break;\\r\\n                case SUSPENDED:\\r\\n                    ws_contractStatus = SUBSCRIPTION_SUSPENDED;\\r\\n                    break;\\r\\n                default:\\r\\n                    ws_contractStatus = \\\"\\\";\\r\\n            }\\r\\n\\r\\n            String ws_cardNumber = \\\"\\\";\\r\\n            String ws_serenityUrl = \\\"\\\";\\r\\n            String ws_adhNumber = \\\"\\\";\\r\\n\\r\\n            final String selfCareUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_SELFCARE_NCLS, true);\\r\\n            String ws_urlSelfcare = \\\"\\\";\\r\\n            if (!StringUtils.isBlank(selfCareUrl)) {\\r\\n                ws_urlSelfcare = selfCareUrl;\\r\\n            }\\r\\n\\r\\n            String ws_engagmentEndDate = \\\"\\\";\\r\\n\\r\\n            String ws_tryBuyEndDate = \\\"\\\";\\r\\n\\r\\n            String ws_subAmount = \\\"\\\";\\r\\n\\r\\n            String ws_amountDrawn = \\\"\\\";\\r\\n            String ws_withdrawalDate = \\\"\\\";\\r\\n\\r\\n            GenerateInvoiceRequestDto generateInvoiceRequestDto = new GenerateInvoiceRequestDto();\\r\\n\\r\\n            generateInvoiceRequestDto.setTargetType(\\\"BillingAccount\\\");\\r\\n            generateInvoiceRequestDto.setTargetCode(billingAccount.getCode());\\r\\n            generateInvoiceRequestDto.setInvoicingDate(new Date());\\r\\n            generateInvoiceRequestDto.setLastTransactionDate(DateUtils.addDaysToDate(new Date(), 1));\\r\\n            generateInvoiceRequestDto.setGenerateXML(false);\\r\\n            generateInvoiceRequestDto.setGeneratePDF(false);\\r\\n            generateInvoiceRequestDto.setGenerateAO(false);\\r\\n            generateInvoiceRequestDto.setIgnoreInvoicingThreshold(true);\\r\\n\\r\\n            BigDecimal totalDiscount = new BigDecimal(\\\"0\\\");\\r\\n            try {\\r\\n\\r\\n                List<Invoice> listInvoice = invoiceService.generateInvoice(billingAccount, generateInvoiceRequestDto, null, true);\\r\\n\\r\\n                if (listInvoice != null) {\\r\\n                    for (Invoice invoice_i :listInvoice) {\\r\\n                        if (invoice_i != null) {\\r\\n                            List<SubCategoryInvoiceAgregate> discountAgregates = invoice_i.getDiscountAgregates();\\r\\n                            if (discountAgregates != null) {\\r\\n                                for (SubCategoryInvoiceAgregate subCategoryInvoiceAgregate : discountAgregates) {\\r\\n                                    if (subCategoryInvoiceAgregate != null) {\\r\\n                                        totalDiscount.add(subCategoryInvoiceAgregate.getAmountWithoutTax());\\r\\n                                    }\\r\\n                                }\\r\\n                            }\\r\\n                        }\\r\\n                    }\\r\\n\\r\\n                    for (Invoice invoice_i : listInvoice) {\\r\\n                        invoiceService.cancelInvoice(invoice_i);\\r\\n                        invoiceService.commit();\\r\\n                    }\\r\\n                }\\r\\n            } catch (InvoiceExistException e) {\\r\\n                log.error(\\\"In NeolaneCustomerLifeFirstRejectScript InvoiceExistException = \\\" + e);\\r\\n            } catch (ImportInvoiceException e) {\\r\\n                log.error(\\\"In NeolaneCustomerLifeFirstRejectScript ImportInvoiceException = \\\" + e);\\r\\n            }\\r\\n\\r\\n            String subAmount = \\\"0\\\";\\r\\n            if (cfiService.getInheritedCFValue(subscription.getOffer(), \\\"CF_OF_FD_PRICE\\\") != null) {\\r\\n                subAmount = String.valueOf(cfiService.getInheritedCFValue(subscription.getOffer(), \\\"CF_OF_FD_PRICE\\\"));\\r\\n            }\\r\\n\\r\\n            if (!\\\"0\\\".equals(subAmount)) {\\r\\n                BigDecimal subAmountValue = new BigDecimal(subAmount);\\r\\n                subAmountValue.add(totalDiscount);\\r\\n                ws_amountDrawn = (subAmountValue.setScale(2, RoundingMode.DOWN)).toString();\\r\\n                ws_withdrawalDate = DateUtils.formatDateWithPattern(billingAccount.getNextInvoiceDate(), DATE_PATTERN_BODY);\\r\\n            }\\r\\n\\r\\n            String ws_oneTimeCBPaymentDate = \\\"\\\";\\r\\n            String ws_oneTimePaymentAmount = \\\"\\\";\\r\\n            String ws_refundDate = \\\"\\\";\\r\\n            String ws_refundAmount = \\\"\\\";\\r\\n            String ws_discountEntryDate = \\\"\\\";\\r\\n            String ws_discountAmount = \\\"\\\";\\r\\n            String ws_transacAutorisationNb = \\\"\\\";\\r\\n            String ws_rum = \\\"\\\";\\r\\n            String ws_ics = \\\"\\\";\\r\\n            String ws_legalEntityName = \\\"\\\";\\r\\n\\r\\n            String ws_activationDate = \\\"\\\";\\r\\n            String ws_rterminationDate = \\\"\\\";\\r\\n            String ws_terminationReason = \\\"\\\";\\r\\n\\r\\n            String ws_trActivationDate = \\\"\\\";\\r\\n            String ws_trDeactivationDate = \\\"\\\";\\r\\n\\r\\n            String soapEnvBody =\\r\\n                    \\\"<urn:Submit><urn:sessiontoken></urn:sessiontoken><urn:elemCtx><ctx \\\" + \\\" address=\\\\\\\"\\\" + ws_address + \\\"\\\\\\\"\\\" + \\\" culture=\\\\\\\"\\\" + ws_culture + \\\"\\\\\\\"\\\"\\r\\n                            + \\\" sendByMail=\\\\\\\"\\\" + ws_sendByMail + \\\"\\\\\\\"\\\" + \\\" sendBySMS=\\\\\\\"\\\" + ws_sendBySMS + \\\"\\\\\\\"\\\" + \\\" cellphone=\\\\\\\"\\\" + ws_cellphone + \\\"\\\\\\\"\\\"\\r\\n                            + \\\" expirationDate=\\\\\\\"\\\" + ws_expirationDate + \\\"\\\\\\\"\\\" + \\\" originalDate=\\\\\\\"\\\" + ws_originalDate + \\\"\\\\\\\"\\\" + \\\" rcpId=\\\\\\\"\\\" + ws_rcpId + \\\"\\\\\\\"\\\"\\r\\n                            + \\\" template=\\\\\\\"\\\" + ws_template + \\\"\\\\\\\"\\\" + \\\" xmlns=\\\\\\\"\\\\\\\">\\\" + \\\"<CUSTOMER> \\\" + \\\"<Enseigne>\\\" + ws_enseigne + \\\"</Enseigne>\\\" + \\\"<Gender>\\\" + ws_gender\\r\\n                            + \\\"</Gender>\\\" + \\\"<FirstName>\\\" + ws_firstName + \\\"</FirstName>\\\" + \\\"<LastName>\\\" + ws_lastName + \\\"</LastName>\\\" + \\\"<Email>\\\" + ws_email\\r\\n                            + \\\"</Email>\\\" + \\\"<SendBySMS>\\\" + ws_sendBySMS + \\\"</SendBySMS>\\\" + \\\"<sendByMail>\\\" + ws_sendByMail + \\\"</sendByMail>\\\" + \\\"<ContractNumber>\\\"\\r\\n                            + ws_contractNumber + \\\"</ContractNumber>\\\" + \\\"<offerLabel>\\\" + ws_offerLabel + \\\"</offerLabel>\\\" + \\\"<ContractStatus>\\\" + ws_contractStatus\\r\\n                            + \\\"</ContractStatus>\\\" + \\\"<CardNumber>\\\" + ws_cardNumber + \\\"</CardNumber>\\\" + \\\"<AdhNumber>\\\" + ws_adhNumber + \\\"</AdhNumber>\\\" + \\\"<SelfCareUrl>\\\"\\r\\n                            + ws_urlSelfcare + \\\"</SelfCareUrl>\\\" + \\\"<SerenityUrl>\\\" + ws_serenityUrl + \\\"</SerenityUrl>\\\" + \\\"<EngagmentEndDate>\\\" + ws_engagmentEndDate\\r\\n                            + \\\"</EngagmentEndDate>\\\" + \\\"<TryBuyEndDate>\\\" + ws_tryBuyEndDate + \\\"</TryBuyEndDate>\\\" + \\\"<SubAmount>\\\" + ws_subAmount + \\\"</SubAmount>\\\"\\r\\n                            + \\\"</CUSTOMER> \\\" + \\\"<INVOICE> \\\" + \\\"<CBValidityDate>\\\" + ws_cbValidityDate + \\\"</CBValidityDate>\\\" + \\\"<PaymentMode>\\\" + ws_paymentMode\\r\\n                            + \\\"</PaymentMode>\\\" + \\\"<RejectDate>\\\" + ws_rejectDate + \\\"</RejectDate>\\\" + \\\"<RejectedInvoiceNb>\\\" + ws_rejectedInvoiceNb\\r\\n                            + \\\"</RejectedInvoiceNb>\\\" + \\\"<RejectedAmountTTC>\\\" + ws_rejectedAmountTTC + \\\"</RejectedAmountTTC>\\\" + \\\"<Reason>\\\" + ws_reason + \\\"</Reason>\\\"\\r\\n                            + \\\"<AmountDrawn>\\\" + ws_amountDrawn + \\\"</AmountDrawn>\\\" + \\\"<WithdrawalDate>\\\" + ws_withdrawalDate + \\\"</WithdrawalDate>\\\"\\r\\n                            + \\\"<OneTimeCBPaymentDate>\\\" + ws_oneTimeCBPaymentDate + \\\"</OneTimeCBPaymentDate>\\\" + \\\"<OneTimePaymentAmount>\\\" + ws_oneTimePaymentAmount\\r\\n                            + \\\"</OneTimePaymentAmount>\\\" + \\\"<RefundDate>\\\" + ws_refundDate + \\\"</RefundDate>\\\" + \\\"<RefundAmount>\\\" + ws_refundAmount + \\\"</RefundAmount>\\\"\\r\\n                            + \\\"<DiscountEntryDate>\\\" + ws_discountEntryDate + \\\"</DiscountEntryDate>\\\" + \\\"<DiscountAmount>\\\" + ws_discountAmount + \\\"</DiscountAmount>\\\"\\r\\n                            + \\\"<TransacAutorisationNb>\\\" + ws_transacAutorisationNb + \\\"</TransacAutorisationNb>\\\" + \\\"<Rum>\\\" + ws_rum + \\\"</Rum>\\\" + \\\"<Ics>\\\" + ws_ics\\r\\n                            + \\\"</Ics>\\\" + \\\"<LegalEntityName>\\\" + ws_legalEntityName + \\\"</LegalEntityName>\\\" + \\\"</INVOICE>\\\" + \\\"<TERMINATION>\\\" + \\\"<ActivationDate>\\\"\\r\\n                            + ws_activationDate + \\\"</ActivationDate>\\\" + \\\"<TerminationDate>\\\" + ws_rterminationDate + \\\"</TerminationDate>\\\" + \\\"<TerminationReason>\\\"\\r\\n                            + ws_terminationReason + \\\"</TerminationReason>\\\" + \\\"</TERMINATION>\\\" + \\\"<TACITRENEWAL>\\\" + \\\"<TrActivationDate>\\\" + ws_trActivationDate\\r\\n                            + \\\"</TrActivationDate>\\\" + \\\"<TrDeactivationDate>\\\" + ws_trDeactivationDate + \\\"</TrDeactivationDate>\\\" + \\\"</TACITRENEWAL>\\\"\\r\\n                            + \\\"</ctx></urn:elemCtx></urn:Submit>\\\";\\r\\n\\r\\n            String response = callWebService(soapEnvBody);\\r\\n            log.info(\\\"response = \\\" + response);\\r\\n            log.info(\\\"soapEnvBody = \\\" + soapEnvBody);\\r\\n        }\\r\\n    }\\r\\n}\",\n    \"executionRoles\": [],\n    \"sourcingRoles\": []\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/scriptInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"scriptInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLifeResiliationScript",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										},
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"org.meveo.service.script.NeolaneCustomerLifeResiliationScript\",\n    \"description\": \"NeolaneCustomerLifeResiliation Script\",\n    \"type\": \"JAVA\",\n    \"script\": \"package org.meveo.service.script;\\r\\n\\r\\nimport org.apache.http.client.methods.CloseableHttpResponse;\\r\\nimport org.apache.http.client.methods.HttpPost;\\r\\nimport org.apache.http.conn.ssl.NoopHostnameVerifier;\\r\\nimport org.apache.http.conn.ssl.SSLContextBuilder;\\r\\nimport org.apache.http.conn.ssl.TrustStrategy;\\r\\nimport org.apache.http.entity.StringEntity;\\r\\nimport org.apache.http.impl.client.CloseableHttpClient;\\r\\nimport org.apache.http.impl.client.HttpClients;\\r\\nimport org.meveo.admin.exception.BusinessException;\\r\\nimport org.meveo.commons.utils.StringUtils;\\r\\nimport org.meveo.model.ICustomFieldEntity;\\r\\nimport org.meveo.model.billing.BillingAccount;\\r\\nimport org.meveo.model.billing.Subscription;\\r\\nimport org.meveo.model.billing.SubscriptionTerminationReason;\\r\\nimport org.meveo.model.billing.UserAccount;\\r\\nimport org.meveo.model.catalog.OfferTemplate;\\r\\nimport org.meveo.model.crm.Customer;\\r\\nimport org.meveo.model.crm.Provider;\\r\\nimport org.meveo.model.payments.CustomerAccount;\\r\\nimport org.meveo.model.shared.ContactInformation;\\r\\nimport org.meveo.model.shared.DateUtils;\\r\\nimport org.meveo.model.shared.Name;\\r\\nimport org.meveo.model.shared.Title;\\r\\nimport org.meveo.service.billing.impl.InvoiceService;\\r\\nimport org.meveo.service.crm.impl.CustomFieldInstanceService;\\r\\nimport org.meveo.service.crm.impl.ProviderService;\\r\\n\\r\\nimport java.io.IOException;\\r\\nimport java.security.cert.CertificateException;\\r\\nimport java.security.cert.X509Certificate;\\r\\nimport java.util.Calendar;\\r\\nimport java.util.Date;\\r\\nimport java.util.Map;\\r\\n\\r\\n/**\\r\\n * Appel le web service Neolane\\r\\n *    Mail de confirmation de prise en compte de la r\\u00E9siliation/d\\u00E9sactivation TR\\r\\n *\\r\\n * @author Mounir Bahije\\r\\n */\\r\\npublic class NeolaneCustomerLifeResiliationScript extends Script {\\r\\n\\r\\n    private CustomFieldInstanceService cfiService = (CustomFieldInstanceService) getServiceInterface(CustomFieldInstanceService.class.getSimpleName());\\r\\n    private ProviderService providerService = (ProviderService) getServiceInterface(ProviderService.class.getSimpleName());\\r\\n    private InvoiceService invoiceService = (InvoiceService) getServiceInterface(InvoiceService.class.getSimpleName());\\r\\n\\r\\n\\r\\n    private Provider appProvider = providerService.getProvider();\\r\\n\\r\\n    private static final String DATE_PATTERN = \\\"yyyy/MM/dd HH:mm:ss\\\";\\r\\n    private static final String DATE_PATTERN_BODY = \\\"dd/MM/yyyy\\\";\\r\\n    private static final String CF_FD_URL_WS_NCLS = \\\"CF_FD_URL_WS_NCLS\\\";\\r\\n    private static final String CF_FD_ACTION_URI_WS_NCLS = \\\"CF_FD_ACTION_URI_WS_NCLS\\\";\\r\\n    private static final String CF_FD_URL_SELFCARE_NCLS = \\\"CF_FD_URL_SELFCARE_NCLS\\\";\\r\\n    private static final String CULTURE = \\\"fr-FR\\\";\\r\\n    private static final String SUBSCRIPTION_CREATED = \\\"0\\\";\\r\\n    private static final String SUBSCRIPTION_ACTIVE = \\\"1\\\";\\r\\n    private static final String SUBSCRIPTION_SUSPENDED = \\\"2\\\";\\r\\n    private static final String SUBSCRIPTION_RESILIATED = \\\"3\\\";\\r\\n    private static final String SUBSCRIPTION_CANCELED = \\\"4\\\";\\r\\n    private static final String SUBSCRIPTION_CLOSED = \\\"5\\\";\\r\\n\\r\\n    @Override\\r\\n    public void execute(Map<String, Object> methodContext) throws BusinessException {\\r\\n\\r\\n        Date nowDate = new Date();\\r\\n\\r\\n        if (cfiService == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeResiliationScript : cfiService is null\\\");\\r\\n            return;\\r\\n        }\\r\\n\\r\\n        Subscription subscription = (Subscription) methodContext.get(\\\"subscription\\\");\\r\\n\\r\\n        if (subscription == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeResiliationScript : subscription is null\\\");\\r\\n            return;\\r\\n        }\\r\\n\\r\\n        UserAccount userAccount = subscription.getUserAccount();\\r\\n        if (userAccount == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeResiliationScript : userAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n        ContactInformation contactInformation = userAccount.getContactInformation();\\r\\n        if (contactInformation == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeResiliationScript : contactInformation is null / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n\\r\\n        //////////////\\r\\n        String email = contactInformation.getEmail();\\r\\n        email = (email == null) ? \\\"\\\" : email;\\r\\n\\r\\n        String ws_address = email;\\r\\n\\r\\n        String ws_culture = CULTURE;\\r\\n\\r\\n        String ws_sendByMail = \\\"true\\\";\\r\\n\\r\\n        String ws_sendBySMS = \\\"false\\\";\\r\\n\\r\\n        String ws_cellphone = \\\"\\\";\\r\\n\\r\\n        BillingAccount billingAccount = userAccount.getBillingAccount();\\r\\n        if (billingAccount == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeResiliationScript : billingAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n\\r\\n\\r\\n        Calendar expirationDateCalendar = Calendar.getInstance();\\r\\n        expirationDateCalendar.setTime(nowDate);\\r\\n        expirationDateCalendar.add(Calendar.HOUR_OF_DAY, 12);\\r\\n        String ws_expirationDate = DateUtils.formatDateWithPattern(expirationDateCalendar.getTime(), DATE_PATTERN);\\r\\n\\r\\n        String ws_originalDate = DateUtils.formatDateWithPattern(nowDate, DATE_PATTERN);\\r\\n\\r\\n\\r\\n        String ws_rcpId = \\\"-2\\\";\\r\\n\\r\\n        String ws_template = \\\"RESIL_OPENCELL_TRT\\\";\\r\\n\\r\\n        String ws_enseigne = \\\"\\\";\\r\\n\\r\\n        CustomerAccount customerAccount = billingAccount.getCustomerAccount();\\r\\n        if (customerAccount == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeResiliationScript : customerAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n\\r\\n        boolean nameOk = false;\\r\\n        Customer customer = null;\\r\\n        Name name = null;\\r\\n        Title title = null;\\r\\n        if (customerAccount != null) {\\r\\n            customer = customerAccount.getCustomer();\\r\\n            if (customer != null) {\\r\\n                name = customer.getName();\\r\\n                if (name != null) {\\r\\n                    nameOk = true;\\r\\n                }\\r\\n            }\\r\\n        }\\r\\n\\r\\n        if (nameOk == false) {\\r\\n            log.error(\\\"NeolaneCustomerLifeResiliationScript : problem with name / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n        title = name.getTitle();\\r\\n        String ws_gender = \\\"\\\";\\r\\n        if (title != null && title.getCode() != null) {\\r\\n            ws_gender = title.getCode();\\r\\n        }\\r\\n\\r\\n        String ws_firstName = (name.getFirstName() == null) ? \\\"\\\" : name.getFirstName();\\r\\n        String ws_lastName = (name.getLastName() == null) ? \\\"\\\" : name.getLastName();\\r\\n        String ws_email = email;\\r\\n\\r\\n        String ws_contractNumber = subscription.getCode();\\r\\n\\r\\n        OfferTemplate offer = subscription.getOffer();\\r\\n        if (offer == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeResiliationScript : offer is null / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n\\r\\n        String ws_offerLabel = (offer.getName() == null) ? \\\"\\\" : offer.getName();\\r\\n\\r\\n        String ws_contractStatus = \\\"\\\";\\r\\n        if (subscription.getStatus() == null) {\\r\\n            log.error(\\\"NeolaneCustomerLifeResiliationScript : subscription.status is null / subscription code = \\\" + subscription.getCode());\\r\\n            return;\\r\\n        }\\r\\n        switch (subscription.getStatus()) {\\r\\n            case CREATED:\\r\\n                ws_contractStatus = SUBSCRIPTION_CREATED;\\r\\n                break;\\r\\n            case ACTIVE:\\r\\n                ws_contractStatus = SUBSCRIPTION_ACTIVE;\\r\\n                break;\\r\\n            case CANCELED:\\r\\n                ws_contractStatus = SUBSCRIPTION_CANCELED;\\r\\n                break;\\r\\n            case RESILIATED:\\r\\n                ws_contractStatus = SUBSCRIPTION_RESILIATED;\\r\\n                break;\\r\\n            case CLOSED:\\r\\n                ws_contractStatus = SUBSCRIPTION_CLOSED;\\r\\n                break;\\r\\n            case SUSPENDED:\\r\\n                ws_contractStatus = SUBSCRIPTION_SUSPENDED;\\r\\n                break;\\r\\n            default:\\r\\n                ws_contractStatus = \\\"\\\";\\r\\n        }\\r\\n\\r\\n        String ws_cardNumber = \\\"\\\";\\r\\n\\r\\n        String ws_adhNumber = \\\"\\\";\\r\\n\\r\\n        final String selfCareUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_SELFCARE_NCLS, true);\\r\\n        String ws_urlSelfcare = \\\"\\\";\\r\\n        if (!StringUtils.isBlank(selfCareUrl)) {\\r\\n            ws_urlSelfcare = selfCareUrl;\\r\\n        }\\r\\n\\r\\n        String ws_serenityUrl = \\\"\\\";\\r\\n\\r\\n        String ws_engagmentEndDate = \\\"\\\";\\r\\n\\r\\n        String ws_tryBuyEndDate = \\\"\\\";\\r\\n\\r\\n        String ws_subAmount = \\\"\\\";\\r\\n\\r\\n        String ws_cbValidityDate = \\\"\\\";\\r\\n        String ws_paymentMode = \\\"\\\";\\r\\n        String ws_rejectDate = \\\"\\\";\\r\\n        String ws_rejectedInvoiceNb = \\\"\\\";\\r\\n        String ws_rejectedAmountTTC = \\\"\\\";\\r\\n        String ws_reason = \\\"\\\";\\r\\n        String ws_amountDrawn = \\\"\\\";\\r\\n        String ws_withdrawalDate = \\\"\\\";\\r\\n        String ws_oneTimeCBPaymentDate = \\\"\\\";\\r\\n        String ws_oneTimePaymentAmount = \\\"\\\";\\r\\n        String ws_refundDate = \\\"\\\";\\r\\n        String ws_refundAmount = \\\"\\\";\\r\\n        String ws_discountEntryDate = \\\"\\\";\\r\\n        String ws_discountAmount = \\\"\\\";\\r\\n        String ws_transacAutorisationNb = \\\"\\\";\\r\\n\\r\\n        String ws_rum = \\\"\\\";\\r\\n        String ws_ics = \\\"\\\";\\r\\n        String ws_legalEntityName = \\\"\\\";\\r\\n\\r\\n        String ws_activationDate = \\\"\\\";\\r\\n        if (subscription.getSubscriptionDate() != null) {\\r\\n            ws_activationDate = DateUtils.formatDateWithPattern(subscription.getSubscriptionDate(),DATE_PATTERN_BODY);\\r\\n        }\\r\\n\\r\\n\\r\\n        String ws_rterminationDate = \\\"\\\";\\r\\n        ws_rterminationDate = DateUtils.formatDateWithPattern(subscription.getSubscribedTillDate(), DATE_PATTERN_BODY);\\r\\n\\r\\n\\r\\n        String ws_terminationReason = \\\"\\\";\\r\\n\\r\\n        SubscriptionTerminationReason subscriptionTerminationReason = subscription.getSubscriptionTerminationReason();\\r\\n        if (subscriptionTerminationReason != null) {\\r\\n            String SubscriptionTerminationReasonCode = subscriptionTerminationReason.getCode();\\r\\n            ws_terminationReason = (SubscriptionTerminationReasonCode == null) ? \\\"\\\" : SubscriptionTerminationReasonCode;\\r\\n        }\\r\\n\\r\\n        String ws_trActivationDate = \\\"\\\";\\r\\n        String ws_trDeactivationDate = \\\"\\\";\\r\\n\\r\\n        String soapEnvBody =\\r\\n                \\\"<urn:Submit><urn:sessiontoken></urn:sessiontoken><urn:elemCtx><ctx \\\" + \\\" address=\\\\\\\"\\\" + ws_address + \\\"\\\\\\\"\\\" + \\\" culture=\\\\\\\"\\\" + ws_culture + \\\"\\\\\\\"\\\"\\r\\n                        + \\\" sendByMail=\\\\\\\"\\\" + ws_sendByMail + \\\"\\\\\\\"\\\" + \\\" sendBySMS=\\\\\\\"\\\" + ws_sendBySMS + \\\"\\\\\\\"\\\" + \\\" cellphone=\\\\\\\"\\\" + ws_cellphone + \\\"\\\\\\\"\\\"\\r\\n                        + \\\" expirationDate=\\\\\\\"\\\" + ws_expirationDate + \\\"\\\\\\\"\\\" + \\\" originalDate=\\\\\\\"\\\" + ws_originalDate + \\\"\\\\\\\"\\\" + \\\" rcpId=\\\\\\\"\\\" + ws_rcpId + \\\"\\\\\\\"\\\"\\r\\n                        + \\\" template=\\\\\\\"\\\" + ws_template + \\\"\\\\\\\"\\\" + \\\" xmlns=\\\\\\\"\\\\\\\">\\\" + \\\"<CUSTOMER> \\\" + \\\"<Enseigne>\\\" + ws_enseigne + \\\"</Enseigne>\\\" + \\\"<Gender>\\\" + ws_gender\\r\\n                        + \\\"</Gender>\\\" + \\\"<FirstName>\\\" + ws_firstName + \\\"</FirstName>\\\" + \\\"<LastName>\\\" + ws_lastName + \\\"</LastName>\\\" + \\\"<Email>\\\" + ws_email\\r\\n                        + \\\"</Email>\\\" + \\\"<SendBySMS>\\\" + ws_sendBySMS + \\\"</SendBySMS>\\\" + \\\"<sendByMail>\\\" + ws_sendByMail + \\\"</sendByMail>\\\" + \\\"<ContractNumber>\\\"\\r\\n                        + ws_contractNumber + \\\"</ContractNumber>\\\" + \\\"<offerLabel>\\\" + ws_offerLabel + \\\"</offerLabel>\\\" + \\\"<ContractStatus>\\\" + ws_contractStatus\\r\\n                        + \\\"</ContractStatus>\\\" + \\\"<CardNumber>\\\" + ws_cardNumber + \\\"</CardNumber>\\\" + \\\"<AdhNumber>\\\" + ws_adhNumber + \\\"</AdhNumber>\\\" + \\\"<SelfCareUrl>\\\"\\r\\n                        + ws_urlSelfcare + \\\"</SelfCareUrl>\\\" + \\\"<SerenityUrl>\\\" + ws_serenityUrl + \\\"</SerenityUrl>\\\" + \\\"<EngagmentEndDate>\\\" + ws_engagmentEndDate\\r\\n                        + \\\"</EngagmentEndDate>\\\" + \\\"<TryBuyEndDate>\\\" + ws_tryBuyEndDate + \\\"</TryBuyEndDate>\\\" + \\\"<SubAmount>\\\" + ws_subAmount + \\\"</SubAmount>\\\"\\r\\n                        + \\\"</CUSTOMER> \\\" + \\\"<INVOICE> \\\" + \\\"<CBValidityDate>\\\" + ws_cbValidityDate + \\\"</CBValidityDate>\\\" + \\\"<PaymentMode>\\\" + ws_paymentMode\\r\\n                        + \\\"</PaymentMode>\\\" + \\\"<RejectDate>\\\" + ws_rejectDate + \\\"</RejectDate>\\\" + \\\"<RejectedInvoiceNb>\\\" + ws_rejectedInvoiceNb\\r\\n                        + \\\"</RejectedInvoiceNb>\\\" + \\\"<RejectedAmountTTC>\\\" + ws_rejectedAmountTTC + \\\"</RejectedAmountTTC>\\\" + \\\"<Reason>\\\" + ws_reason + \\\"</Reason>\\\"\\r\\n                        + \\\"<AmountDrawn>\\\" + ws_amountDrawn + \\\"</AmountDrawn>\\\" + \\\"<WithdrawalDate>\\\" + ws_withdrawalDate + \\\"</WithdrawalDate>\\\"\\r\\n                        + \\\"<OneTimeCBPaymentDate>\\\" + ws_oneTimeCBPaymentDate + \\\"</OneTimeCBPaymentDate>\\\" + \\\"<OneTimePaymentAmount>\\\" + ws_oneTimePaymentAmount\\r\\n                        + \\\"</OneTimePaymentAmount>\\\" + \\\"<RefundDate>\\\" + ws_refundDate + \\\"</RefundDate>\\\" + \\\"<RefundAmount>\\\" + ws_refundAmount + \\\"</RefundAmount>\\\"\\r\\n                        + \\\"<DiscountEntryDate>\\\" + ws_discountEntryDate + \\\"</DiscountEntryDate>\\\" + \\\"<DiscountAmount>\\\" + ws_discountAmount + \\\"</DiscountAmount>\\\"\\r\\n                        + \\\"<TransacAutorisationNb>\\\" + ws_transacAutorisationNb + \\\"</TransacAutorisationNb>\\\" + \\\"<Rum>\\\" + ws_rum + \\\"</Rum>\\\" + \\\"<Ics>\\\" + ws_ics\\r\\n                        + \\\"</Ics>\\\" + \\\"<LegalEntityName>\\\" + ws_legalEntityName + \\\"</LegalEntityName>\\\" + \\\"</INVOICE>\\\" + \\\"<TERMINATION>\\\" + \\\"<ActivationDate>\\\"\\r\\n                        + ws_activationDate + \\\"</ActivationDate>\\\" + \\\"<TerminationDate>\\\" + ws_rterminationDate + \\\"</TerminationDate>\\\" + \\\"<TerminationReason>\\\"\\r\\n                        + ws_terminationReason + \\\"</TerminationReason>\\\" + \\\"</TERMINATION>\\\" + \\\"<TACITRENEWAL>\\\" + \\\"<TrActivationDate>\\\" + ws_trActivationDate\\r\\n                        + \\\"</TrActivationDate>\\\" + \\\"<TrDeactivationDate>\\\" + ws_trDeactivationDate + \\\"</TrDeactivationDate>\\\" + \\\"</TACITRENEWAL>\\\"\\r\\n                        + \\\"</ctx></urn:elemCtx></urn:Submit>\\\";\\r\\n\\r\\n\\r\\n        String response = callWebService(soapEnvBody);\\r\\n\\r\\n        log.info(\\\"response = \\\" + response);\\r\\n        log.info(\\\"soapEnvBody = \\\" + soapEnvBody);\\r\\n\\r\\n\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Call Neolane WS\\r\\n     *\\r\\n     * @param soapEnvBody\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private String callWebService(String soapEnvBody) throws BusinessException {\\r\\n\\r\\n        String body = \\\"<?xml version=\\\\\\\"1.0\\\\\\\" encoding=\\\\\\\"UTF-8\\\\\\\"?><soapenv:Envelope xmlns:soapenv=\\\\\\\"http://schemas.xmlsoap.org/soap/envelope/\\\\\\\" xmlns:urn=\\\\\\\"urn:nms:rtMsg\\\\\\\"><soapenv:Header/><soapenv:Body>\\\" + soapEnvBody + \\\"</soapenv:Body></soapenv:Envelope>\\\";\\r\\n\\r\\n        StringEntity stringEntity = new StringEntity(body, \\\"UTF-8\\\");\\r\\n\\r\\n        final String wsUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_WS_NCLS, true);\\r\\n        final String actionUri = (String) this.fetchCFConfigValue(appProvider, CF_FD_ACTION_URI_WS_NCLS, true);\\r\\n\\r\\n        // Request parameters and other properties.\\r\\n        HttpPost httpPost = new HttpPost(wsUrl);\\r\\n        httpPost.setEntity(stringEntity);\\r\\n        httpPost.setHeader(\\\"SOAPAction\\\", actionUri);\\r\\n\\r\\n        // Execute and get the response.\\r\\n        CloseableHttpClient httpClient = getCloseableHttpClient();\\r\\n        CloseableHttpResponse response = null;\\r\\n        try {\\r\\n\\r\\n            log.info(\\\"we want to sent to this address = \\\" + actionUri);\\r\\n            log.info(\\\"This body = \\\" + body);\\r\\n\\r\\n            response = httpClient.execute(httpPost);\\r\\n            boolean responseOk = false;\\r\\n            if (response != null) {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    if (response.getStatusLine().getStatusCode() == 200) {\\r\\n                        responseOk = true;\\r\\n                        log.info(\\\"In NeolaneCustomerLifeResiliationScript : body sent and it's Ok\\\");\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n            if (responseOk) {\\r\\n                log.info(\\\"In NeolaneCustomerLifeResiliationScript : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                return \\\"OK\\\";\\r\\n            } else {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    log.error(\\\"In NeolaneCustomerLifeResiliationScript : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                } else {\\r\\n                    log.error(\\\"In NeolaneCustomerLifeResiliationScript : response.getStatusLine() = null \\\");\\r\\n                }\\r\\n                return \\\"KO\\\";\\r\\n            }\\r\\n\\r\\n\\r\\n        } catch (IOException e) {\\r\\n            log.error(\\\"Exception in EndSubscriptionScript :\\\", e);\\r\\n        }\\r\\n        return \\\"KO\\\";\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * fetch CF Config Value\\r\\n     *\\r\\n     * @param entity\\r\\n     * @param cfKey\\r\\n     * @param isMandatory\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private Object fetchCFConfigValue(ICustomFieldEntity entity, String cfKey, boolean isMandatory) throws BusinessException {\\r\\n        Object cfValue = cfiService.getCFValue(entity, cfKey);\\r\\n        if (isMandatory && (cfValue == null || (cfValue instanceof String && org.apache.commons.lang3.StringUtils.isEmpty(String.valueOf(cfValue))))) {\\r\\n            throw new BusinessException(\\\" Missing mandatory config [\\\" + cfKey + \\\"]\\\");\\r\\n        }\\r\\n        return cfValue;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * get CloseableHttpClient\\r\\n     *\\r\\n     * @return trusted httpClient\\r\\n     */\\r\\n    public CloseableHttpClient getCloseableHttpClient()\\r\\n    {\\r\\n        CloseableHttpClient httpClient = null;\\r\\n        try {\\r\\n            httpClient = HttpClients.custom().\\r\\n                    setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).\\r\\n                    setSSLContext(new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy()\\r\\n                    {\\r\\n                        public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException\\r\\n                        {\\r\\n                            return true;\\r\\n                        }\\r\\n                    }).build()).build();\\r\\n        } catch (Exception e) {\\r\\n            log.error(\\\"KeyManagementException in creating http client instance\\\", e);\\r\\n        }\\r\\n        return httpClient;\\r\\n    }\\r\\n}\",\n    \"executionRoles\": [],\n    \"sourcingRoles\": []\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/scriptInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"scriptInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLifeResiliationMassScript",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										},
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"org.meveo.service.script.NeolaneCustomerLifeResiliationMassScript\",\n    \"description\": \"NeolaneCustomerLifeResiliationMass Script\",\n    \"type\": \"JAVA\",\n    \"script\": \"package org.meveo.service.script;\\r\\n\\r\\nimport org.apache.http.client.methods.CloseableHttpResponse;\\r\\nimport org.apache.http.client.methods.HttpPost;\\r\\nimport org.apache.http.conn.ssl.NoopHostnameVerifier;\\r\\nimport org.apache.http.conn.ssl.SSLContextBuilder;\\r\\nimport org.apache.http.conn.ssl.TrustStrategy;\\r\\nimport org.apache.http.entity.StringEntity;\\r\\nimport org.apache.http.impl.client.CloseableHttpClient;\\r\\nimport org.apache.http.impl.client.HttpClients;\\r\\nimport org.meveo.admin.exception.BusinessException;\\r\\nimport org.meveo.commons.utils.StringUtils;\\r\\nimport org.meveo.model.ICustomFieldEntity;\\r\\nimport org.meveo.model.billing.BillingAccount;\\r\\nimport org.meveo.model.billing.Subscription;\\r\\nimport org.meveo.model.billing.SubscriptionStatusEnum;\\r\\nimport org.meveo.model.billing.SubscriptionTerminationReason;\\r\\nimport org.meveo.model.billing.UserAccount;\\r\\nimport org.meveo.model.catalog.OfferTemplate;\\r\\nimport org.meveo.model.crm.Customer;\\r\\nimport org.meveo.model.crm.Provider;\\r\\nimport org.meveo.model.payments.CustomerAccount;\\r\\nimport org.meveo.model.shared.ContactInformation;\\r\\nimport org.meveo.model.shared.DateUtils;\\r\\nimport org.meveo.model.shared.Name;\\r\\nimport org.meveo.model.shared.Title;\\r\\nimport org.meveo.service.billing.impl.InvoiceService;\\r\\nimport org.meveo.service.billing.impl.SubscriptionService;\\r\\nimport org.meveo.service.crm.impl.CustomFieldInstanceService;\\r\\nimport org.meveo.service.crm.impl.ProviderService;\\r\\n\\r\\nimport java.io.IOException;\\r\\nimport java.security.cert.CertificateException;\\r\\nimport java.security.cert.X509Certificate;\\r\\nimport java.util.Calendar;\\r\\nimport java.util.Date;\\r\\nimport java.util.HashMap;\\r\\nimport java.util.List;\\r\\nimport java.util.Map;\\r\\n\\r\\n/**\\r\\n * Appel le web service Neolane\\r\\n *    Mail de r\\u00E9siliation\\r\\n *\\r\\n * @author Mounir Bahije\\r\\n */\\r\\npublic class NeolaneCustomerLifeResiliationMassScript extends Script {\\r\\n\\r\\n    private CustomFieldInstanceService cfiService = (CustomFieldInstanceService) getServiceInterface(CustomFieldInstanceService.class.getSimpleName());\\r\\n    private ProviderService providerService = (ProviderService) getServiceInterface(ProviderService.class.getSimpleName());\\r\\n    private InvoiceService invoiceService = (InvoiceService) getServiceInterface(InvoiceService.class.getSimpleName());\\r\\n    private SubscriptionService subscriptionService = (SubscriptionService) getServiceInterface(\\\"SubscriptionService\\\");\\r\\n\\r\\n    private Provider appProvider = providerService.getProvider();\\r\\n\\r\\n    private static final String DATE_PATTERN = \\\"yyyy/MM/dd HH:mm:ss\\\";\\r\\n    private static final String DATE_PATTERN_BODY = \\\"dd/MM/yyyy\\\";\\r\\n    private static final String CF_FD_URL_WS_NCLS = \\\"CF_FD_URL_WS_NCLS\\\";\\r\\n    private static final String CF_FD_ACTION_URI_WS_NCLS = \\\"CF_FD_ACTION_URI_WS_NCLS\\\";\\r\\n    private static final String CF_FD_URL_SELFCARE_NCLS = \\\"CF_FD_URL_SELFCARE_NCLS\\\";\\r\\n    private static final String CULTURE = \\\"fr-FR\\\";\\r\\n    private static final String SUBSCRIPTION_CREATED = \\\"0\\\";\\r\\n    private static final String SUBSCRIPTION_ACTIVE = \\\"1\\\";\\r\\n    private static final String SUBSCRIPTION_SUSPENDED = \\\"2\\\";\\r\\n    private static final String SUBSCRIPTION_RESILIATED = \\\"3\\\";\\r\\n    private static final String SUBSCRIPTION_CANCELED = \\\"4\\\";\\r\\n    private static final String SUBSCRIPTION_CLOSED = \\\"5\\\";\\r\\n\\r\\n    @Override\\r\\n    public void execute(Map<String, Object> methodContext) throws BusinessException {\\r\\n        log.debug(\\\"EXECUTE  methodContext {}\\\", methodContext);\\r\\n\\r\\n        String querySubscription = String.format(\\\"select  subsc  from Subscription subsc\\\");\\r\\n        Map<String, Object> paramsSubscription = new HashMap<>();\\r\\n        List<Subscription> listSubscription = (List<Subscription>) subscriptionService.executeSelectQuery(querySubscription.toString(), paramsSubscription);\\r\\n\\r\\n        setWSData(listSubscription);\\r\\n\\r\\n\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Call Neolane WS\\r\\n     *\\r\\n     * @param soapEnvBody\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private String callWebService(String soapEnvBody) throws BusinessException {\\r\\n\\r\\n        String body = \\\"<?xml version=\\\\\\\"1.0\\\\\\\" encoding=\\\\\\\"UTF-8\\\\\\\"?><soapenv:Envelope xmlns:soapenv=\\\\\\\"http://schemas.xmlsoap.org/soap/envelope/\\\\\\\" \\\" +\\r\\n                \\\"xmlns:urn=\\\\\\\"urn:nms:rtMsg\\\\\\\"><soapenv:Header/><soapenv:Body>\\\" + soapEnvBody + \\\"</soapenv:Body></soapenv:Envelope>\\\";\\r\\n\\r\\n        StringEntity stringEntity = new StringEntity(body, \\\"UTF-8\\\");\\r\\n\\r\\n        final String wsUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_WS_NCLS, true);\\r\\n        final String actionUri = (String) this.fetchCFConfigValue(appProvider, CF_FD_ACTION_URI_WS_NCLS, true);\\r\\n\\r\\n        // Request parameters and other properties.\\r\\n        HttpPost httpPost = new HttpPost(wsUrl);\\r\\n        httpPost.setEntity(stringEntity);\\r\\n        httpPost.setHeader(\\\"SOAPAction\\\", actionUri);\\r\\n\\r\\n        // Execute and get the response.\\r\\n        CloseableHttpClient httpClient = getCloseableHttpClient();\\r\\n        CloseableHttpResponse response = null;\\r\\n        try {\\r\\n\\r\\n            log.info(\\\"we want to sent to this address = \\\" + actionUri);\\r\\n            log.info(\\\"This body = \\\" + body);\\r\\n\\r\\n            response = httpClient.execute(httpPost);\\r\\n            boolean responseOk = false;\\r\\n            if (response != null) {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    if (response.getStatusLine().getStatusCode() == 200) {\\r\\n                        responseOk = true;\\r\\n                        log.info(\\\"In NeolaneCustomerLifeResiliationMassScript : body sent and it's Ok\\\");\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n            if (responseOk) {\\r\\n                log.info(\\\"In NeolaneCustomerLifeResiliationMassScript : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                return \\\"OK\\\";\\r\\n            } else {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    log.error(\\\"In NeolaneCustomerLifeResiliationMassScript : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                } else {\\r\\n                    log.error(\\\"In NeolaneCustomerLifeResiliationMassScript : response.getStatusLine() = null \\\");\\r\\n                }\\r\\n                return \\\"KO\\\";\\r\\n            }\\r\\n\\r\\n\\r\\n        } catch (IOException e) {\\r\\n            log.error(\\\"Exception in EndSubscriptionScript :\\\", e);\\r\\n        }\\r\\n        return \\\"KO\\\";\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * fetch CF Config Value\\r\\n     *\\r\\n     * @param entity\\r\\n     * @param cfKey\\r\\n     * @param isMandatory\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private Object fetchCFConfigValue(ICustomFieldEntity entity, String cfKey, boolean isMandatory) throws BusinessException {\\r\\n        Object cfValue = cfiService.getCFValue(entity, cfKey);\\r\\n        if (isMandatory && (cfValue == null || (cfValue instanceof String && org.apache.commons.lang3.StringUtils.isEmpty(String.valueOf(cfValue))))) {\\r\\n            throw new BusinessException(\\\" Missing mandatory config [\\\" + cfKey + \\\"]\\\");\\r\\n        }\\r\\n        return cfValue;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * get CloseableHttpClient\\r\\n     *\\r\\n     * @return trusted httpClient\\r\\n     */\\r\\n    public CloseableHttpClient getCloseableHttpClient() {\\r\\n        CloseableHttpClient httpClient = null;\\r\\n        try {\\r\\n            httpClient = HttpClients.custom().\\r\\n                    setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).\\r\\n                    setSSLContext(new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {\\r\\n                        public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {\\r\\n                            return true;\\r\\n                        }\\r\\n                    }).build()).build();\\r\\n        } catch (Exception e) {\\r\\n            log.error(\\\"KeyManagementException in creating http client instance\\\", e);\\r\\n        }\\r\\n        return httpClient;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Set Data for Neolane WS\\r\\n     *\\r\\n     * @param listSubscription the list of subscription\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private void setWSData(List<Subscription> listSubscription) throws BusinessException {\\r\\n\\r\\n        Date nowDate = new Date();\\r\\n\\r\\n        for (Subscription subscription : listSubscription) {\\r\\n            if (subscription != null) {\\r\\n                if (SubscriptionStatusEnum.RESILIATED == subscription.getStatus()) {\\r\\n                    Date terminationDate = subscription.getTerminationDate();\\r\\n                    if (terminationDate != null) {\\r\\n                        Date nowDate_1 = DateUtils.addDaysToDate(nowDate, -1);\\r\\n                        String nowDate_Str = DateUtils.formatDateWithPattern(nowDate, DATE_PATTERN_BODY);\\r\\n                        String nowDate_1_Str = DateUtils.formatDateWithPattern(nowDate_1, DATE_PATTERN_BODY);\\r\\n                        Date nowDate_1_Start = DateUtils.parseDateWithPattern(nowDate_1_Str, DATE_PATTERN_BODY);\\r\\n                        Date nowDate_1_End = DateUtils.parseDateWithPattern(nowDate_Str, DATE_PATTERN_BODY);\\r\\n                        if (DateUtils.isDateTimeWithinPeriod(terminationDate, nowDate_1_Start, nowDate_1_End)) {\\r\\n\\r\\n                            UserAccount userAccount = subscription.getUserAccount();\\r\\n                            if (userAccount == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLifeResiliationMassScript : userAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n                            ContactInformation contactInformation = userAccount.getContactInformation();\\r\\n                            if (contactInformation == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLifeResiliationMassScript : contactInformation is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n\\r\\n                            String email = contactInformation.getEmail();\\r\\n                            email = (email == null) ? \\\"\\\" : email;\\r\\n\\r\\n                            String ws_address = email;\\r\\n\\r\\n                            String ws_culture = CULTURE;\\r\\n\\r\\n                            String ws_sendByMail = \\\"true\\\";\\r\\n\\r\\n                            String ws_sendBySMS = \\\"false\\\";\\r\\n\\r\\n                            String ws_cellphone = \\\"\\\";\\r\\n\\r\\n                            BillingAccount billingAccount = userAccount.getBillingAccount();\\r\\n                            if (billingAccount == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLifeResiliationMassScript : billingAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n\\r\\n\\r\\n                            Calendar expirationDateCalendar = Calendar.getInstance();\\r\\n                            expirationDateCalendar.setTime(nowDate);\\r\\n                            expirationDateCalendar.add(Calendar.HOUR_OF_DAY, 12);\\r\\n                            String ws_expirationDate = DateUtils.formatDateWithPattern(expirationDateCalendar.getTime(), DATE_PATTERN);\\r\\n\\r\\n                            String ws_originalDate = DateUtils.formatDateWithPattern(nowDate, DATE_PATTERN);\\r\\n\\r\\n\\r\\n                            String ws_rcpId = \\\"-2\\\";\\r\\n\\r\\n                            String ws_template = \\\"RESIL_OPENCELL_CNF\\\";\\r\\n\\r\\n                            String ws_enseigne = \\\"\\\";\\r\\n\\r\\n                            CustomerAccount customerAccount = billingAccount.getCustomerAccount();\\r\\n                            if (customerAccount == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLifeResiliationMassScript : customerAccount is null  / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n\\r\\n                            boolean nameOk = false;\\r\\n                            Customer customer = customerAccount.getCustomer();\\r\\n                            Name name = null;\\r\\n                            Title title = null;\\r\\n                            if (customer != null && customer.getName() != null) {\\r\\n                                name = customer.getName();\\r\\n                                nameOk = true;\\r\\n                            }\\r\\n\\r\\n                            if (nameOk == false) {\\r\\n                                log.error(\\\"NeolaneCustomerLifeResiliationMassScript : problem with name  / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n                            title = name.getTitle();\\r\\n                            String ws_gender = \\\"\\\";\\r\\n                            if (title != null && title.getCode() != null) {\\r\\n                                ws_gender = title.getCode();\\r\\n                            }\\r\\n                            String ws_firstName = (name.getFirstName() == null) ? \\\"\\\" : name.getFirstName();\\r\\n                            String ws_lastName = (name.getLastName() == null) ? \\\"\\\" : name.getLastName();\\r\\n\\r\\n\\r\\n                            String ws_email = email;\\r\\n\\r\\n                            String ws_contractNumber = subscription.getCode();\\r\\n\\r\\n                            OfferTemplate offer = subscription.getOffer();\\r\\n                            if (offer == null) {\\r\\n                                throw new BusinessException(\\\"NeolaneCustomerLifeResiliationMassScript : offer is null\\\");\\r\\n                            }\\r\\n\\r\\n                            String ws_offerLabel = (offer.getName() == null) ? \\\"\\\" : offer.getName();\\r\\n\\r\\n                            String ws_contractStatus = \\\"\\\";\\r\\n                            if (subscription.getStatus() == null) {\\r\\n                                log.error(\\\"NeolaneCustomerLifeResiliationMassScript : subscription.status is null / subscription code = \\\" + subscription.getCode());\\r\\n                                continue;\\r\\n                            }\\r\\n                            switch (subscription.getStatus()) {\\r\\n                                case CREATED:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_CREATED;\\r\\n                                    break;\\r\\n                                case ACTIVE:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_ACTIVE;\\r\\n                                    break;\\r\\n                                case CANCELED:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_CANCELED;\\r\\n                                    break;\\r\\n                                case RESILIATED:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_RESILIATED;\\r\\n                                    break;\\r\\n                                case CLOSED:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_CLOSED;\\r\\n                                    break;\\r\\n                                case SUSPENDED:\\r\\n                                    ws_contractStatus = SUBSCRIPTION_SUSPENDED;\\r\\n                                    break;\\r\\n                                default:\\r\\n                                    ws_contractStatus = \\\"\\\";\\r\\n                            }\\r\\n\\r\\n                            String ws_cardNumber = \\\"\\\";\\r\\n\\r\\n                            String ws_adhNumber = \\\"\\\";\\r\\n\\r\\n                            final String selfCareUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_SELFCARE_NCLS, true);\\r\\n                            String ws_urlSelfcare = \\\"\\\";\\r\\n                            if (!StringUtils.isBlank(selfCareUrl)) {\\r\\n                                ws_urlSelfcare = selfCareUrl;\\r\\n                            }\\r\\n\\r\\n                            String ws_serenityUrl = \\\"\\\";\\r\\n\\r\\n                            String ws_engagmentEndDate = \\\"\\\";\\r\\n\\r\\n                            String ws_tryBuyEndDate = \\\"\\\";\\r\\n\\r\\n                            String ws_subAmount = \\\"\\\";\\r\\n\\r\\n\\r\\n                            String ws_cbValidityDate = \\\"\\\";\\r\\n                            String ws_paymentMode = \\\"\\\";\\r\\n                            String ws_rejectDate = \\\"\\\";\\r\\n                            String ws_rejectedInvoiceNb = \\\"\\\";\\r\\n                            String ws_rejectedAmountTTC = \\\"\\\";\\r\\n                            String ws_reason = \\\"\\\";\\r\\n                            String ws_amountDrawn = \\\"\\\";\\r\\n                            String ws_withdrawalDate = \\\"\\\";\\r\\n                            String ws_oneTimeCBPaymentDate = \\\"\\\";\\r\\n                            String ws_oneTimePaymentAmount = \\\"\\\";\\r\\n                            String ws_refundDate = \\\"\\\";\\r\\n                            String ws_refundAmount = \\\"\\\";\\r\\n                            String ws_discountEntryDate = \\\"\\\";\\r\\n                            String ws_discountAmount = \\\"\\\";\\r\\n                            String ws_transacAutorisationNb = \\\"\\\";\\r\\n\\r\\n                            String ws_rum = \\\"\\\";\\r\\n                            String ws_ics = \\\"\\\";\\r\\n                            String ws_legalEntityName = \\\"\\\";\\r\\n\\r\\n                            String ws_activationDate = DateUtils.formatDateWithPattern(subscription.getSubscriptionDate(), DATE_PATTERN_BODY);\\r\\n                            String ws_rterminationDate = DateUtils.formatDateWithPattern(subscription.getTerminationDate(), DATE_PATTERN_BODY);\\r\\n\\r\\n                            String ws_terminationReason = \\\"\\\";\\r\\n\\r\\n                            SubscriptionTerminationReason subscriptionTerminationReason = subscription.getSubscriptionTerminationReason();\\r\\n                            if (subscriptionTerminationReason != null) {\\r\\n                                String SubscriptionTerminationReasonCode = subscriptionTerminationReason.getCode();\\r\\n                                ws_terminationReason = (SubscriptionTerminationReasonCode == null) ? \\\"\\\" : SubscriptionTerminationReasonCode;\\r\\n                            }\\r\\n\\r\\n                            String ws_trActivationDate = \\\"\\\";\\r\\n                            String ws_trDeactivationDate = \\\"\\\";\\r\\n\\r\\n                            String soapEnvBody =\\r\\n                                    \\\"<urn:Submit><urn:sessiontoken></urn:sessiontoken><urn:elemCtx><ctx \\\" + \\\" address=\\\\\\\"\\\" + ws_address + \\\"\\\\\\\"\\\" + \\\" culture=\\\\\\\"\\\" + ws_culture + \\\"\\\\\\\"\\\"\\r\\n                                            + \\\" sendByMail=\\\\\\\"\\\" + ws_sendByMail + \\\"\\\\\\\"\\\" + \\\" sendBySMS=\\\\\\\"\\\" + ws_sendBySMS + \\\"\\\\\\\"\\\" + \\\" cellphone=\\\\\\\"\\\" + ws_cellphone + \\\"\\\\\\\"\\\"\\r\\n                                            + \\\" expirationDate=\\\\\\\"\\\" + ws_expirationDate + \\\"\\\\\\\"\\\" + \\\" originalDate=\\\\\\\"\\\" + ws_originalDate + \\\"\\\\\\\"\\\" + \\\" rcpId=\\\\\\\"\\\" + ws_rcpId + \\\"\\\\\\\"\\\"\\r\\n                                            + \\\" template=\\\\\\\"\\\" + ws_template + \\\"\\\\\\\"\\\" + \\\" xmlns=\\\\\\\"\\\\\\\">\\\" + \\\"<CUSTOMER> \\\" + \\\"<Enseigne>\\\" + ws_enseigne + \\\"</Enseigne>\\\" + \\\"<Gender>\\\" + ws_gender\\r\\n                                            + \\\"</Gender>\\\" + \\\"<FirstName>\\\" + ws_firstName + \\\"</FirstName>\\\" + \\\"<LastName>\\\" + ws_lastName + \\\"</LastName>\\\" + \\\"<Email>\\\" + ws_email\\r\\n                                            + \\\"</Email>\\\" + \\\"<SendBySMS>\\\" + ws_sendBySMS + \\\"</SendBySMS>\\\" + \\\"<sendByMail>\\\" + ws_sendByMail + \\\"</sendByMail>\\\" + \\\"<ContractNumber>\\\"\\r\\n                                            + ws_contractNumber + \\\"</ContractNumber>\\\" + \\\"<offerLabel>\\\" + ws_offerLabel + \\\"</offerLabel>\\\" + \\\"<ContractStatus>\\\" + ws_contractStatus\\r\\n                                            + \\\"</ContractStatus>\\\" + \\\"<CardNumber>\\\" + ws_cardNumber + \\\"</CardNumber>\\\" + \\\"<AdhNumber>\\\" + ws_adhNumber + \\\"</AdhNumber>\\\" + \\\"<SelfCareUrl>\\\"\\r\\n                                            + ws_urlSelfcare + \\\"</SelfCareUrl>\\\" + \\\"<SerenityUrl>\\\" + ws_serenityUrl + \\\"</SerenityUrl>\\\" + \\\"<EngagmentEndDate>\\\" + ws_engagmentEndDate\\r\\n                                            + \\\"</EngagmentEndDate>\\\" + \\\"<TryBuyEndDate>\\\" + ws_tryBuyEndDate + \\\"</TryBuyEndDate>\\\" + \\\"<SubAmount>\\\" + ws_subAmount + \\\"</SubAmount>\\\"\\r\\n                                            + \\\"</CUSTOMER> \\\" + \\\"<INVOICE> \\\" + \\\"<CBValidityDate>\\\" + ws_cbValidityDate + \\\"</CBValidityDate>\\\" + \\\"<PaymentMode>\\\" + ws_paymentMode\\r\\n                                            + \\\"</PaymentMode>\\\" + \\\"<RejectDate>\\\" + ws_rejectDate + \\\"</RejectDate>\\\" + \\\"<RejectedInvoiceNb>\\\" + ws_rejectedInvoiceNb\\r\\n                                            + \\\"</RejectedInvoiceNb>\\\" + \\\"<RejectedAmountTTC>\\\" + ws_rejectedAmountTTC + \\\"</RejectedAmountTTC>\\\" + \\\"<Reason>\\\" + ws_reason + \\\"</Reason>\\\"\\r\\n                                            + \\\"<AmountDrawn>\\\" + ws_amountDrawn + \\\"</AmountDrawn>\\\" + \\\"<WithdrawalDate>\\\" + ws_withdrawalDate + \\\"</WithdrawalDate>\\\"\\r\\n                                            + \\\"<OneTimeCBPaymentDate>\\\" + ws_oneTimeCBPaymentDate + \\\"</OneTimeCBPaymentDate>\\\" + \\\"<OneTimePaymentAmount>\\\" + ws_oneTimePaymentAmount\\r\\n                                            + \\\"</OneTimePaymentAmount>\\\" + \\\"<RefundDate>\\\" + ws_refundDate + \\\"</RefundDate>\\\" + \\\"<RefundAmount>\\\" + ws_refundAmount + \\\"</RefundAmount>\\\"\\r\\n                                            + \\\"<DiscountEntryDate>\\\" + ws_discountEntryDate + \\\"</DiscountEntryDate>\\\" + \\\"<DiscountAmount>\\\" + ws_discountAmount + \\\"</DiscountAmount>\\\"\\r\\n                                            + \\\"<TransacAutorisationNb>\\\" + ws_transacAutorisationNb + \\\"</TransacAutorisationNb>\\\" + \\\"<Rum>\\\" + ws_rum + \\\"</Rum>\\\" + \\\"<Ics>\\\" + ws_ics\\r\\n                                            + \\\"</Ics>\\\" + \\\"<LegalEntityName>\\\" + ws_legalEntityName + \\\"</LegalEntityName>\\\" + \\\"</INVOICE>\\\" + \\\"<TERMINATION>\\\" + \\\"<ActivationDate>\\\"\\r\\n                                            + ws_activationDate + \\\"</ActivationDate>\\\" + \\\"<TerminationDate>\\\" + ws_rterminationDate + \\\"</TerminationDate>\\\" + \\\"<TerminationReason>\\\"\\r\\n                                            + ws_terminationReason + \\\"</TerminationReason>\\\" + \\\"</TERMINATION>\\\" + \\\"<TACITRENEWAL>\\\" + \\\"<TrActivationDate>\\\" + ws_trActivationDate\\r\\n                                            + \\\"</TrActivationDate>\\\" + \\\"<TrDeactivationDate>\\\" + ws_trDeactivationDate + \\\"</TrDeactivationDate>\\\" + \\\"</TACITRENEWAL>\\\"\\r\\n                                            + \\\"</ctx></urn:elemCtx></urn:Submit>\\\";\\r\\n\\r\\n                            String response = callWebService(soapEnvBody);\\r\\n\\r\\n                            log.info(\\\"response = \\\" + response);\\r\\n                            log.info(\\\"soapEnvBody = \\\" + soapEnvBody);\\r\\n\\r\\n                        }\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n        }\\r\\n    }\\r\\n}\",\n    \"executionRoles\": [],\n    \"sourcingRoles\": []\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/scriptInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"scriptInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLifeRefundScript",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										},
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"org.meveo.service.script.NeolaneCustomerLifeRefundScript\",\n    \"description\": \"NeolaneCustomerLifeRefund Script\",\n    \"type\": \"JAVA\",\n    \"script\": \"package org.meveo.service.script;\\r\\n\\r\\nimport org.apache.http.client.methods.CloseableHttpResponse;\\r\\nimport org.apache.http.client.methods.HttpPost;\\r\\nimport org.apache.http.conn.ssl.NoopHostnameVerifier;\\r\\nimport org.apache.http.conn.ssl.SSLContextBuilder;\\r\\nimport org.apache.http.conn.ssl.TrustStrategy;\\r\\nimport org.apache.http.entity.StringEntity;\\r\\nimport org.apache.http.impl.client.CloseableHttpClient;\\r\\nimport org.apache.http.impl.client.HttpClients;\\r\\nimport org.meveo.admin.exception.BusinessException;\\r\\nimport org.meveo.commons.utils.StringUtils;\\r\\nimport org.meveo.model.ICustomFieldEntity;\\r\\nimport org.meveo.model.billing.BillingAccount;\\r\\nimport org.meveo.model.billing.Invoice;\\r\\nimport org.meveo.model.billing.Subscription;\\r\\nimport org.meveo.model.billing.UserAccount;\\r\\nimport org.meveo.model.catalog.OfferTemplate;\\r\\nimport org.meveo.model.crm.Customer;\\r\\nimport org.meveo.model.crm.Provider;\\r\\nimport org.meveo.model.payments.CustomerAccount;\\r\\nimport org.meveo.model.shared.ContactInformation;\\r\\nimport org.meveo.model.shared.DateUtils;\\r\\nimport org.meveo.model.shared.Name;\\r\\nimport org.meveo.model.shared.Title;\\r\\nimport org.meveo.service.billing.impl.InvoiceService;\\r\\nimport org.meveo.service.crm.impl.CustomFieldInstanceService;\\r\\nimport org.meveo.service.crm.impl.ProviderService;\\r\\n\\r\\nimport java.io.IOException;\\r\\nimport java.math.BigDecimal;\\r\\nimport java.security.cert.CertificateException;\\r\\nimport java.security.cert.X509Certificate;\\r\\nimport java.text.SimpleDateFormat;\\r\\nimport java.util.Calendar;\\r\\nimport java.util.Date;\\r\\nimport java.util.HashMap;\\r\\nimport java.util.List;\\r\\nimport java.util.Map;\\r\\n\\r\\n/**\\r\\n * Appel le web service Neolane\\r\\n *    Mail de confirmation de remboursement\\r\\n *\\r\\n * @author Mounir Bahije\\r\\n */\\r\\npublic class NeolaneCustomerLifeRefundScript extends Script {\\r\\n\\r\\n    private CustomFieldInstanceService cfiService = (CustomFieldInstanceService) getServiceInterface(CustomFieldInstanceService.class.getSimpleName());\\r\\n    private ProviderService providerService = (ProviderService) getServiceInterface(ProviderService.class.getSimpleName());\\r\\n    private InvoiceService invoiceService = (InvoiceService) getServiceInterface(\\\"InvoiceService\\\");\\r\\n\\r\\n    private Provider appProvider = providerService.getProvider();\\r\\n\\r\\n    private static final String DATE_PATTERN = \\\"yyyy/MM/dd HH:mm:ss\\\";\\r\\n    private static final String DATE_PATTERN_BODY = \\\"dd/MM/yyyy\\\";\\r\\n    private static final String CF_FD_URL_WS_NCLS = \\\"CF_FD_URL_WS_NCLS\\\";\\r\\n    private static final String CF_FD_ACTION_URI_WS_NCLS = \\\"CF_FD_ACTION_URI_WS_NCLS\\\";\\r\\n    private static final String CF_FD_URL_SELFCARE_NCLS = \\\"CF_FD_URL_SELFCARE_NCLS\\\";\\r\\n    private static final String CULTURE = \\\"fr-FR\\\";\\r\\n    private static final String SUBSCRIPTION_CREATED = \\\"0\\\";\\r\\n    private static final String SUBSCRIPTION_ACTIVE = \\\"1\\\";\\r\\n    private static final String SUBSCRIPTION_SUSPENDED = \\\"2\\\";\\r\\n    private static final String SUBSCRIPTION_RESILIATED = \\\"3\\\";\\r\\n    private static final String SUBSCRIPTION_CANCELED = \\\"4\\\";\\r\\n    private static final String SUBSCRIPTION_CLOSED = \\\"5\\\";\\r\\n    /**\\r\\n     * The custom field of repayment duration.\\r\\n     */\\r\\n    private final Long CF_PROV_FD_REPAYMENT_DURATION = (Long) cfiService.getCFValue(appProvider, \\\"CF_PROV_FD_REPAYMENT_DURATION\\\");\\r\\n\\r\\n    @Override\\r\\n    public void execute(Map<String, Object> methodContext) throws BusinessException {\\r\\n\\r\\n        Date nowDate = new Date();\\r\\n\\r\\n        Date nowDate_1 = DateUtils.addDaysToDate(nowDate, -1);\\r\\n        String nowDate_Str = DateUtils.formatDateWithPattern(nowDate, \\\"dd/MM/yyyy\\\");\\r\\n        String nowDate_1_Str = DateUtils.formatDateWithPattern(nowDate_1, \\\"dd/MM/yyyy\\\");\\r\\n        Date fromDate = DateUtils.parseDateWithPattern(nowDate_1_Str, \\\"dd/MM/yyyy\\\");\\r\\n        Date toDate = DateUtils.parseDateWithPattern(nowDate_Str, \\\"dd/MM/yyyy\\\");\\r\\n\\r\\n        String queryStr = \\\"select  inv  from Invoice inv where inv.invoiceType.code = :invoiceType and inv.invoiceDate  >= :fromDate  and inv.invoiceDate < :toDate \\\";\\r\\n\\r\\n        Map<String, Object> params = new HashMap<String, Object>();\\r\\n        params.put(\\\"invoiceType\\\", \\\"COM\\\");\\r\\n        params.put(\\\"fromDate\\\", fromDate);\\r\\n        params.put(\\\"toDate\\\", toDate);\\r\\n        List<Invoice> invoiceList = (List<Invoice>) invoiceService.executeSelectQuery(queryStr.toString(), params);\\r\\n\\r\\n        methodContext.clear();\\r\\n\\r\\n        setWSData(invoiceList);\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Call Neolane WS\\r\\n     *\\r\\n     * @param soapEnvBody\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private String callWebService(String soapEnvBody) throws BusinessException {\\r\\n\\r\\n        String body = \\\"<?xml version=\\\\\\\"1.0\\\\\\\" encoding=\\\\\\\"UTF-8\\\\\\\"?><soapenv:Envelope xmlns:soapenv=\\\\\\\"http://schemas.xmlsoap.org/soap/envelope/\\\\\\\" \\\" +\\r\\n                \\\"xmlns:urn=\\\\\\\"urn:nms:rtMsg\\\\\\\"><soapenv:Header/><soapenv:Body>\\\" + soapEnvBody + \\\"</soapenv:Body></soapenv:Envelope>\\\";\\r\\n\\r\\n        StringEntity stringEntity = new StringEntity(body, \\\"UTF-8\\\");\\r\\n\\r\\n        final String wsUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_WS_NCLS, true);\\r\\n        final String actionUri = (String) this.fetchCFConfigValue(appProvider, CF_FD_ACTION_URI_WS_NCLS, true);\\r\\n\\r\\n        // Request parameters and other properties.\\r\\n        HttpPost httpPost = new HttpPost(wsUrl);\\r\\n        httpPost.setEntity(stringEntity);\\r\\n        httpPost.setHeader(\\\"SOAPAction\\\", actionUri);\\r\\n\\r\\n        // Execute and get the response.\\r\\n        CloseableHttpClient httpClient = getCloseableHttpClient();\\r\\n        CloseableHttpResponse response = null;\\r\\n        try {\\r\\n\\r\\n            log.info(\\\"we want to sent to this address = \\\" + actionUri);\\r\\n            log.info(\\\"This body = \\\" + body);\\r\\n\\r\\n            response = httpClient.execute(httpPost);\\r\\n            boolean responseOk = false;\\r\\n            if (response != null) {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    if (response.getStatusLine().getStatusCode() == 200) {\\r\\n                        responseOk = true;\\r\\n                        log.info(\\\"In NeolaneCustomerLifeRefundScript : body sent and it's Ok\\\");\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n            if (responseOk) {\\r\\n                log.info(\\\"In NeolaneCustomerLifeRefundScript : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                return \\\"OK\\\";\\r\\n            } else {\\r\\n                if (response.getStatusLine() != null) {\\r\\n                    log.error(\\\"In NeolaneCustomerLifeRefundScript : Status Code of response is \\\" + response.getStatusLine().getStatusCode());\\r\\n                } else {\\r\\n                    log.error(\\\"In NeolaneCustomerLifeRefundScript : response.getStatusLine() = null \\\");\\r\\n                }\\r\\n                return \\\"KO\\\";\\r\\n            }\\r\\n\\r\\n\\r\\n        } catch (IOException e) {\\r\\n            log.error(\\\"Exception in EndSubscriptionScript :\\\", e);\\r\\n        }\\r\\n        return \\\"KO\\\";\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * fetch CF Config Value\\r\\n     *\\r\\n     * @param entity\\r\\n     * @param cfKey\\r\\n     * @param isMandatory\\r\\n     * @return\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private Object fetchCFConfigValue(ICustomFieldEntity entity, String cfKey, boolean isMandatory) throws BusinessException {\\r\\n        Object cfValue = cfiService.getCFValue(entity, cfKey);\\r\\n        if (isMandatory && (cfValue == null || (cfValue instanceof String && org.apache.commons.lang3.StringUtils.isEmpty(String.valueOf(cfValue))))) {\\r\\n            throw new BusinessException(\\\" Missing mandatory config [\\\" + cfKey + \\\"]\\\");\\r\\n        }\\r\\n        return cfValue;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * get CloseableHttpClient\\r\\n     *\\r\\n     * @return trusted httpClient\\r\\n     */\\r\\n    public CloseableHttpClient getCloseableHttpClient() {\\r\\n        CloseableHttpClient httpClient = null;\\r\\n        try {\\r\\n            httpClient = HttpClients.custom().\\r\\n                    setSSLHostnameVerifier(NoopHostnameVerifier.INSTANCE).\\r\\n                    setSSLContext(new SSLContextBuilder().loadTrustMaterial(null, new TrustStrategy() {\\r\\n                        public boolean isTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {\\r\\n                            return true;\\r\\n                        }\\r\\n                    }).build()).build();\\r\\n        } catch (Exception e) {\\r\\n            log.error(\\\"KeyManagementException in creating http client instance\\\", e);\\r\\n        }\\r\\n        return httpClient;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * get Subscription From Invoice\\r\\n     *\\r\\n     * @param invoice\\r\\n     * @return\\r\\n     */\\r\\n    private Subscription getSubFromInvoice(Invoice invoice) {\\r\\n        if (invoice != null) {\\r\\n            if (invoice.getBillingAccount() != null) {\\r\\n                BillingAccount ba = invoice.getBillingAccount();\\r\\n                if (ba != null && ba.getUsersAccounts() != null && !ba.getUsersAccounts().isEmpty()) {\\r\\n                    UserAccount ua = ba.getUsersAccounts().get(0);\\r\\n                    if (ua != null && ua.getSubscriptions() != null && !ua.getSubscriptions().isEmpty()) {\\r\\n                        return ua.getSubscriptions().get(0);\\r\\n                    }\\r\\n                }\\r\\n            }\\r\\n        }\\r\\n        return null;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * get UA From Invoice\\r\\n     *\\r\\n     * @param invoice\\r\\n     * @return\\r\\n     */\\r\\n    private UserAccount getUAFromInvoice(Invoice invoice) {\\r\\n        if (invoice != null) {\\r\\n            if (invoice.getBillingAccount() != null) {\\r\\n                BillingAccount ba = invoice.getBillingAccount();\\r\\n                if (ba != null && ba.getUsersAccounts() != null && !ba.getUsersAccounts().isEmpty()) {\\r\\n                    return ba.getUsersAccounts().get(0);\\r\\n                }\\r\\n            }\\r\\n        }\\r\\n        return null;\\r\\n    }\\r\\n\\r\\n    /**\\r\\n     * Set Data for Neolane WS\\r\\n     *\\r\\n     * @param invoiceList the list of invoices\\r\\n     * @throws BusinessException\\r\\n     */\\r\\n    private void setWSData(List<Invoice> invoiceList) throws BusinessException {\\r\\n\\r\\n        Date nowDate = new Date();\\r\\n\\r\\n        for (Invoice invoice : invoiceList) {\\r\\n            if ((invoice != null) && (invoice.getAmountWithTax() != null)) {\\r\\n                BigDecimal amountInvoice = invoice.getAmountWithTax();\\r\\n                if (amountInvoice != null && amountInvoice.compareTo(BigDecimal.ZERO) < 0) {\\r\\n\\r\\n                    Subscription subscription = getSubFromInvoice(invoice);\\r\\n                    if (subscription == null) {\\r\\n                        log.error(\\\"NeolaneCustomerLifeRefundScript : subscription is null\\\");\\r\\n                        continue;\\r\\n                    }\\r\\n                    BillingAccount billingAccount = invoice.getBillingAccount();\\r\\n                    if (billingAccount == null) {\\r\\n                        log.error(\\\"NeolaneCustomerLifeRefundScript : billingAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                        continue;\\r\\n                    }\\r\\n                    CustomerAccount customerAccount = billingAccount.getCustomerAccount();\\r\\n                    if (customerAccount == null) {\\r\\n                        log.error(\\\"NeolaneCustomerLifeRefundScript : customerAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                        continue;\\r\\n                    }\\r\\n                    UserAccount userAccount = getUAFromInvoice(invoice);\\r\\n\\r\\n                    if (userAccount == null) {\\r\\n                        log.error(\\\"NeolaneCustomerLifeRefundScript : userAccount is null / subscription code = \\\" + subscription.getCode());\\r\\n                        continue;\\r\\n                    }\\r\\n\\r\\n                    ContactInformation contactInformation = userAccount.getContactInformation();\\r\\n                    if (contactInformation == null) {\\r\\n                        log.error(\\\"NeolaneCustomerLifeRefundScript : contactInformation is null / subscription code = \\\" + subscription.getCode());\\r\\n                        continue;\\r\\n                    }\\r\\n\\r\\n                    //////////////\\r\\n                    String email = contactInformation.getEmail();\\r\\n                    email = (email == null) ? \\\"\\\" : email;\\r\\n\\r\\n                    String ws_address = email;\\r\\n\\r\\n                    String ws_culture = CULTURE;\\r\\n\\r\\n                    String ws_sendByMail = \\\"true\\\";\\r\\n\\r\\n                    String ws_sendBySMS = \\\"false\\\";\\r\\n\\r\\n                    String ws_cellphone = \\\"\\\";\\r\\n\\r\\n                    SimpleDateFormat fd = new SimpleDateFormat(DATE_PATTERN);\\r\\n                    SimpleDateFormat fdBody = new SimpleDateFormat(DATE_PATTERN_BODY);\\r\\n\\r\\n                    Calendar expirationDateCalendar = Calendar.getInstance();\\r\\n                    expirationDateCalendar.setTime(nowDate);\\r\\n                    expirationDateCalendar.add(Calendar.HOUR_OF_DAY, 12);\\r\\n                    String ws_expirationDate = DateUtils.formatDateWithPattern(expirationDateCalendar.getTime(), DATE_PATTERN);\\r\\n\\r\\n                    String ws_originalDate = DateUtils.formatDateWithPattern(nowDate, DATE_PATTERN);\\r\\n\\r\\n\\r\\n                    String ws_rcpId = \\\"-2\\\";\\r\\n\\r\\n                    String ws_template = \\\"REMB_OPENCELL_CNF\\\";\\r\\n\\r\\n                    String ws_enseigne = \\\"\\\";\\r\\n\\r\\n                    boolean nameOk = false;\\r\\n\\r\\n                    Customer customer = null;\\r\\n                    Name name = null;\\r\\n                    Title title = null;\\r\\n                    if (customerAccount != null) {\\r\\n                        customer = customerAccount.getCustomer();\\r\\n                        if (customer != null) {\\r\\n                            name = customer.getName();\\r\\n                            if (name != null) {\\r\\n                                nameOk = true;\\r\\n                            }\\r\\n                        }\\r\\n                    }\\r\\n\\r\\n                    if (nameOk == false) {\\r\\n                        log.error(\\\"NeolaneCustomerLifeRefundScript : problem with name / subscription code = \\\" + subscription.getCode());\\r\\n                        continue;\\r\\n                    }\\r\\n                    title = name.getTitle();\\r\\n                    String ws_gender = \\\"\\\";\\r\\n                    if (title != null && title.getCode() != null) {\\r\\n                        ws_gender = title.getCode();\\r\\n                    }\\r\\n\\r\\n                    String ws_firstName = (name.getFirstName() == null) ? \\\"\\\" : name.getFirstName();\\r\\n                    String ws_lastName = (name.getLastName() == null) ? \\\"\\\" : name.getLastName();\\r\\n\\r\\n                    String ws_email = email;\\r\\n\\r\\n                    String ws_contractNumber = subscription.getCode();\\r\\n                    ws_contractNumber = (ws_contractNumber == null) ? \\\"\\\" : ws_contractNumber;\\r\\n\\r\\n                    OfferTemplate offer = subscription.getOffer();\\r\\n                    if (offer == null) {\\r\\n                        log.error(\\\"NeolaneCustomerLifeRefundScript : offer is null / subscription code = \\\" + subscription.getCode());\\r\\n                        continue;\\r\\n                    }\\r\\n\\r\\n                    String ws_offerLabel = (offer.getName() == null) ? \\\"\\\" : offer.getName();\\r\\n\\r\\n                    String ws_contractStatus = \\\"\\\";\\r\\n\\r\\n                    if (subscription.getStatus() == null) {\\r\\n                        log.error(\\\"NeolaneCustomerLifeRefundScript : subscription.status is null / subscription code = \\\" + subscription.getCode());\\r\\n                        continue;\\r\\n                    }\\r\\n                    switch (subscription.getStatus()) {\\r\\n                        case CREATED:\\r\\n                            ws_contractStatus = SUBSCRIPTION_CREATED;\\r\\n                            break;\\r\\n                        case ACTIVE:\\r\\n                            ws_contractStatus = SUBSCRIPTION_ACTIVE;\\r\\n                            break;\\r\\n                        case CANCELED:\\r\\n                            ws_contractStatus = SUBSCRIPTION_CANCELED;\\r\\n                            break;\\r\\n                        case RESILIATED:\\r\\n                            ws_contractStatus = SUBSCRIPTION_RESILIATED;\\r\\n                            break;\\r\\n                        case CLOSED:\\r\\n                            ws_contractStatus = SUBSCRIPTION_CLOSED;\\r\\n                            break;\\r\\n                        case SUSPENDED:\\r\\n                            ws_contractStatus = SUBSCRIPTION_SUSPENDED;\\r\\n                            break;\\r\\n                        default:\\r\\n                            ws_contractStatus = \\\"\\\";\\r\\n                    }\\r\\n\\r\\n                    final String selfCareUrl = (String) this.fetchCFConfigValue(appProvider, CF_FD_URL_SELFCARE_NCLS, true);\\r\\n                    String ws_urlSelfcare = \\\"\\\";\\r\\n                    if (!StringUtils.isBlank(selfCareUrl)) {\\r\\n                        ws_urlSelfcare = selfCareUrl;\\r\\n                    }\\r\\n\\r\\n                    String ws_refundDate = \\\"\\\";\\r\\n                    Date refundDate = null;\\r\\n                    Date dueDate = invoice.getDueDate();\\r\\n\\r\\n                    if (!StringUtils.isBlank(dueDate)) {\\r\\n                        if (CF_PROV_FD_REPAYMENT_DURATION != null) {\\r\\n                            refundDate = DateUtils.addDaysToDate(dueDate, CF_PROV_FD_REPAYMENT_DURATION.intValue());\\r\\n                            ws_refundDate = DateUtils.formatDateWithPattern(refundDate, DATE_PATTERN_BODY);\\r\\n                        }\\r\\n                    }\\r\\n                    String ws_refundAmount = amountInvoice.abs().toString();\\r\\n\\r\\n                    String ws_cardNumber = \\\"\\\";\\r\\n                    String ws_adhNumber = \\\"\\\";\\r\\n                    String ws_serenityUrl = \\\"\\\";\\r\\n                    String ws_engagmentEndDate = \\\"\\\";\\r\\n                    String ws_tryBuyEndDate = \\\"\\\";\\r\\n                    String ws_subAmount = \\\"\\\";\\r\\n                    String ws_cbValidityDate = \\\"\\\";\\r\\n                    String ws_paymentMode = \\\"\\\";\\r\\n                    String ws_rejectDate = \\\"\\\";\\r\\n                    String ws_rejectedInvoiceNb = \\\"\\\";\\r\\n                    String ws_rejectedAmountTTC = \\\"\\\";\\r\\n                    String ws_reason = \\\"\\\";\\r\\n                    String ws_amountDrawn = \\\"\\\";\\r\\n                    String ws_withdrawalDate = \\\"\\\";\\r\\n                    String ws_oneTimeCBPaymentDate = \\\"\\\";\\r\\n                    String ws_oneTimePaymentAmount = \\\"\\\";\\r\\n                    String ws_discountEntryDate = \\\"\\\";\\r\\n                    String ws_discountAmount = \\\"\\\";\\r\\n                    String ws_transacAutorisationNb = \\\"\\\";\\r\\n                    String ws_rum = \\\"\\\";\\r\\n                    String ws_ics = \\\"\\\";\\r\\n                    String ws_legalEntityName = \\\"\\\";\\r\\n                    String ws_activationDate = \\\"\\\";\\r\\n                    String ws_terminationDate = \\\"\\\";\\r\\n                    String ws_terminationReason = \\\"\\\";\\r\\n                    String ws_trActivationDate = \\\"\\\";\\r\\n                    String ws_trDeactivationDate = \\\"\\\";\\r\\n\\r\\n                    String soapEnvBody = \\\"<urn:Submit><urn:sessiontoken></urn:sessiontoken><urn:elemCtx><ctx \\\" + \\\" address=\\\\\\\"\\\" + ws_address + \\\"\\\\\\\"\\\" + \\\" culture=\\\\\\\"\\\" + ws_culture + \\\"\\\\\\\"\\\"\\r\\n                            + \\\" sendByMail=\\\\\\\"\\\" + ws_sendByMail + \\\"\\\\\\\"\\\" + \\\" sendBySMS=\\\\\\\"\\\" + ws_sendBySMS + \\\"\\\\\\\"\\\" + \\\" cellphone=\\\\\\\"\\\" + ws_cellphone + \\\"\\\\\\\"\\\" + \\\" expirationDate=\\\\\\\"\\\" + ws_expirationDate + \\\"\\\\\\\"\\\" + \\\" originalDate=\\\\\\\"\\\" + ws_originalDate + \\\"\\\\\\\"\\\" + \\\" rcpId=\\\\\\\"\\\" + ws_rcpId + \\\"\\\\\\\"\\\" + \\\" template=\\\\\\\"\\\" + ws_template + \\\"\\\\\\\"\\\"\\r\\n                            + \\\" xmlns=\\\\\\\"\\\\\\\">\\\" + \\\"<CUSTOMER> \\\" + \\\"<Enseigne>\\\" + ws_enseigne + \\\"</Enseigne>\\\" + \\\"<Gender>\\\" + ws_gender + \\\"</Gender>\\\" + \\\"<FirstName>\\\" + ws_firstName + \\\"</FirstName>\\\" + \\\"<LastName>\\\" + ws_lastName\\r\\n                            + \\\"</LastName>\\\" + \\\"<Email>\\\" + ws_email + \\\"</Email>\\\" + \\\"<SendBySMS>\\\" + ws_sendBySMS + \\\"</SendBySMS>\\\"\\r\\n                            + \\\"<sendByMail>\\\" + ws_sendByMail + \\\"</sendByMail>\\\" + \\\"<ContractNumber>\\\" + ws_contractNumber + \\\"</ContractNumber>\\\" + \\\"<offerLabel>\\\" + ws_offerLabel + \\\"</offerLabel>\\\" + \\\"<ContractStatus>\\\" + ws_contractStatus\\r\\n                            + \\\"</ContractStatus>\\\" + \\\"<CardNumber>\\\" + ws_cardNumber + \\\"</CardNumber>\\\" + \\\"<AdhNumber>\\\" + ws_adhNumber + \\\"</AdhNumber>\\\" + \\\"<SelfCareUrl>\\\" + ws_urlSelfcare\\r\\n                            + \\\"</SelfCareUrl>\\\" + \\\"<SerenityUrl>\\\" + ws_serenityUrl + \\\"</SerenityUrl>\\\" + \\\"<EngagmentEndDate>\\\" + ws_engagmentEndDate\\r\\n                            + \\\"</EngagmentEndDate>\\\" + \\\"<TryBuyEndDate>\\\" + ws_tryBuyEndDate + \\\"</TryBuyEndDate>\\\" + \\\"<SubAmount>\\\" + ws_subAmount\\r\\n                            + \\\"</SubAmount>\\\" + \\\"</CUSTOMER> \\\" + \\\"<INVOICE> \\\" + \\\"<CBValidityDate>\\\" + ws_cbValidityDate + \\\"</CBValidityDate>\\\" + \\\"<PaymentMode>\\\" + ws_paymentMode + \\\"</PaymentMode>\\\" + \\\"<RejectDate>\\\" + ws_rejectDate\\r\\n                            + \\\"</RejectDate>\\\" + \\\"<RejectedInvoiceNb>\\\" + ws_rejectedInvoiceNb + \\\"</RejectedInvoiceNb>\\\" + \\\"<RejectedAmountTTC>\\\" + ws_rejectedAmountTTC + \\\"</RejectedAmountTTC>\\\" + \\\"<Reason>\\\" + ws_reason\\r\\n                            + \\\"</Reason>\\\" + \\\"<AmountDrawn>\\\" + ws_amountDrawn + \\\"</AmountDrawn>\\\" + \\\"<WithdrawalDate>\\\" + ws_withdrawalDate\\r\\n                            + \\\"</WithdrawalDate>\\\" + \\\"<OneTimeCBPaymentDate>\\\" + ws_oneTimeCBPaymentDate + \\\"</OneTimeCBPaymentDate>\\\" + \\\"<OneTimePaymentAmount>\\\" + ws_oneTimePaymentAmount\\r\\n                            + \\\"</OneTimePaymentAmount>\\\" + \\\"<RefundDate>\\\" + ws_refundDate + \\\"</RefundDate>\\\" + \\\"<RefundAmount>\\\" + ws_refundAmount\\r\\n                            + \\\"</RefundAmount>\\\" + \\\"<DiscountEntryDate>\\\" + ws_discountEntryDate + \\\"</DiscountEntryDate>\\\" + \\\"<DiscountAmount>\\\" + ws_discountAmount\\r\\n                            + \\\"</DiscountAmount>\\\" + \\\"<TransacAutorisationNb>\\\" + ws_transacAutorisationNb + \\\"</TransacAutorisationNb>\\\" + \\\"<Rum>\\\" + ws_rum + \\\"</Rum>\\\" + \\\"<Ics>\\\" + ws_ics + \\\"</Ics>\\\" + \\\"<LegalEntityName>\\\" + ws_legalEntityName\\r\\n                            + \\\"</LegalEntityName>\\\" + \\\"</INVOICE>\\\" + \\\"<TERMINATION>\\\" + \\\"<ActivationDate>\\\" + ws_activationDate + \\\"</ActivationDate>\\\" + \\\"<TerminationDate>\\\" + ws_terminationDate\\r\\n                            + \\\"</TerminationDate>\\\" + \\\"<TerminationReason>\\\" + ws_terminationReason + \\\"</TerminationReason>\\\" + \\\"</TERMINATION>\\\" + \\\"<TACITRENEWAL>\\\" + \\\"<TrActivationDate>\\\" + ws_trActivationDate\\r\\n                            + \\\"</TrActivationDate>\\\" + \\\"<TrDeactivationDate>\\\" + ws_trDeactivationDate + \\\"</TrDeactivationDate>\\\" + \\\"</TACITRENEWAL>\\\" + \\\"</ctx></urn:elemCtx></urn:Submit>\\\";\\r\\n\\r\\n                    String response = callWebService(soapEnvBody);\\r\\n                    log.info(\\\"response = \\\" + response);\\r\\n                    log.info(\\\"soapEnvBody = \\\" + soapEnvBody);\\r\\n                }\\r\\n            }\\r\\n        }\\r\\n    }\\r\\n}\",\n    \"executionRoles\": [],\n    \"sourcingRoles\": []\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/scriptInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"scriptInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLifeNotif",
							"event": [
								{
									"listen": "test",
									"script": {
										"id": "3f933c17-6518-429c-b77b-8c404850a1fe",
										"exec": [
											"var jsonData = JSON.parse(responseBody);",
											"tests[\"is.success\"] = jsonData.status === \"SUCCESS\";"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										},
										{
											"key": "saveHelperData",
											"value": true,
											"type": "boolean"
										},
										{
											"key": "showPassword",
											"value": false,
											"type": "boolean"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Proxy-Authorization",
										"value": "{{proxy.auth}}"
									},
									{
										"key": "Content-Type",
										"value": "application/json"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\r\n    \"code\": \"NeolaneCustomerLifeNotif\",\r\n    \"classNameFilter\": \"org.meveo.model.billing.ServiceInstance\",\r\n    \"eventTypeFilter\": \"STATUS_UPDATED\",\r\n    \"elFilter\": \"#{ event.entity.code.endsWith('REC_MAIN') }\",\r\n    \"scriptInstanceCode\": \"org.meveo.service.script.NeolaneCustomerLifeScript\",\r\n    \"priority\": 10,\r\n\t\"scriptParams\": {\r\n\t\t\"event\" : \"#{event.entity}\"\r\n\t},\r\n    \"counterTemplate\": null\r\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/notification/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"notification",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLife_J0_Job",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"NeolaneCustomerLife_J0_Job\",\n    \"description\": \"NeolaneCustomerLife at J-0 Job\",\n    \"jobCategory\": \"MEDIATION\",\n    \"jobTemplate\": \"ScriptingJob\",\n    \"customFields\": {\n        \"customField\": [\n            {\n                \"code\": \"ScriptingJob_script\",\n                \"entityReferenceValue\": {\n                    \"classname\": \"org.meveo.model.scripts.ScriptInstance\",\n                    \"code\": \"org.meveo.service.script.NeolaneCustomerLife_J0_Script\"\n                } \n            } ,\n            {\n                \"code\": \"ScriptingJob_variables\",\n                \"mapValue\": {\n                }\n            }\n        ]\n    }\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/jobInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"jobInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLife_J10_Job",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"NeolaneCustomerLife_J10_Job\",\n    \"description\": \"NeolaneCustomerLife at J-10 Job\",\n    \"jobCategory\": \"MEDIATION\",\n    \"jobTemplate\": \"ScriptingJob\",\n    \"customFields\": {\n        \"customField\": [\n            {\n                \"code\": \"ScriptingJob_script\",\n                \"entityReferenceValue\": {\n                    \"classname\": \"org.meveo.model.scripts.ScriptInstance\",\n                    \"code\": \"org.meveo.service.script.NeolaneCustomerLife_J10_Script\"\n                } \n            } ,\n            {\n                \"code\": \"ScriptingJob_variables\",\n                \"mapValue\": {\n                }\n            }\n        ]\n    }\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/jobInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"jobInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLife_CB_Job",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"NeolaneCustomerLife_CB_Job\",\n    \"description\": \"NeolaneCustomerLife_CB Job\",\n    \"jobCategory\": \"MEDIATION\",\n    \"jobTemplate\": \"ScriptingJob\",\n    \"customFields\": {\n        \"customField\": [\n            {\n                \"code\": \"ScriptingJob_script\",\n                \"entityReferenceValue\": {\n                    \"classname\": \"org.meveo.model.scripts.ScriptInstance\",\n                    \"code\": \"org.meveo.service.script.NeolaneCustomerLife_CB_Script\"\n                } \n            } ,\n            {\n                \"code\": \"ScriptingJob_variables\",\n                \"mapValue\": {\n                }\n            }\n        ]\n    }\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/jobInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"jobInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLife_CB_10_Job",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"NeolaneCustomerLife_CB_10_Job\",\n    \"description\": \"NeolaneCustomerLife_CB_10 Job\",\n    \"jobCategory\": \"MEDIATION\",\n    \"jobTemplate\": \"ScriptingJob\",\n    \"customFields\": {\n        \"customField\": [\n            {\n                \"code\": \"ScriptingJob_script\",\n                \"entityReferenceValue\": {\n                    \"classname\": \"org.meveo.model.scripts.ScriptInstance\",\n                    \"code\": \"org.meveo.service.script.NeolaneCustomerLife_CB_10_Script\"\n                } \n            } ,\n            {\n                \"code\": \"ScriptingJob_variables\",\n                \"mapValue\": {\n                }\n            }\n        ]\n    }\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/jobInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"jobInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLifeEndContract_Job",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"NeolaneCustomerLifeEndContract_Job\",\n    \"description\": \"NeolaneCustomerLifeEndContract Job\",\n    \"jobCategory\": \"MEDIATION\",\n    \"jobTemplate\": \"ScriptingJob\",\n    \"customFields\": {\n        \"customField\": [\n            {\n                \"code\": \"ScriptingJob_script\",\n                \"entityReferenceValue\": {\n                    \"classname\": \"org.meveo.model.scripts.ScriptInstance\",\n                    \"code\": \"org.meveo.service.script.NeolaneCustomerLifeEndContractScript\"\n                } \n            } ,\n            {\n                \"code\": \"ScriptingJob_variables\",\n                \"mapValue\": {\n                }\n            }\n        ]\n    }\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/jobInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"jobInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLifeFirstRejectJob",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"NeolaneCustomerLifeFirstRejectJob\",\n    \"description\": \"NeolaneCustomerLifeFirstReject Job\",\n    \"jobCategory\": \"MEDIATION\",\n    \"jobTemplate\": \"ScriptingJob\",\n    \"customFields\": {\n        \"customField\": [\n            {\n                \"code\": \"ScriptingJob_script\",\n                \"entityReferenceValue\": {\n                    \"classname\": \"org.meveo.model.scripts.ScriptInstance\",\n                    \"code\": \"org.meveo.service.script.NeolaneCustomerLifeFirstRejectScript\"\n                } \n            } ,\n            {\n                \"code\": \"ScriptingJob_variables\",\n                \"mapValue\": {\n                }\n            }\n        ]\n    }\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/jobInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"jobInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLifeResiliationNotif",
							"event": [
								{
									"listen": "test",
									"script": {
										"id": "83d4419b-d4f7-4b69-8b09-5b8c037881ff",
										"exec": [
											"var jsonData = JSON.parse(responseBody);",
											"tests[\"is.success\"] = jsonData.status === \"SUCCESS\";"
										],
										"type": "text/javascript"
									}
								}
							],
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										},
										{
											"key": "saveHelperData",
											"value": true,
											"type": "boolean"
										},
										{
											"key": "showPassword",
											"value": false,
											"type": "boolean"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"NeolaneCustomerLifeResiliationNotif\",\n    \"classNameFilter\": \"org.meveo.model.billing.Subscription\",\n    \"eventTypeFilter\": \"RENEWAL_UPDATED\",\n    \"elFilter\" : \"#{event.entity.subscriptionRenewal != null && event.entity.subscriptionRenewal.autoRenew == true && event.previousState  != null && event.previousState.autoRenew == false}\",\n    \"scriptInstanceCode\": \"org.meveo.service.script.NeolaneCustomerLifeResiliationScript\",\n    \"priority\":65,\n\t\"scriptParams\": {\n\t\t\"subscription\" : \"#{event.entity}\",\n\t\t\"currentState\" : \"#{event.currentState}\",\n\t\t\"previousState\" : \"#{event.previousState}\"\n\t},\n    \"counterTemplate\": null\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/notification/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"notification",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLifeResiliationMass_Job",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"NeolaneCustomerLifeResiliationMass_Job\",\n    \"description\": \"NeolaneCustomerLifeResiliationMass Job\",\n    \"jobCategory\": \"MEDIATION\",\n    \"jobTemplate\": \"ScriptingJob\",\n    \"customFields\": {\n        \"customField\": [\n            {\n                \"code\": \"ScriptingJob_script\",\n                \"entityReferenceValue\": {\n                    \"classname\": \"org.meveo.model.scripts.ScriptInstance\",\n                    \"code\": \"org.meveo.service.script.NeolaneCustomerLifeResiliationMassScript\"\n                } \n            } ,\n            {\n                \"code\": \"ScriptingJob_variables\",\n                \"mapValue\": {\n                }\n            }\n        ]\n    }\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/jobInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"jobInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "NeolaneCustomerLifeRefund_Job",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"NeolaneCustomerLifeRefund_Job\",\n    \"description\": \"NeolaneCustomerLifeRefund Job\",\n    \"jobCategory\": \"MEDIATION\",\n    \"jobTemplate\": \"ScriptingJob\",\n    \"customFields\": {\n        \"customField\": [\n            {\n                \"code\": \"ScriptingJob_script\",\n                \"entityReferenceValue\": {\n                    \"classname\": \"org.meveo.model.scripts.ScriptInstance\",\n                    \"code\": \"org.meveo.service.script.NeolaneCustomerLifeRefundScript\"\n                } \n            } ,\n            {\n                \"code\": \"ScriptingJob_variables\",\n                \"mapValue\": {\n                }\n            }\n        ]\n    }\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/jobInstance/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"jobInstance",
										"createOrUpdate"
									]
								}
							},
							"response": []
						},
						{
							"name": "Create CF : REJECT_BULK_START",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"REJECT_BULK_START\",\n    \"description\": \"Debut traitement des rejets en masse\",\n    \"fieldType\": \"LONG\",\n    \"defaultValue\":1,\n    \"minValue\":1,\n    \"maxValue\":31,\n    \"appliesTo\": \"JOB_ScriptingJob\",\n    \"storageType\": \"SINGLE\",\n    \"applicableOnEl\" : \"#{entity.code.equals('NeolaneCustomerLifeFirstRejectJob')}\",\n    \"valueRequired\": true,\n    \"versionable\": false,\n    \"triggerEndPeriodEvent\": false,\n    \"allowEdit\": true,\n    \"hideOnNew\": false,\n    \"cacheValue\": false\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/customFieldTemplate/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"customFieldTemplate",
										"createOrUpdate"
									]
								},
								"description": "Custom field aimed to flag a contract (Subscrition) in order to filter payments to represent or retry."
							},
							"response": []
						},
						{
							"name": "Create CF : REJECT_BULK_END",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"REJECT_BULK_END\",\n    \"description\": \"Fin traitement des rejets en masse\",\n    \"fieldType\": \"LONG\",\n    \"defaultValue\":15,\n    \"minValue\":1,\n    \"maxValue\":31,\n    \"appliesTo\": \"JOB_ScriptingJob\",\n    \"storageType\": \"SINGLE\",\n    \"applicableOnEl\" : \"#{entity.code.equals('NeolaneCustomerLifeFirstRejectJob')}\",\n    \"valueRequired\": false,\n    \"versionable\": false,\n    \"triggerEndPeriodEvent\": false,\n    \"allowEdit\": true,\n    \"hideOnNew\": false,\n    \"cacheValue\": false\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/customFieldTemplate/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"customFieldTemplate",
										"createOrUpdate"
									]
								},
								"description": "Custom field aimed to flag a contract (Subscrition) in order to filter payments to represent or retry."
							},
							"response": []
						},
						{
							"name": "Create CF_FD_URL_WS_NCLS",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"value": "{{proxy.auth}}",
										"type": "text"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"CF_FD_URL_WS_NCLS\",\n    \"description\": \"URL pour l'appel du WS Neolane\",\n    \"fieldType\": \"STRING\",\n    \"appliesTo\": \"PROVIDER\",\n    \"storageType\": \"SINGLE\",\n    \"defaultValue\" : \"http://ws.neolane.rec1.fr.fnac.dev/nms/jsp/rtMsg.jsp\",\n    \"maxValue\" : 100,\n    \"valueRequired\": false,\n    \"versionable\": false,\n    \"triggerEndPeriodEvent\": false,\n    \"allowEdit\": true,\n    \"hideOnNew\": false,\n    \"cacheValue\": false\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/customFieldTemplate/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"customFieldTemplate",
										"createOrUpdate"
									]
								},
								"description": "https://www.freeformatter.com/java-dotnet-escape.html#ad-output"
							},
							"response": []
						},
						{
							"name": "Create CF_FD_URL_SELFCARE_NCLS",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"CF_FD_URL_SELFCARE_NCLS\",\n    \"description\": \"URL SELFCARE envoye au WS Neolane\",\n    \"fieldType\": \"STRING\",\n    \"appliesTo\": \"PROVIDER\",\n    \"storageType\": \"SINGLE\",\n    \"defaultValue\" : \"https://abonnes.fd-recette.net/selfcare\",\n    \"maxValue\" : 100,\n    \"valueRequired\": false,\n    \"versionable\": false,\n    \"triggerEndPeriodEvent\": false,\n    \"allowEdit\": true,\n    \"hideOnNew\": false,\n    \"cacheValue\": false\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/customFieldTemplate/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"customFieldTemplate",
										"createOrUpdate"
									]
								},
								"description": "https://www.freeformatter.com/java-dotnet-escape.html#ad-output"
							},
							"response": []
						},
						{
							"name": "Create CF_FD_ACTION_URI_WS_NCLS",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"CF_FD_ACTION_URI_WS_NCLS\",\n    \"description\": \"ACTION Submit du WS Neolane\",\n    \"fieldType\": \"STRING\",\n    \"appliesTo\": \"PROVIDER\",\n    \"storageType\": \"SINGLE\",\n    \"defaultValue\" : \"http://ws.neolane.rec1.fr.fnac.dev/nms/jsp/rtMsg.jsp#Submit\",\n    \"maxValue\" : 100,\n    \"valueRequired\": false,\n    \"versionable\": false,\n    \"triggerEndPeriodEvent\": false,\n    \"allowEdit\": true,\n    \"hideOnNew\": false,\n    \"cacheValue\": false\n}\n"
								},
								"url": {
									"raw": "{{opencell.url}}/customFieldTemplate/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"customFieldTemplate",
										"createOrUpdate"
									]
								},
								"description": "https://www.freeformatter.com/java-dotnet-escape.html#ad-output"
							},
							"response": []
						},
						{
							"name": "Create CF_FD_URL_SERENITE_NCLS",
							"request": {
								"auth": {
									"type": "basic",
									"basic": [
										{
											"key": "username",
											"value": "{{opencell.username}}",
											"type": "string"
										},
										{
											"key": "password",
											"value": "{{opencell.password}}",
											"type": "string"
										}
									]
								},
								"method": "POST",
								"header": [
									{
										"key": "Content-Type",
										"value": "application/json"
									},
									{
										"key": "Proxy-Authorization",
										"type": "text",
										"value": "{{proxy.auth}}"
									}
								],
								"body": {
									"mode": "raw",
									"raw": "{\n    \"code\": \"CF_FD_URL_SERENITE_NCLS\",\n    \"description\": \"URL SERENITE envoye au WS Neolane\",\n    \"fieldType\": \"STRING\",\n    \"appliesTo\": \"PROVIDER\",\n    \"storageType\": \"SINGLE\",\n    \"defaultValue\" : \"https://recette.fnacserenite.com/activation?key=\",\n    \"maxValue\" : 100,\n    \"valueRequired\": false,\n    \"versionable\": false,\n    \"triggerEndPeriodEvent\": false,\n    \"allowEdit\": true,\n    \"hideOnNew\": false,\n    \"cacheValue\": false\n}"
								},
								"url": {
									"raw": "{{opencell.url}}/customFieldTemplate/createOrUpdate",
									"host": [
										"{{opencell.url}}"
									],
									"path": [
										"customFieldTemplate",
										"createOrUpdate"
									]
								},
								"description": "https://www.freeformatter.com/java-dotnet-escape.html#ad-output"
							},
							"response": []
						}
					],
					"_postman_isSubFolder": true
				}
			]
		},
		{
			"name": "CF_PROV_PROVIDER_VERSION",
			"event": [
				{
					"listen": "test",
					"script": {
						"id": "533db33d-45ae-448e-bc6a-114c52d19a0d",
						"exec": [
							"var jsonData = JSON.parse(responseBody);",
							"tests[\"is.success\"] = jsonData.status === \"SUCCESS\";"
						],
						"type": "text/javascript"
					}
				}
			],
			"request": {
				"auth": {
					"type": "basic",
					"basic": [
						{
							"key": "username",
							"value": "{{opencell.username}}",
							"type": "string"
						},
						{
							"key": "password",
							"value": "{{opencell.password}}",
							"type": "string"
						},
						{
							"key": "saveHelperData",
							"value": true,
							"type": "boolean"
						},
						{
							"key": "showPassword",
							"value": false,
							"type": "boolean"
						}
					]
				},
				"method": "POST",
				"header": [
					{
						"key": "Authorization",
						"value": "Basic b3BlbmNlbGwuYWRtaW46b3BlbmNlbGwuYWRtaW4="
					},
					{
						"key": "Content-Type",
						"value": "application/json"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\r\n    \"code\": \"{{request.label}}_{{$timestamp}}\",\r\n    \"description\": \"{{project.code}} {{project.type}} {{project.version}}\",\r\n    \"fieldType\": \"STRING\",\r\n    \"appliesTo\": \"PROVIDER\",\r\n    \"defaultValue\": \"{{timestamp.iso}}\",\r\n    \"storageType\": \"SINGLE\",\r\n    \"valueRequired\": false,\r\n    \"versionable\": false,\r\n    \"allowEdit\": false,\r\n    \"hideOnNew\": false,\r\n    \"cacheValue\": false,\r\n    \"guiPosition\": \"tab:Project versions:999\"\r\n}\r\n"
				},
				"url": {
					"raw": "{{opencell.url}}/customFieldTemplate/createOrUpdate",
					"host": [
						"{{opencell.url}}"
					],
					"path": [
						"customFieldTemplate",
						"createOrUpdate"
					]
				}
			},
			"response": []
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"id": "351bba63-d110-4a17-aa31-5dd5e01e03f9",
				"type": "text/javascript",
				"exec": [
					"pm.globals.set(\"timestamp.iso\", (new Date()).toISOString());",
					"pm.globals.set(\"request.label\", pm.info.requestName);",
					"",
					"var parts = pm.info.requestName.split(\"|\");",
					"",
					"for(let i=0; i<parts.length; i++) {",
					"    pm.globals.set(\"request.label.\"+i, parts[i]);",
					"}",
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"id": "41a93d89-7b80-42da-a5d0-75de0101172b",
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"id": "a3c2234c-c611-4b46-8f7f-116afb016b6e",
			"key": "template.code",
			"value": "FD",
			"type": "string"
		},
		{
			"id": "ff42ae7c-d690-4045-b3d3-82698ca82d26",
			"key": "template.label",
			"value": "Fnac-Darty",
			"type": "string"
		},
		{
			"id": "c3c94695-2da0-4a81-8ab9-a65561b53264",
			"key": "provider.code",
			"value": "ABO",
			"type": "string"
		},
		{
			"id": "0d95d347-bc1b-4cae-9472-44350ef566e6",
			"key": "project.code",
			"value": "FnacDarty-370",
			"type": "string"
		},
		{
			"id": "5c533c04-8631-4f77-a035-9682153b8bb6",
			"key": "project.description",
			"value": "Fnac-Darty Abo",
			"type": "string"
		},
		{
			"id": "d1e49b45-c090-4b1e-9d46-62ec19c4ee2e",
			"key": "project.type",
			"value": "Patch",
			"type": "string"
		},
		{
			"id": "f3c59d83-8db7-40e1-af3d-aaa371f9411d",
			"key": "project.version",
			"value": "20190225_1",
			"type": "string"
		}
	]
}