<?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.product_option.class%" shortName="ProductOption">
        <attribute name="validation_groups">sylius</attribute>

        <attribute name="order">
            <attribute name="position">ASC</attribute>
        </attribute>

        <collectionOperations>
            <collectionOperation name="admin_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/product-options</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_option:index</attribute>
                        <attribute>sylius:admin:product_option:index</attribute>
                    </attribute>
                </attribute>
            </collectionOperation>

            <collectionOperation name="admin_post">
                <attribute name="method">POST</attribute>
                <attribute name="path">/admin/product-options</attribute>
                <attribute name="denormalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_option:create</attribute>
                        <attribute>sylius:admin:product_option:create</attribute>
                    </attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_option:show</attribute>
                        <attribute>sylius:admin:product_option:show</attribute>
                    </attribute>
                </attribute>
            </collectionOperation>
        </collectionOperations>

        <itemOperations>
            <itemOperation name="admin_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/product-options/{code}</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_option:show</attribute>
                        <attribute>sylius:admin:product_option:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="shop_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/shop/product-options/{code}</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>shop:product_option:show</attribute>
                        <attribute>sylius:shop:product_option:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_put">
                <attribute name="method">PUT</attribute>
                <attribute name="path">/admin/product-options/{code}</attribute>
                <attribute name="denormalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_option:update</attribute>
                        <attribute>sylius:admin:product_option:update</attribute>
                    </attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:product_option:show</attribute>
                        <attribute>sylius:admin:product_option:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_delete">
                <attribute name="method">DELETE</attribute>
                <attribute name="path">/admin/product-options/{code}</attribute>
            </itemOperation>
        </itemOperations>

        <subresourceOperations>
            <subresourceOperation name="values_get_subresource">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/product-options/{code}/values</attribute>
            </subresourceOperation>
        </subresourceOperations>

        <property name="id" identifier="false" writable="false" />
        <property name="code" identifier="true" required="true" />
        <property name="createdAt" writable="false" />
        <property name="updatedAt" writable="false" />
        <property name="values" readable="true" writable="true">
            <subresource resourceClass="%sylius.model.product_option_value.class%" collection="true" />
        </property>
        <property name="translations" readable="true" writable="true">
            <attribute name="openapi_context">
                <attribute name="type">object</attribute>
                <attribute name="example">
                    <attribute name="en_US">
                        <attribute name="name">string</attribute>
                    </attribute>
                </attribute>
            </attribute>
        </property>
    </resource>

</resources>
