<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
    <extension_attributes for="Magento\Catalog\Api\Data\ProductInterface">
        <attribute code="preorder_info" type="Amasty\Preorder\Api\Data\ProductInformationInterface" />
    </extension_attributes>

    <extension_attributes for="Magento\Quote\Api\Data\CartItemInterface">
        <attribute code="preorder_info" type="Amasty\Preorder\Api\Data\CartItemInformationInterface" />
    </extension_attributes>

    <extension_attributes for="Magento\Quote\Api\Data\TotalsItemInterface">
        <attribute code="preorder_info" type="Amasty\Preorder\Api\Data\CartItemInformationInterface" />
    </extension_attributes>

    <extension_attributes for="Magento\Sales\Api\Data\OrderInterface">
        <attribute code="preorder_info" type="Amasty\Preorder\Api\Data\OrderInformationInterface">
            <join reference_table="amasty_preorder_order_preorder"
                  reference_field="order_id"
                  join_on_field="entity_id">
                <field>is_preorder</field>
                <field>warning</field>
            </join>
        </attribute>
    </extension_attributes>

    <extension_attributes for="Magento\Sales\Api\Data\OrderItemInterface">
        <attribute code="preorder_info" type="Amasty\Preorder\Api\Data\OrderItemInformationInterface">
            <join reference_table="amasty_preorder_order_item_preorder"
                  reference_field="order_item_id"
                  join_on_field="item_id">
                <field>is_preorder</field>
                <field>preorder_note</field>
            </join>
        </attribute>
    </extension_attributes>
</config>
