<?xml version="1.0" ?>

<!--

 This file is part of the Sylius package.

 (c) Sylius Sp. z o.o.

 For the full copyright and license information, please view the LICENSE
 file that was distributed with this source code.

-->

<resources xmlns="https://api-platform.com/schema/metadata"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="https://api-platform.com/schema/metadata https://api-platform.com/schema/metadata/metadata-2.0.xsd"
>
    <resource class="%sylius.model.adjustment.class%" shortName="Adjustment">
        <collectionOperations />

        <itemOperations>
            <itemOperation name="admin_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/adjustments/{id}</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:adjustment:show</attribute>
                        <attribute>sylius:admin:adjustment:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="shop_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/shop/adjustments/{id}</attribute>
                <attribute name="controller">ApiPlatform\Core\Action\NotFoundAction</attribute>
                <attribute name="read">false</attribute>
                <attribute name="output">false</attribute>
            </itemOperation>
        </itemOperations>

        <subresourceOperations>
            <subresourceOperation name="api_orders_adjustments_get_subresource">
                <attribute name="access_control">is_granted('SYLIUS_ORDER_ADJUSTMENT', object)</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>shop:cart:show</attribute>
                        <attribute>sylius:shop:cart:show</attribute>
                    </attribute>
                </attribute>
            </subresourceOperation>

            <subresourceOperation name="api_orders_items_adjustments_get_subresource">
                <attribute name="access_control">is_granted('SYLIUS_ORDER_ADJUSTMENT', object)</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>shop:cart:show</attribute>
                        <attribute>sylius:shop:cart:show</attribute>
                    </attribute>
                </attribute>
            </subresourceOperation>

            <subresourceOperation name="api_order_items_adjustments_get_subresource">
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:order_item:index</attribute>
                        <attribute>sylius:admin:order_item:index</attribute>
                    </attribute>
                </attribute>
            </subresourceOperation>

            <subresourceOperation name="api_order_item_units_adjustments_get_subresource">
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:order_item_unit:index</attribute>
                        <attribute>sylius:admin:order_item_unit:index</attribute>
                    </attribute>
                </attribute>
            </subresourceOperation>

            <subresourceOperation name="api_shipments_adjustments_get_subresource">
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:shipment:index</attribute>
                        <attribute>sylius:admin:shipment:index</attribute>
                    </attribute>
                </attribute>
            </subresourceOperation>
        </subresourceOperations>

        <property name="id" identifier="true" writable="false" />
        <property name="type" writable="false" />
        <property name="label" writable="false" />
        <property name="amount" writable="false" />
        <property name="order" writable="false" />
        <property name="orderItem" writable="false" />
        <property name="orderItemUnit" writable="false" />
        <property name="shipment" writable="false" />
        <property name="neutral" writable="false" />
        <property name="locked" writable="false" />
    </resource>
</resources>
