php-shopify
php-shopify copied to clipboard
Resource/Object specific data key support
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
)
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']);