Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] handle shipping without addressing #12746

Merged
merged 3 commits into from Jun 23, 2021

Conversation

SirDomin
Copy link
Contributor

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Related tickets
License MIT

@SirDomin SirDomin requested a review from a team as a code owner June 23, 2021 10:47
@probot-autolabeler probot-autolabeler bot added the API APIs related issues and PRs. label Jun 23, 2021
@SirDomin SirDomin force-pushed the handle-shipping-without-addressing branch from 6179567 to 3cb78c1 Compare June 23, 2021 11:43
src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php Outdated Show resolved Hide resolved
src/Sylius/Behat/Context/Api/Shop/CheckoutContext.php Outdated Show resolved Hide resolved
@@ -66,6 +67,10 @@ public function __invoke(ChooseShippingMethod $chooseShippingMethod): OrderInter

$stateMachine = $this->stateMachineFactory->get($cart, OrderCheckoutTransitions::GRAPH);

if ($cart->getShippingAddress() === null) {
throw new OrderCannotBeShippedWithoutAddressing();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder, is it something we would like to do with a custom exception? Or maybe it should be a guard on state machine? 🤔 We're checking the possibility of transitioning order below nonetheless. cc @GSadee @lchrusciel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state machine is check in the next lines, it throws 500 error if state cant be applied, this way we capture error we expect before and throw custom error to tell what caused this error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally understand that 😄 I just wonder shouldn't we keep the order validation in one place rather than have it done with two fashions (custom exception + state machine checking). Still, it's just an improvement 🖖

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation should be handled mostly with the validation component. That should be possible with the command, that we are having here. I'm wondering if we should start moving some protecting rules into the state machine, as we don't have any yet. Exception itself is not a big deal in the current implementation tho

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#12746 okay, added another approach (this time with validations)

@SirDomin SirDomin force-pushed the handle-shipping-without-addressing branch from 762cf3b to df21ee5 Compare June 23, 2021 11:56
@Zales0123 Zales0123 merged commit ffcfd56 into Sylius:master Jun 23, 2021
@Zales0123
Copy link
Member

Thank you, @SirDomin! 🥇

Zales0123 added a commit that referenced this pull request Jun 24, 2021
This PR was merged into the 1.11-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.10
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | #12746
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.9 or 1.10 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
-------

85eafce [API] change error to violation
7be565f [API] add specs
GSadee pushed a commit to Sylius/SyliusApiBundle that referenced this pull request Jun 24, 2021
This PR was merged into the 1.11-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.10
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | Sylius/Sylius#12746
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.9 or 1.10 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
-------

85eafce99fd5e2a71b92d8bb854bba966615f2ba [API] change error to violation
7be565f357d1b49f11279901b7970e134bb3127f [API] add specs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API APIs related issues and PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants