<?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.avatar_image.class%" shortName="AvatarImage">
        <attribute name="route_prefix">admin</attribute>

        <collectionOperations>
            <collectionOperation name="admin_post">
                <attribute name="method">POST</attribute>
                <attribute name="controller">Sylius\Bundle\ApiBundle\Controller\UploadAvatarImageAction</attribute>
                <attribute name="deserialize">false</attribute>
                <attribute name="openapi_context">
                    <attribute name="requestBody">
                        <attribute name="content">
                            <attribute name="multipart/form-data">
                                <attribute name="schema">
                                    <attribute name="type">object</attribute>
                                    <attribute name="properties">
                                        <attribute name="file">
                                            <attribute name="type">string</attribute>
                                            <attribute name="format">binary</attribute>
                                        </attribute>
                                        <attribute name="owner">
                                            <attribute name="type">string</attribute>
                                            <attribute name="format">iri-reference</attribute>
                                        </attribute>
                                    </attribute>
                                </attribute>
                            </attribute>
                        </attribute>
                    </attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:avatar_image:show</attribute>
                        <attribute>sylius:admin:avatar_image:show</attribute>
                    </attribute>
                </attribute>
            </collectionOperation>
        </collectionOperations>

        <itemOperations>
            <itemOperation name="admin_get">
                <attribute name="method">GET</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:avatar_image:show</attribute>
                        <attribute>sylius:admin:avatar_image:show</attribute>
                    </attribute>
                </attribute>
                <attribute name="openapi_context">
                    <attribute name="parameters">
                        <attribute>
                            <attribute name="name">imageFilter</attribute>
                            <attribute name="in">query</attribute>
                            <attribute name="description">Provide one of supported image liip imagine filters</attribute>
                            <attribute name="schema">
                                <attribute name="type">string</attribute>
                            </attribute>
                        </attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_delete">
                <attribute name="method">DELETE</attribute>
            </itemOperation>
        </itemOperations>

        <property name="id" identifier="true" writable="false" />
        <property name="path" required="true" />
        <property name="owner" required="true" />
    </resource>
</resources>
