diff --git a/src/Enum/Fields/FulfillmentFields.php b/src/Enum/Fields/FulfillmentFields.php index 96bf79f..682018b 100644 --- a/src/Enum/Fields/FulfillmentFields.php +++ b/src/Enum/Fields/FulfillmentFields.php @@ -8,6 +8,8 @@ class FulfillmentFields extends AbstractObjectEnum const ID = 'id'; const LINE_ITEMS = 'line_items'; const NOTIFY_CUSTOMER = 'notify_customer'; + const TRACKING_INFO = 'tracking_info'; + const LINE_ITEMS_BY_FULFILLMENT_ORDER = 'line_items_by_fulfillment_order'; const ORDER_ID = 'order_id'; const RECEIPT = 'receipt'; const STATUS = 'status'; @@ -25,6 +27,8 @@ public function getFieldTypes() 'id' => 'integer', 'line_items' => 'LineItem[]', 'notify_customer' => 'boolean', + 'tracking_info' => 'TrackingInfo', + 'line_items_by_fulfillment_order' => 'LineItemByFulfillmentOrder[]', 'order_id' => 'integer', 'receipt' => "object", 'status' => 'string', diff --git a/src/Enum/Fields/LineItemByFulfillmentOrderFields.php b/src/Enum/Fields/LineItemByFulfillmentOrderFields.php new file mode 100644 index 0000000..c7d64e6 --- /dev/null +++ b/src/Enum/Fields/LineItemByFulfillmentOrderFields.php @@ -0,0 +1,15 @@ + 'integer', + ); + } +} diff --git a/src/Enum/Fields/TrackingInfoFields.php b/src/Enum/Fields/TrackingInfoFields.php new file mode 100644 index 0000000..4aacd3b --- /dev/null +++ b/src/Enum/Fields/TrackingInfoFields.php @@ -0,0 +1,19 @@ + 'string', + 'number' => 'string', + 'url' => 'string', + ]; + } +} diff --git a/src/Object/LineItemByFulfillmentOrder.php b/src/Object/LineItemByFulfillmentOrder.php new file mode 100644 index 0000000..5ee9552 --- /dev/null +++ b/src/Object/LineItemByFulfillmentOrder.php @@ -0,0 +1,14 @@ +createObject(Fulfillment::class, $response['fulfillments']); } - public function create($orderId, Fulfillment &$fulfillment) + public function getFulfilledOrder(Fulfillment &$fulfillment) + { + $endpoint = 'fulfillment_orders/' . $fulfillment->id . '/fulfillments.json'; + $response = $this->request($endpoint, 'GET'); + + return $this->createObject(Fulfillment::class, $response['fulfillments']); + } + + public function create(Fulfillment &$fulfillment) { $data = $fulfillment->exportData(); - $endpoint = 'orders/' . $orderId . '/fulfillments.json'; + $endpoint = 'fulfillments.json'; $response = $this->request( $endpoint, 'POST', @@ -41,13 +49,13 @@ public function create($orderId, Fulfillment &$fulfillment) $fulfillment->setData($response['fulfillment']); } - public function update($orderId, Fulfillment &$fulfillment) + public function updateTracking(Fulfillment &$fulfillment) { $data = $fulfillment->exportData(); - $endpoint = 'orders/' . $orderId . '/fulfillments/' . $fulfillment->id . '.json'; + $endpoint = 'fulfillments/' . $fulfillment->id . '/update_tracking.json'; $response = $this->request( $endpoint, - 'PUT', + 'POST', [ 'fulfillment' => $data ] @@ -55,24 +63,10 @@ public function update($orderId, Fulfillment &$fulfillment) $fulfillment->setData($response['fulfillment']); } - public function complete($orderId, Fulfillment &$fulfillment) - { - $endpoint = 'orders/' . $orderId . '/fulfillments/' . $fulfillment->id . '/complete.json'; - $response = $this->request($endpoint, 'POST'); - $fulfillment->setData($response['fulfillment']); - } - - public function cancel($orderId, Fulfillment &$fulfillment) + public function cancel(Fulfillment &$fulfillment) { - $endpoint = 'orders/' . $orderId . '/fulfillments/' . $fulfillment->id . '/cancel.json'; + $endpoint = 'fulfillments/' . $fulfillment->id . '/cancel.json'; $response = $this->request($endpoint, 'POST'); $fulfillment->setData($response['fulfillment']); } - - public function open($orderId, Fulfillment &$fulfillment) - { - $endpoint = 'orders/' . $orderId . '/fulfillments/' . $fulfillment->id . '/open.json'; - $response = $this->request($endpoint, 'POST'); - $fulfillment->setData($response->fulfillment); - } }