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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] Product options - update vol.1 #11144

Merged
merged 5 commits into from
Feb 27, 2020

Conversation

Zales0123
Copy link
Member

@Zales0123 Zales0123 commented Feb 26, 2020

Q A
Branch? api
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets started in #11136
License MIT

TO-DO:

  • handle code immutability properly - even though serialization groups are defined properly, so code change is impossible, we should still get a validation error instead of just not having a code changed 馃拑 - see this line (EDIT: we decided that the current behavior is good, at least for now 馃悗)
  • start refactoring of ApiPlatformClient to not make it too big 馃槃 (but I suppose it would be better to do it in a separate PR)

@Zales0123 Zales0123 added the Feature New feature proposals. label Feb 26, 2020
@Zales0123 Zales0123 requested a review from a team as a code owner February 26, 2020 07:44
*/
public function thisProductOptionNameShouldBe(ProductOptionInterface $productOption, string $name): void
{
$this->client->show('product_options', $productOption->getCode());
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$this->client->show('product_options', $productOption->getCode());
$this->client->show('product_options', $productOption->getId());

?

Copy link
Member Author

Choose a reason for hiding this comment

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

We defined the code as identifier of currency (check here), so I've done the same with product options. It's another decision we need to take. We use codes in Sylius (ui routes), but, on the other hand, it's not reliable as it's always just and autogenerated integer 鈿栵笍 I'm for using codes, but cc @pamil @lchrusciel

Copy link
Contributor

Choose a reason for hiding this comment

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

okey I was confused because in apiClient we have public function buildUpdateRequest(string $resource, string $id): void so in this functions we should have $code instead $id if i understand it correctly 馃拑

Copy link
Member Author

Choose a reason for hiding this comment

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

To be honest... I'm not sure 馃槃 For us, in Sylius, it's a code indeed, but for ApiPlatform it's an identifier (even if you take a look at the URL there is {id}, not {code}). So it still makes sense to me to keep it as it is 馃殌 But I'm not forcing it if it's confusing for some more people as well 馃枛

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should use an IRI as the unique identifier in API Platform (ApiPlatform\Core\Api\IriConverterInterface)?

@@ -35,6 +35,11 @@ public function index(string $resource): void
$this->client->request('GET', '/new-api/'.$resource, [], [], ['HTTP_ACCEPT' => 'application/ld+json']);
}

public function show(string $resource, string $id): void
{
$this->client->request('GET', sprintf('/new-api/%s/%s', $resource, $id), [], [], ['HTTP_ACCEPT' => 'application/ld+json']);
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can use ApiPlatform\Core\Api\IriConverterInterface to generate an iri in this client?

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 agree 馃憤 However, do you think it can be a part of next PR, that would refactor ApiPlatformClient a little bit? It's needed, nevertheless

src/Sylius/Behat/Client/ApiPlatformClient.php Outdated Show resolved Hide resolved
*/
public function thisProductOptionNameShouldBe(ProductOptionInterface $productOption, string $name): void
{
$this->client->show('product_options', $productOption->getCode());
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should use an IRI as the unique identifier in API Platform (ApiPlatform\Core\Api\IriConverterInterface)?

@Zales0123 Zales0123 changed the title [WIP][API] Product options - update [WIP][API] Product options - update vol.1 Feb 26, 2020
@Zales0123 Zales0123 changed the title [WIP][API] Product options - update vol.1 [API] Product options - update vol.1 Feb 26, 2020
@CoderMaggie CoderMaggie added the API APIs related issues and PRs. label Feb 27, 2020
@GSadee GSadee merged commit 60f7b60 into Sylius:api Feb 27, 2020
@GSadee
Copy link
Member

GSadee commented Feb 27, 2020

Thanks, Mateusz! 馃

@Zales0123 Zales0123 deleted the product-options-api-update branch February 27, 2020 09:43
GSadee added a commit that referenced this pull request Feb 28, 2020
This PR was merged into the api branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | api
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | continuation of #11144
| License         | MIT

- production option name validation
- default sorting of product options

Commits
-------

cb2dd4e [Behat][Api] Finish tests for product option validation
d1ca81c [Behat][Api] Default sorting for product options
@lchrusciel
Copy link
Member

Part of #11250

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

7 participants