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] Pick up cart implementation #11524

Merged
merged 1 commit into from May 28, 2020
Merged

Conversation

lchrusciel
Copy link
Member

@lchrusciel lchrusciel commented May 28, 2020

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

@lchrusciel lchrusciel added Feature New feature proposals. API APIs related issues and PRs. labels May 28, 2020
@lchrusciel lchrusciel requested a review from a team as a code owner May 28, 2020 09:54
{
$response = $this->cartsClient->getLastResponse();
Assert::true(
$this->responseChecker->isCreationSuccessful($response),
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering, cannot we really check is there nothing in the created cart? Of course, it needs to be created first, but the content is crucial for this step imo 🐴

Copy link
Member Author

Choose a reason for hiding this comment

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

For now, I would like to leave it as it is due to time constraints

Copy link
Member

@Zales0123 Zales0123 May 28, 2020

Choose a reason for hiding this comment

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

👍 but still should be improved 🚀


$this->orderManager->persist($cart);

return $cart;
Copy link
Member

Choose a reason for hiding this comment

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

How orthodox we want to be regarding command and handlers in API? 😄 I theory, the command handler should not return any value

Copy link
Member Author

Choose a reason for hiding this comment

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

There is no other way ATM. At least without a custom data transformer at the end.

Copy link
Member

Choose a reason for hiding this comment

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

So probably we should implement a custom data transformer as fast as possible. The limits our used tool should no be an excuse for the wrong CQS pattern usage 🖖

@@ -56,4 +56,6 @@ public function updateFiles(array $newFiles): void;
public function addSubResource(string $key, array $subResource): void;

public function removeSubResource(string $subResource, string $id): void;

public function authorize(string $token): void;
Copy link
Member

Choose a reason for hiding this comment

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

What is the reason for extracting this method?

Copy link
Member Author

Choose a reason for hiding this comment

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

I need to make a request without authorization, therefore the previous create method was no-go for me. However, the rest of the methods still needs to authorize so IMHO it is better to provide it as a part of Public API. BTW, I would like completely decouple Request creation from APIClient and I see these changes as a first steps in this direction.

@GSadee GSadee merged commit 3ae2547 into Sylius:master May 28, 2020
@GSadee
Copy link
Member

GSadee commented May 28, 2020

Thanks, Łukasz! 🥇

@lchrusciel lchrusciel deleted the cart-view branch May 28, 2020 12:37
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. Feature New feature proposals.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants