Skip to content

The property of the parent element is used first when making a request #75

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

Merged
merged 4 commits into from
Nov 28, 2018
Merged

The property of the parent element is used first when making a request #75

merged 4 commits into from
Nov 28, 2018

Conversation

rocketweb
Copy link

@rocketweb rocketweb commented Apr 2, 2018

Description

Whenever you want to make an API request to an URL that has a variable in it, e.g. deleting a product requires the sku of that product in the URL, you would go the a 'meta' file and add an operation that looks something like this:

<operation name="deleteProduct" dataType="product" type="delete" auth="adminOauth" url="/V1/products/{sku}" method="DELETE"> <contentType>application/json</contentType> </operation>

Adding {sku} to the url works if the entity that you want to delete is the only entity that has a property of that name, and there are no child entities associated with it that also have the property. In other words, if you want to create, for example, a bundle product, and be able to pass it the category and it's child products, like so:

        <createData entity="SimpleProductForBundle1" stepKey="createSimpleProduct1">
            <requiredEntity createDataKey="createCategory"/>
        </createData>
        <createData entity="SimpleProductForBundle2" stepKey="createSimpleProduct2">
            <requiredEntity createDataKey="createCategory"/>
        </createData>
        <createData entity="SimpleProductForBundle3" stepKey="createSimpleProduct3">
            <requiredEntity createDataKey="createCategory"/>
        </createData>

        <createData entity="BundleProduct" stepKey="createBundleProduct">
            <requiredEntity createDataKey="createCategory"/>
            <requiredEntity createDataKey="createSimpleProduct1"/>
            <requiredEntity createDataKey="createSimpleProduct2"/>
            <requiredEntity createDataKey="createSimpleProduct3"/>
        </createData>

When you want to delete the product by calling <deleteData createDataKey="createBundleProduct" stepKey="deleteBundleProduct"/>, which refferences something like <operation name="deleteProductBundle" dataType="product_bundle" type="delete" auth="adminOauth" url="/V1/products/{sku}" method="DELETE"> <contentType>application/json</contentType> </operation> , it will actually delete the last entity that was passed as a parameter which has the 'sku' property. In the example above that would be "createSimpleProduct3". This is not how it should work.

The changes that I've made allows you to pick the entity that you want to make a refference to, when you want to call its property in the url. In order to delete a bundle product, one would add something like this in the metadata file:

<operation name="deleteProductBundle" dataType="product_bundle" type="delete" auth="adminOauth" url="/V1/products/{product_bundle.sku}" method="DELETE">
        <contentType>application/json</contentType>
    </operation>

Basically, instead of adding {sku}, one would add {product_bundle.sku}, where product_bundle is the metadata entity type, to the url.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/verification tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)
  • Changes to Framework doesn't have backward incompatible changes for tests or have related Pull Request with fixes to tests

@coveralls
Copy link

coveralls commented Apr 2, 2018

Coverage Status

Coverage decreased (-0.008%) to 57.046% when pulling 314c5b1 on rocketweb:parent-property-in-metadata-url into 349c9bf on magento:develop.

@okolesnyk okolesnyk self-assigned this Apr 2, 2018
@okolesnyk
Copy link
Member

Hello, @rocketweb.
Thank you for your contribution!
We created internal ticket MQE-910 to track it. We will update you here about progress on this Pull Request.

@okolesnyk okolesnyk added this to the 2.2.1 milestone Apr 17, 2018
@okolesnyk okolesnyk added Partner: Rocket Web Pull Request is created by partner Rocket Web partners-contribution Pull Request is created by Magento Partner labels Apr 23, 2018
@okolesnyk
Copy link
Member

Hello, @rocketweb
Please sign licence/cla, because otherwise I can not process this Pull Request.

@okolesnyk okolesnyk modified the milestones: 2.2.1, 2.2.0, 2.3.0 Jun 18, 2018
@KevinBKozan
Copy link
Contributor

@rocketweb,
Following up with you about the license/CLA. If you could please sign the license/cla we can process this Pull Request.

@okolesnyk
Copy link
Member

@rocketweb Thank you very much, we will include it into 2.3.1 upcoming release.

@okolesnyk okolesnyk modified the milestones: 2.3.0, 2.3.1 Jul 18, 2018
@okolesnyk okolesnyk assigned KevinBKozan and aljcalandra and unassigned okolesnyk Oct 5, 2018
@okolesnyk okolesnyk modified the milestones: 2.3.1, 2.3.9 Oct 5, 2018
@okolesnyk okolesnyk merged commit bea09d4 into magento:develop Nov 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accept Partner: Rocket Web Pull Request is created by partner Rocket Web partners-contribution Pull Request is created by Magento Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants