<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <!--<type name="Magento\Customer\Model\Customer">
        <plugin name="blulogic_sendsms_register_success" type="Bluelogic\GupShupSms\Plugin\Model\ResourceModel\Customer\SendSms" sortOrder="10" disabled="false"  />
    </type>-->
    <preference for="Magestat\SigninPhoneNumber\Controller\Account\ForgotPasswordPost"
                type="BlueLogic\GupShupSms\Controller\Account\ForgotPasswordPost"/>
    <preference for="Magestat\SigninPhoneNumber\Controller\Account\OTPpost"
                type="BlueLogic\GupShupSms\Controller\Account\OTPpost"/>

    <!-- Whatsapp Message Interface -->
    <preference for="BlueLogic\GupShupSms\Api\Data\WhatsappMessageInterface"
                type="BlueLogic\GupShupSms\Model\Data\WhatsappMessage"/>

    <type name="Magento\Sales\Model\Service\OrderService">
        <plugin name="bluelogic_order_success_whatsapp"
                type="BlueLogic\GupShupSms\Plugin\Order\AfterPlaceOrder"/>
    </type>

    <!-- Custom Logger for GupShup Webhooks -->
    <type name="BlueLogic\GupShupSms\Logger\Handler">
        <arguments>
            <argument name="filesystem" xsi:type="object">Magento\Framework\Filesystem\Driver\File</argument>
        </arguments>
    </type>
    <type name="BlueLogic\GupShupSms\Logger\Logger">
        <arguments>
            <argument name="name" xsi:type="string">gupshup_webhook</argument>
            <argument name="handlers" xsi:type="array">
                <item name="system" xsi:type="object">BlueLogic\GupShupSms\Logger\Handler</item>
            </argument>
        </arguments>
    </type>

    <type name="BlueLogic\GupShupSms\Model\Otp\FallbackProcessor">
        <arguments>
            <argument name="collectionFactory" xsi:type="object">
                BlueLogic\GupShupSms\Model\ResourceModel\WebhookLog\CollectionFactory
            </argument>
            <argument name="smsSender" xsi:type="object">BlueLogic\GupShupSms\Helper\SmsSender</argument>
            <argument name="logger" xsi:type="object">BlueLogic\GupShupSms\Logger\Logger</argument>
        </arguments>
    </type>

    <type name="Mageplaza\AbandonedCart\Model\AbandonedCart">
        <plugin
                name="bl_gupshup_abandonedcart_around"
                type="BlueLogic\GupShupSms\Plugin\Mageplaza\AbandonedCartAroundPlugin"
                sortOrder="10"
        />
    </type>

    <!-- Virtual Type for Grid Collection -->
    <virtualType name="BlueLogic\GupShupSms\Model\ResourceModel\WebhookLog\Grid\Collection"
                 type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">bluelogic_gupshup_webhook_log</argument>
            <argument name="resourceModel" xsi:type="string">BlueLogic\GupShupSms\Model\ResourceModel\WebhookLog
            </argument>
        </arguments>
    </virtualType>

    <!-- Register the virtual type with CollectionFactory -->
    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="bluelogic_gupshupsms_webhooklog_listing_data_source"
                      xsi:type="string">BlueLogic\GupShupSms\Model\ResourceModel\WebhookLog\Grid\Collection
                </item>
            </argument>
        </arguments>
    </type>

</config>




