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

        <collectionOperations>
            <collectionOperation name="admin_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/exchange-rates</attribute>
                <attribute name="filters">
                    <attribute>Sylius\Bundle\ApiBundle\Filter\Doctrine\ExchangeRateFilter</attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:exchange_rate:index</attribute>
                        <attribute>sylius:admin:exchange_rate:index</attribute>
                    </attribute>
                </attribute>
            </collectionOperation>

            <collectionOperation name="shop_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/shop/exchange-rates</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>shop:exchange_rate:index</attribute>
                        <attribute>sylius:shop:exchange_rate:index</attribute>
                    </attribute>
                </attribute>
            </collectionOperation>

            <collectionOperation name="admin_post">
                <attribute name="method">POST</attribute>
                <attribute name="path">/admin/exchange-rates</attribute>
                <attribute name="denormalization_context">
                    <attribute name="groups">
                        <attribute>admin:exchange_rate:create</attribute>
                        <attribute>sylius:admin:exchange_rate:create</attribute>
                    </attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:exchange_rate:show</attribute>
                        <attribute>sylius:admin:exchange_rate:show</attribute>
                    </attribute>
                </attribute>
            </collectionOperation>
        </collectionOperations>

        <itemOperations>
            <itemOperation name="admin_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/exchange-rates/{id}</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:exchange_rate:show</attribute>
                        <attribute>sylius:admin:exchange_rate:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="shop_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/shop/exchange-rates/{id}</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>shop:exchange_rate:show</attribute>
                        <attribute>sylius:shop:exchange_rate:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_put">
                <attribute name="method">PUT</attribute>
                <attribute name="path">/admin/exchange-rates/{id}</attribute>
                <attribute name="denormalization_context">
                    <attribute name="groups">
                        <attribute>admin:exchange_rate:update</attribute>
                        <attribute>sylius:admin:exchange_rate:update</attribute>
                    </attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:exchange_rate:show</attribute>
                        <attribute>sylius:admin:exchange_rate:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_delete">
                <attribute name="method">DELETE</attribute>
                <attribute name="path">/admin/exchange-rates/{id}</attribute>
            </itemOperation>
        </itemOperations>

        <property name="id" identifier="true" writable="false" />
        <property name="ratio" identifier="false" required="true" />
        <property name="sourceCurrency" identifier="false" required="true" />
        <property name="targetCurrency" identifier="false" required="true" />
        <property name="createdAt" writable="false" />
        <property name="updatedAt" writable="false" />
    </resource>
</resources>
