<?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.shipping_method.class%" shortName="ShippingMethod">
        <attribute name="validation_groups">Sylius\Bundle\ShippingBundle\Validator\GroupsGenerator\ShippingMethodConfigurationGroupsGenerator</attribute>

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

        <itemOperations>
            <itemOperation name="admin_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/shipping-methods/{code}</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:shipping_method:show</attribute>
                        <attribute>sylius:admin:shipping_method:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="shop_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/shop/shipping-methods/{code}</attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>shop:shipping_method:show</attribute>
                        <attribute>sylius:shop:shipping_method:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_put">
                <attribute name="method">PUT</attribute>
                <attribute name="path">/admin/shipping-methods/{code}</attribute>
                <attribute name="denormalization_context">
                    <attribute name="groups">
                        <attribute>admin:shipping_method:update</attribute>
                        <attribute>sylius:admin:shipping_method:update</attribute>
                    </attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:shipping_method:show</attribute>
                        <attribute>sylius:admin:shipping_method:show</attribute>
                    </attribute>
                </attribute>
                <attribute name="openapi_context">
                    <attribute name="description">
Example configuration for `total_weight_greater_than_or_equal` rule type:

```
{
    "type": "total_weight_greater_than_or_equal",
    "configuration": {
        "weight": int
    }
}
```

Example configuration for `order_total_greater_than_or_equal` rule type:

```
{
    "type": "order_total_greater_than_or_equal",
    "configuration": {
        "channel-code": [
            "amount": int,
        ]
    }
}
```

Example configuration for `flat_rate` shipping charges calculator:

```
"shippingChargesCalculator": "flat_rate",
"shippingChargesCalculatorConfiguration": {
    "channel-code": [
        "amount": int,
    ]
}
```
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_delete">
                <attribute name="method">DELETE</attribute>
                <attribute name="path">/admin/shipping-methods/{code}</attribute>
            </itemOperation>

            <itemOperation name="admin_archive">
                <attribute name="method">PATCH</attribute>
                <attribute name="path">/admin/shipping-methods/{code}/archive</attribute>
                <attribute name="input">false</attribute>
                <attribute name="controller">Sylius\Bundle\ApiBundle\Applicator\ArchivingShippingMethodApplicatorInterface::archive</attribute>
                <attribute name="openapi_context">
                    <attribute name="summary">Archives Shipping Method.</attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:shipping_method:show</attribute>
                        <attribute>sylius:admin:shipping_method:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>

            <itemOperation name="admin_restore">
                <attribute name="method">PATCH</attribute>
                <attribute name="path">/admin/shipping-methods/{code}/restore</attribute>
                <attribute name="input">false</attribute>
                <attribute name="controller">Sylius\Bundle\ApiBundle\Applicator\ArchivingShippingMethodApplicatorInterface::restore</attribute>
                <attribute name="openapi_context">
                    <attribute name="summary">Restores archived Shipping Method.</attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:shipping_method:show</attribute>
                        <attribute>sylius:admin:shipping_method:show</attribute>
                    </attribute>
                </attribute>
            </itemOperation>
        </itemOperations>

        <collectionOperations>
            <collectionOperation name="admin_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/admin/shipping-methods</attribute>
                <attribute name="filters">
                    <attribute>sylius.api.archived_shipping_methods_filter</attribute>
                    <attribute>sylius.api.shipping_method_order_filter</attribute>
                    <attribute>Sylius\Bundle\ApiBundle\Filter\Doctrine\TranslationOrderNameAndLocaleFilter</attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:shipping_method:index</attribute>
                        <attribute>sylius:admin:shipping_method:index</attribute>
                    </attribute>
                </attribute>
            </collectionOperation>
            <collectionOperation name="shop_get">
                <attribute name="method">GET</attribute>
                <attribute name="path">/shop/shipping-methods</attribute>
                <attribute name="pagination_enabled">false</attribute>
                <attribute name="filters">
                    <attribute>Sylius\Bundle\ApiBundle\Filter\ShippingMethodFilter</attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>shop:shipping_method:index</attribute>
                        <attribute>sylius:shop:shipping_method:index</attribute>
                    </attribute>
                </attribute>
            </collectionOperation>

            <collectionOperation name="admin_post">
                <attribute name="method">POST</attribute>
                <attribute name="path">/admin/shipping-methods</attribute>
                <attribute name="denormalization_context">
                    <attribute name="groups">
                        <attribute>admin:shipping_method:create</attribute>
                        <attribute>sylius:admin:shipping_method:create</attribute>
                    </attribute>
                </attribute>
                <attribute name="normalization_context">
                    <attribute name="groups">
                        <attribute>admin:shipping_method:show</attribute>
                        <attribute>sylius:admin:shipping_method:show</attribute>
                    </attribute>
                </attribute>
                <attribute name="openapi_context">
                    <attribute name="description">
Example configuration for `total_weight_greater_than_or_equal` rule type:

```
{
    "type": "total_weight_greater_than_or_equal",
    "configuration": {
        "weight": int
    }
}
```

Example configuration for `order_total_greater_than_or_equal` rule type:

```
{
    "type": "order_total_greater_than_or_equal",
    "configuration": {
        "channel-code": [
            "amount": int,
        ]
    }
}
```

Example configuration for `flat_rate` shipping charges calculator:

```
"shippingChargesCalculator": "flat_rate",
"shippingChargesCalculatorConfiguration": {
    "channel-code": [
        "amount": int,
    ]
}
```
                    </attribute>
                </attribute>
            </collectionOperation>
        </collectionOperations>

        <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="archivedAt" writable="false" />
        <property name="name" writable="true" />
        <property name="position" writable="true" />
        <property name="enabled" writable="true" />
        <property name="zone" writable="true" />
        <property name="channels" writable="true" />
        <property name="calculator" writable="true" />
        <property name="configuration" writable="true" />
        <property name="rules" readable="true" />
        <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 name="description">string</attribute>
                    </attribute>
                </attribute>
            </attribute>
        </property>
        <property name="description" readable="true" />
    </resource>
</resources>
