<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
		<tab id="magesales" translate="label" sortOrder="100">
            <label>Magesales.com</label>
        </tab>
        <section id="addresvalidation" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
            <class>separator-top</class>
            <label>Address Validation</label>
            <tab>magesales</tab>
            <resource>Magesales_AddressValidation::system_config</resource>	

                <group id="general" translate="label" type="group" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>General</label>
                    <field id="enable" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Enable</label>
                        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                        <config_path>addressvalidation/general/enable</config_path>
                    </field>
                    <field id="allow_not_valid_address" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Allow Invalid Address Checkout</label>
                        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                        <comment>If yes, then customers with an invalid address will be able to place their order. If no, customer will have to provide a valid address to place order.</comment>
                        <config_path>addressvalidation/general/allow_not_valid_address</config_path>
                    </field>
                </group>

                <group id="content" translate="label" type="group" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Content</label>
                    <field id="header" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Validation Pop-up Title</label>
                        <config_path>addressvalidation/content/header</config_path>
                    </field>
                    <field id="message" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Invalid Address Message</label>
                        <config_path>addressvalidation/content/message</config_path>
                    </field>
                    <field id="origin_address" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Original Address</label>
                        <config_path>addressvalidation/content/origin_address</config_path>
                    </field>
                    <field id="suggested_address" translate="label" type="text" sortOrder="40" showInDefault="1"
                           showInWebsite="1" showInStore="1">
                        <label>Suggested Address</label>
                        <config_path>addressvalidation/content/suggested_address</config_path>
                    </field>
                </group>

                <group id="api_settings" translate="label" type="group" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
                    <label>Validation Settings</label>

                    <field id="validtion" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="0" showInStore="0">
                        <frontend_model>Magesales\AddressValidation\Block\Adminhtml\System\Config\Validation</frontend_model>
                        <config_path>addressvalidation/api_settings/validtion</config_path>
                    </field>

                    <field id="mode" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Validation Service</label>
                        <source_model>Magesales\AddressValidation\Model\Config\Source\ValidationMode</source_model>
                        <config_path>addressvalidation/api_settings/mode</config_path>
                    </field>

                    <!-- UPS -->
                    <field id="ups_test_mode" translate="label" type="select" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Test Mode</label>
                        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                        <depends>
                            <field id="mode">ups</field>
                        </depends>
                        <config_path>addressvalidation/api_settings/ups_test_mode</config_path>
                    </field>
                    <field id="ups_login" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Login</label>
                        <depends>
                            <field id="mode">ups</field>
                        </depends>
                        <config_path>addressvalidation/api_settings/ups_login</config_path>
                    </field>
                    <field id="ups_password" translate="label" type="obscure" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Password</label>
                        <backend_model>Magento\Config\Model\Config\Backend\Encrypted</backend_model>
                        <depends>
                            <field id="mode">ups</field>
                        </depends>
                        <config_path>addressvalidation/api_settings/ups_password</config_path>
                    </field>
                    <field id="ups_access_key" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Access Key</label>
                        <depends>
                            <field id="mode">ups</field>
                        </depends>
                        <config_path>addressvalidation/api_settings/ups_access_key</config_path>
                    </field>
                    <field id="ups_show_address_type" translate="label" type="select" sortOrder="60" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Display Address Type</label>
                        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                        <depends>
                            <field id="mode">ups</field>
                        </depends>
                        <comment>Allow to display type (Residential/Commercial) of suggested address in validation pop-up.</comment>
                        <config_path>addressvalidation/api_settings/ups_show_address_type</config_path>
                    </field>

                    <!-- USPS -->
                    <field id="usps_test_mode" translate="label" type="select" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Test Mode</label>
                        <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                        <depends>
                            <field id="mode">usps</field>
                        </depends>
                        <config_path>addressvalidation/api_settings/usps_test_mode</config_path>
                    </field>
                    <field id="usps_account_id" translate="label" type="text" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>Account ID</label>
                        <depends>
                            <field id="mode">usps</field>
                        </depends>
                        <config_path>addressvalidation/api_settings/usps_account_id</config_path>
                    </field>

                    <!-- Google -->
                    <field id="google_key" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
                        <label>API Key</label>
                        <depends>
                            <field id="mode">google</field>
                        </depends>
                        <comment><![CDATA[<a href="https://developers.google.com/maps/documentation/geocoding/get-api-key">Get a Key for Google Maps Geocoding API.</a>]]></comment>
                        <config_path>addressvalidation/api_settings/google_key</config_path>
                    </field>
                </group>
        </section>
    </system>
</config>
