Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Added post endpoint for updating an order. #73

Merged
merged 9 commits into from
Sep 24, 2021

Conversation

zkimffm
Copy link
Contributor

@zkimffm zkimffm commented Sep 7, 2021

Added a post endpoint to update an order.

Example usage:

$body = [
    'entity' => [
        'entity_id' => '12345',
        'extension_attributes' => [
            'amasty_order_attributes' => [
                'delivery_date' => '2021-09-07'
            ]
        ]
    ]
];

...api('orders')->edit($body);

@ahinkle
Copy link
Member

ahinkle commented Sep 7, 2021

Thanks, @zkimffm!

What are your thoughts on removing the parent-level entity array and have it explicitly applied? Will there ever be anything else passed besides entity?

e.g.

Magento::api('orders')->edit([
    'entity_id' => '12345',
    'extension_attributes' => [
        'amasty_order_attributes' => [
            'delivery_date' => '2021-09-07'
        ]
    ]
    // so on so forth..
]);

@zkimffm
Copy link
Contributor Author

zkimffm commented Sep 7, 2021

Thanks, @zkimffm!

What are your thoughts on removing the parent-level entity array and have it explicitly applied? Will there ever be anything else passed besides entity?

e.g.

Magento::api('orders')->edit([
    'entity_id' => '12345',
    'extension_attributes' => [
        'amasty_order_attributes' => [
            'delivery_date' => '2021-09-07'
        ]
    ]
    // so on so forth..
]);

Hi! @ahinkle So according to the magento documentation, it looks like the entity object is required with the Orders POST request. Please see attached screenshot.
Screen Shot 2021-09-07 at 11 02 09 PM

@ahinkle
Copy link
Member

ahinkle commented Sep 7, 2021

Hey @zkimffm ,

Right :) I'm saying what if we automatically provide entity in the array so the developer doesn't have to write it every time.

it would change the method to something like this:

public function edit($entity = [])
{
    return $this->post('/orders', [
        'entity => $entity',
    ]);
}

then, you don't have to provide entity directly as its already applied:

Magento::api('orders')->edit([
    'entity_id' => '12345',
    'extension_attributes' => [
        'amasty_order_attributes' => [
            'delivery_date' => '2021-09-07'
        ]
    ]
    // so on so forth..
]);

Thoughts there, or would expect to write that out each time?

@zkimffm
Copy link
Contributor Author

zkimffm commented Sep 7, 2021

Hey @zkimffm ,

Right :) I'm saying what if we automatically provide entity in the array so the developer doesn't have to write it every time.

it would change the method to something like this:

public function edit($entity = [])
{
    return $this->post('/orders', [
        'entity => $entity',
    ]);
}

then, you don't have to provide entity:

Magento::api('orders')->edit([
    'entity_id' => '12345',
    'extension_attributes' => [
        'amasty_order_attributes' => [
            'delivery_date' => '2021-09-07'
        ]
    ]
    // so on so forth..
]);

Thoughts there, or would expect to write that out each time?

Ah! @ahinkle I understand what you mean now. Okay, that sounds good. I will make the change! Thanks.

@ahinkle ahinkle merged commit 73b5739 into grayloon:master Sep 24, 2021
@ahinkle
Copy link
Member

ahinkle commented Sep 24, 2021

Thanks, @zkimffm!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants