<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one or more
  ~ contributor license agreements.  See the NOTICE file distributed with
  ~ this work for additional information regarding copyright ownership.
  ~ The ASF licenses this file to You under the Apache License, Version 2.0
  ~ (the "License"); you may not use this file except in compliance with
  ~ the License.  You may obtain a copy of the License at
  ~
  ~      http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<blueprint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
           xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
           xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

    <cm:property-placeholder persistent-id="org.apache.unomi.sfdc"
                             update-strategy="reload">
        <cm:default-properties>
            <cm:property name="sfdc.login.endpoint" value="https://login.salesforce.com"/>
            <cm:property name="sfdc.user.username" value=""/>
            <cm:property name="sfdc.user.password" value=""/>
            <cm:property name="sfdc.user.securityToken" value=""/>
            <cm:property name="sfdc.consumer.key" value=""/>
            <cm:property name="sfdc.consumer.secret" value=""/>
            <cm:property name="sfdc.channel" value="/topic/LeadUpdates"/>
            <cm:property name="sfdc.fields.mappings.identifier" value=""/>
            <cm:property name="sfdc.fields.mappings" value=""/>
            <cm:property name="sfdc.session.timeout" value="900000"/>
            <cm:property name="sfdc.checkIfContactExistBeforeLeadCreation" value="false"/>
            <cm:property name="sfdc.fields.consents" value=""/>
        </cm:default-properties>
    </cm:property-placeholder>

    <reference id="persistenceService"
               interface="org.apache.unomi.persistence.spi.PersistenceService"/>

    <bean id="defaultSFDCConfiguration" class="org.apache.unomi.sfdc.services.SFDCConfiguration">
        <property name="itemId" value="sfdcConfiguration"/>
        <property name="sfdcLoginEndpoint" value="${sfdc.login.endpoint}"/>
        <property name="sfdcUserUsername" value="${sfdc.user.username}"/>
        <property name="sfdcUserPassword" value="${sfdc.user.password}"/>
        <property name="sfdcUserSecurityToken" value="${sfdc.user.securityToken}"/>
        <property name="sfdcConsumerKey" value="${sfdc.consumer.key}"/>
        <property name="sfdcConsumerSecret" value="${sfdc.consumer.secret}"/>
        <property name="sfdcChannel" value="${sfdc.channel}"/>
        <property name="sfdcFieldMappings" value="${sfdc.fields.mappings}"/>
        <property name="sfdcFieldMappingsIdentifier" value="${sfdc.fields.mappings.identifier}"/>
        <property name="sfdcSessionTimeout" value="${sfdc.session.timeout}" />
        <property name="sfdcFieldsConsents" value="${sfdc.fields.consents}" />
        <property name="sfdcCheckIfContactExistBeforeLeadCreation"
                  value="${sfdc.checkIfContactExistBeforeLeadCreation}"/>
    </bean>

    <bean id="sfdcServiceImpl" class="org.apache.unomi.sfdc.services.internal.SFDCServiceImpl" init-method="start"
          destroy-method="stop">
        <property name="defaultSFDCConfiguration" ref="defaultSFDCConfiguration" />
        <property name="persistenceService" ref="persistenceService" />
    </bean>

    <service id="sfdcService" ref="sfdcServiceImpl" interface="org.apache.unomi.sfdc.services.SFDCService"/>

</blueprint>
