php-shopify icon indicating copy to clipboard operation
php-shopify copied to clipboard

Resource/Object specific data key support

Open Spotnyk opened this issue 1 year ago • 1 comments

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 avatar May 29 '23 16:05 Spotnyk

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']);

Spotnyk avatar May 31 '23 22:05 Spotnyk