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

        <attribute name="order">
            <attribute name="createdAt">DESC</attribute>
        </attribute>

        <collectionOperations>
            <collectionOperation name="admin_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/payments</attribute>
                <attribute name="filters">
                    <attribute>sylius.api.search_payment_filter</attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:payment:index</attribute>
                        <attribute>sylius:admin:payment:index</attribute>
                    </attribute>
                </attribute>
            </collectionOperation>
        </collectionOperations>

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

            <itemOperation name="shop_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/shop/payments/{id}</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>shop:payment:show</attribute>
                        <attribute>sylius:shop:payment:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_complete">
                <attribute name="method">PATCH</attribute>
                <attribute name="input">false</attribute>
                <attribute name="path">/admin/payments/{id}/complete</attribute>
                <attribute name="controller">Sylius\Bundle\ApiBundle\Applicator\PaymentStateMachineTransitionApplicatorInterface::complete</attribute>
                <attribute name="openapi_context">
                    <attribute name="summary">Completes Payment.</attribute>
                </attribute>
            </itemOperation>
        </itemOperations>

        <subresourceOperations>
            <subresourceOperation name="api_orders_payments_get_subresource">
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:payment:show</attribute>
                        <attribute>sylius:admin:payment:show</attribute>
                    </attribute>
                </attribute>
            </subresourceOperation>
        </subresourceOperations>

        <property name="id" identifier="true" writable="false" />
        <property name="createdAt" writable="false" />
        <property name="updatedAt" writable="false" />
        <property name="currencyCode" writable="false" />
        <property name="amount" writable="false" />
        <property name="state" writable="false" />
        <property name="details" writable="false" />
        <property name="order" writable="false" />
    </resource>
</resources>
