Skip to content

Commit

Permalink
minor #13659 API Upgrade file updated after ShippingMethod endpoints …
Browse files Browse the repository at this point in the history
…changes (TheMilek)

This PR was merged into the 1.12-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | master <!-- see the comment below -->
| Bug fix?        | no
| New feature?    | no
| Deprecations?   | no <!-- don't forget to update the UPGRADE-*.md file -->
| Related tickets | #13628
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.10 or 1.11 branch(the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set

 To be sure you are not breaking any Backward Compatibilities, check the documentation:
 https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->


Commits
-------

2ee5438 information about shippingMethods endpoints changes documented
  • Loading branch information
GSadee committed Feb 23, 2022
2 parents 88d80df + 2ee5438 commit 584bc76
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions UPGRADE-API-1.12.md
@@ -0,0 +1,61 @@
# UPGRADE FROM `v1.11.X` TO `v1.12.0`

1. The `Sylius\Bundle\ApiBundle\DataProvider\CartShippingMethodsSubresourceDataProvider` has been removed and replaced by `Sylius\Bundle\ApiBundle\DataProvider\ShippingMethodsCollectionDataProvider`.

1. The `Sylius\Bundle\ApiBundle\Serializer\ShippingMethodNormalizer` logic and constructor has been changed due to refactor above.

```diff
public function __construct(
private OrderRepositoryInterface $orderRepository,
private ShipmentRepositoryInterface $shipmentRepository,
private ServiceRegistryInterface $shippingCalculators,
+ private RequestStack $requestStack,
+ private ChannelContextInterface $channelContext
) {
...
}
```

1. The `GET` `api/v2/shop/orders/{token}/shipments/{id}/methods` and `api/v2/shop/shipments/{id}/methods` endpoints have been removed and changed into collection request with 2 parameters `api/v2/shop/shipping-methods?shipmentId={id}&orderToken={token}`.
Now when we do not provide parameters in response it returns all available `shippingMethods` in channel.
Wrong parameters otherwise cause empty array `[]` in response and correct parameters return `shippingMethods` available for your `shipment`.
Here is how the response looks like:

```
{
"@context": "/api/v2/contexts/ShippingMethod",
"@id": "/api/v2/shop/shipping-methods",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "/api/v2/shop/shipping-methods/ups",
"@type": "ShippingMethod",
"id": 1,
"code": "ups",
"position": 0,
"name": "UPS",
"description": "Quasi perferendis debitis officiis ut inventore exercitationem."
}
],
"hydra:totalItems": 1,
"hydra:search": {
"@type": "hydra:IriTemplate",
"hydra:template": "/api/v2/shop/shipping-methods{?shipmentId,tokenValue}",
"hydra:variableRepresentation": "BasicRepresentation",
"hydra:mapping": [
{
"@type": "IriTemplateMapping",
"variable": "shipmentId",
"property": null,
"required": false
},
{
"@type": "IriTemplateMapping",
"variable": "tokenValue",
"property": null,
"required": false
}
]
}
}
```

0 comments on commit 584bc76

Please sign in to comment.