mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[API] Configure Promotion Creation endpoint
This commit is contained in:
parent
af0208dbc7
commit
a4df68ef6b
8 changed files with 144 additions and 116 deletions
|
|
@ -30,6 +30,72 @@
|
|||
</normalizationContext>
|
||||
</operation>
|
||||
|
||||
<operation class="ApiPlatform\Metadata\Post" uriTemplate="/admin/promotions">
|
||||
<validationContext>
|
||||
<values>
|
||||
<value name="groups">
|
||||
<values>
|
||||
<value>sylius</value>
|
||||
<value>sylius_api</value>
|
||||
</values>
|
||||
</value>
|
||||
</values>
|
||||
</validationContext>
|
||||
|
||||
<denormalizationContext>
|
||||
<values>
|
||||
<value name="groups">
|
||||
<values>
|
||||
<value>sylius:admin:promotion:create</value>
|
||||
</values>
|
||||
</value>
|
||||
</values>
|
||||
</denormalizationContext>
|
||||
|
||||
<normalizationContext>
|
||||
<values>
|
||||
<value name="groups">
|
||||
<values>
|
||||
<value>sylius:admin:promotion:show</value>
|
||||
</values>
|
||||
</value>
|
||||
</values>
|
||||
</normalizationContext>
|
||||
|
||||
<openapiContext>
|
||||
<values>
|
||||
<value name="description">
|
||||
Example configuration for `total_of_items_from_taxon` rule type:
|
||||
|
||||
```
|
||||
{
|
||||
"type": "total_of_items_from_taxon",
|
||||
"configuration": {
|
||||
"channel-code": {
|
||||
"taxon": "taxon-code",
|
||||
"amount": int
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Example configuration for `order_fixed_discount` action type:
|
||||
|
||||
```
|
||||
{
|
||||
"type": "order_fixed_discount",
|
||||
"configuration": {
|
||||
"channel-code": {
|
||||
"amount": int,
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
</value>
|
||||
</values>
|
||||
</openapiContext>
|
||||
</operation>
|
||||
|
||||
<operation
|
||||
class="ApiPlatform\Metadata\Patch"
|
||||
uriTemplate="/admin/promotions/{code}/archive"
|
||||
|
|
@ -100,6 +166,7 @@
|
|||
</normalizationContext>
|
||||
</operation>
|
||||
|
||||
|
||||
<operation
|
||||
class="ApiPlatform\Metadata\Delete"
|
||||
uriTemplate="/admin/promotions/{code}"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
<?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/resources-3.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0 https://api-platform.com/schema/metadata/resources-3.0.xsd"
|
||||
>
|
||||
<resource class="Sylius\Component\Promotion\Model\PromotionAction">
|
||||
<operations>
|
||||
<operation class="ApiPlatform\Metadata\NotExposed" uriTemplate="/admin/promotions/{code}/actions/{id}">
|
||||
<uriVariables>
|
||||
<uriVariable parameterName="code" fromClass="Sylius\Component\Core\Model\Promotion" fromProperty="rules"/>
|
||||
<uriVariable parameterName="id" fromClass="Sylius\Component\Promotion\Model\PromotionAction"/>
|
||||
</uriVariables>
|
||||
</operation>
|
||||
</operations>
|
||||
</resource>
|
||||
</resources>
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?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/resources-3.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0 https://api-platform.com/schema/metadata/resources-3.0.xsd"
|
||||
>
|
||||
<resource class="Sylius\Component\Promotion\Model\PromotionRule">
|
||||
<operations>
|
||||
<operation class="ApiPlatform\Metadata\NotExposed" uriTemplate="/admin/promotions/{code}/rules/{id}">
|
||||
<uriVariables>
|
||||
<uriVariable parameterName="code" fromClass="Sylius\Component\Core\Model\Promotion" fromProperty="rules"/>
|
||||
<uriVariable parameterName="id" fromClass="Sylius\Component\Promotion\Model\PromotionRule"/>
|
||||
</uriVariables>
|
||||
</operation>
|
||||
</operations>
|
||||
</resource>
|
||||
</resources>
|
||||
|
|
@ -28,54 +28,6 @@
|
|||
</attribute>
|
||||
|
||||
<collectionOperations>
|
||||
<collectionOperation name="admin_post">
|
||||
<attribute name="method">POST</attribute>
|
||||
<attribute name="denormalization_context">
|
||||
<attribute name="groups">
|
||||
<attribute>admin:promotion:create</attribute>
|
||||
<attribute>sylius:admin:promotion:create</attribute>
|
||||
</attribute>
|
||||
</attribute>
|
||||
<attribute name="normalization_context">
|
||||
<attribute name="groups">
|
||||
<attribute>admin:promotion:show</attribute>
|
||||
<attribute>sylius:admin:promotion:show</attribute>
|
||||
</attribute>
|
||||
<!-- It auto-turned on when adding PATCH itemOperations: https://github.com/api-platform/core/issues/3600 -->
|
||||
<attribute name="skip_null_values">false</attribute>
|
||||
</attribute>
|
||||
<attribute name="openapi_context">
|
||||
<attribute name="description">
|
||||
Example configuration for `total_of_items_from_taxon` rule type:
|
||||
|
||||
```
|
||||
{
|
||||
"type": "total_of_items_from_taxon",
|
||||
"configuration": {
|
||||
"channel-code": {
|
||||
"taxon": "taxon-code",
|
||||
"amount": int
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Example configuration for `order_fixed_discount` action type:
|
||||
|
||||
```
|
||||
{
|
||||
"type": "order_fixed_discount",
|
||||
"configuration": {
|
||||
"channel-code": {
|
||||
"amount": int,
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
</attribute>
|
||||
</attribute>
|
||||
</collectionOperation>
|
||||
|
||||
<collectionOperation name="admin_get">
|
||||
<attribute name="method">GET</attribute>
|
||||
<attribute name="normalization_context">
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
<?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.promotion_action.class%" shortName="PromotionAction">
|
||||
<attribute name="route_prefix">admin</attribute>
|
||||
|
||||
<itemOperations>
|
||||
<itemOperation name="admin_get">
|
||||
<attribute name="method">GET</attribute>
|
||||
<attribute name="controller">ApiPlatform\Core\Action\NotFoundAction</attribute>
|
||||
<attribute name="read">false</attribute>
|
||||
<attribute name="output">false</attribute>
|
||||
</itemOperation>
|
||||
</itemOperations>
|
||||
|
||||
<collectionOperations/>
|
||||
|
||||
<property name="id" identifier="true" writable="false" />
|
||||
</resource>
|
||||
</resources>
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
<?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.promotion_rule.class%" shortName="PromotionRule">
|
||||
<attribute name="route_prefix">admin</attribute>
|
||||
|
||||
<itemOperations>
|
||||
<itemOperation name="admin_get">
|
||||
<attribute name="method">GET</attribute>
|
||||
<attribute name="controller">ApiPlatform\Core\Action\NotFoundAction</attribute>
|
||||
<attribute name="read">false</attribute>
|
||||
<attribute name="output">false</attribute>
|
||||
</itemOperation>
|
||||
</itemOperations>
|
||||
|
||||
<collectionOperations/>
|
||||
|
||||
<property name="id" identifier="true" writable="false" />
|
||||
</resource>
|
||||
</resources>
|
||||
|
|
@ -30,36 +30,43 @@
|
|||
<attribute name="name">
|
||||
<group>sylius:admin:promotion:index</group>
|
||||
<group>sylius:admin:promotion:show</group>
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
|
||||
<attribute name="code">
|
||||
<group>sylius:admin:promotion:index</group>
|
||||
<group>sylius:admin:promotion:show</group>
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
|
||||
<attribute name="description">
|
||||
<group>sylius:admin:promotion:index</group>
|
||||
<group>sylius:admin:promotion:show</group>
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
|
||||
<attribute name="priority">
|
||||
<group>sylius:admin:promotion:index</group>
|
||||
<group>sylius:admin:promotion:show</group>
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
|
||||
<attribute name="exclusive">
|
||||
<group>sylius:admin:promotion:index</group>
|
||||
<group>sylius:admin:promotion:show</group>
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
|
||||
<attribute name="appliesToDiscounted">
|
||||
<group>sylius:admin:promotion:index</group>
|
||||
<group>sylius:admin:promotion:show</group>
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
|
||||
<attribute name="usageLimit">
|
||||
<group>sylius:admin:promotion:index</group>
|
||||
<group>sylius:admin:promotion:show</group>
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
|
||||
<attribute name="used">
|
||||
|
|
@ -70,16 +77,19 @@
|
|||
<attribute name="startsAt">
|
||||
<group>sylius:admin:promotion:index</group>
|
||||
<group>sylius:admin:promotion:show</group>
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
|
||||
<attribute name="endsAt">
|
||||
<group>sylius:admin:promotion:index</group>
|
||||
<group>sylius:admin:promotion:show</group>
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
|
||||
<attribute name="couponBased">
|
||||
<group>sylius:admin:promotion:index</group>
|
||||
<group>sylius:admin:promotion:show</group>
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
|
||||
<attribute name="coupons">
|
||||
|
|
@ -90,21 +100,25 @@
|
|||
<attribute name="rules">
|
||||
<group>sylius:admin:promotion:index</group>
|
||||
<group>sylius:admin:promotion:show</group>
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
|
||||
<attribute name="actions">
|
||||
<group>sylius:admin:promotion:index</group>
|
||||
<group>sylius:admin:promotion:show</group>
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
|
||||
<attribute name="channels">
|
||||
<group>sylius:admin:promotion:index</group>
|
||||
<group>sylius:admin:promotion:show</group>
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
|
||||
<attribute name="translations">
|
||||
<group>sylius:admin:promotion:index</group>
|
||||
<group>sylius:admin:promotion:show</group>
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
|
||||
<attribute name="archivedAt">
|
||||
|
|
|
|||
|
|
@ -16,9 +16,14 @@
|
|||
xsi:schemaLocation="http://symfony.com/schema/dic/serializer-mapping https://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd"
|
||||
>
|
||||
<class name="Sylius\Component\Promotion\Model\PromotionTranslation">
|
||||
<attribute name="locale">
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
|
||||
<attribute name="label">
|
||||
<group>sylius:admin:promotion:index</group>
|
||||
<group>sylius:admin:promotion:show</group>
|
||||
<group>sylius:admin:promotion:create</group>
|
||||
</attribute>
|
||||
</class>
|
||||
</serializer>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue