Skip to content

Resource/Object specific data key support #296

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Spotnyk
Copy link
Contributor

@Spotnyk Spotnyk commented May 29, 2023

This PR attempts to support resource/object level data keys as well as request level.

As example:
The recently added AssignedFulfillmentOrder resource. It returns results with the fulfillment_orders key, which does not match the resource key.

While a data key can be manually passed to get(), it feels messy for a resource which always requires a custom data key.

Setting the protected $dataKey property in a resource object will cause the specified key to be used with results (unless a key is provided manually).

(Therefore, this PR "fixes" the response payload from AssignedFulfillmentOrder)

@Spotnyk
Copy link
Contributor Author

Spotnyk commented May 31, 2023

As a "quick glance" example of what this fixes:

Currently (at every implementation point):

$shopify->AssignedFulfillmentOrders->get(['assignment_status' => 'in_progress'], null, 'fulfillment_orders');

WIth change:
Resource (once):

protected $dataKey = 'fulfillment_orders';

Runtime:

$shopify->AssignedFulfillmentOrders->get(['assignment_status' => 'in_progress']);

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant