From bbd78837e3819e38323339f6848962b9bb2517da Mon Sep 17 00:00:00 2001 From: long-blade Date: Wed, 11 Jan 2023 18:23:50 +0200 Subject: [PATCH 1/6] refactor: removed deprecated endpoints --- src/Service/FulfillmentService.php | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/src/Service/FulfillmentService.php b/src/Service/FulfillmentService.php index 0bcc30c..f0e0df0 100644 --- a/src/Service/FulfillmentService.php +++ b/src/Service/FulfillmentService.php @@ -27,10 +27,10 @@ public function get($orderId, $fulfillmentId, array $params = []) return $this->createObject(Fulfillment::class, $response['fulfillments']); } - public function create($orderId, Fulfillment &$fulfillment) + public function create(Fulfillment &$fulfillment) { $data = $fulfillment->exportData(); - $endpoint = 'orders/' . $orderId . '/fulfillments.json'; + $endpoint = 'fulfillments.json'; $response = $this->request( $endpoint, 'POST', @@ -41,10 +41,10 @@ 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', @@ -55,24 +55,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); - } } From cc4d59c735c07777f6427640109c091c8c813ee9 Mon Sep 17 00:00:00 2001 From: long-blade Date: Wed, 11 Jan 2023 18:24:39 +0200 Subject: [PATCH 2/6] refactor: add TrackingInfo and LineItemByFulfillmentOrder properties --- src/Enum/Fields/FulfillmentFields.php | 4 ++++ .../LineItemByFulfillmentOrderFields.php | 15 +++++++++++++++ src/Enum/Fields/TrackingInfoFields.php | 19 +++++++++++++++++++ src/Object/LineItemByFulfillmentOrder.php | 14 ++++++++++++++ src/Object/TrackingInfo.php | 14 ++++++++++++++ 5 files changed, 66 insertions(+) create mode 100644 src/Enum/Fields/LineItemByFulfillmentOrderFields.php create mode 100644 src/Enum/Fields/TrackingInfoFields.php create mode 100644 src/Object/LineItemByFulfillmentOrder.php create mode 100644 src/Object/TrackingInfo.php diff --git a/src/Enum/Fields/FulfillmentFields.php b/src/Enum/Fields/FulfillmentFields.php index 96bf79f..f29fce6 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_FULFILMENT_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 @@ + Date: Wed, 11 Jan 2023 18:44:35 +0200 Subject: [PATCH 3/6] fix: add the correct method for updateTracking endpoint --- src/Service/FulfillmentService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Service/FulfillmentService.php b/src/Service/FulfillmentService.php index f0e0df0..f949e5d 100644 --- a/src/Service/FulfillmentService.php +++ b/src/Service/FulfillmentService.php @@ -47,7 +47,7 @@ public function updateTracking(Fulfillment &$fulfillment) $endpoint = 'fulfillments/' . $fulfillment->id . '/update_tracking.json'; $response = $this->request( $endpoint, - 'PUT', + 'POST', [ 'fulfillment' => $data ] From 3d9bdf2c990a90219b77019445e6f043f78fa210 Mon Sep 17 00:00:00 2001 From: long-blade Date: Wed, 11 Jan 2023 18:48:26 +0200 Subject: [PATCH 4/6] fix: minor lexical fix --- src/Enum/Fields/FulfillmentFields.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Enum/Fields/FulfillmentFields.php b/src/Enum/Fields/FulfillmentFields.php index f29fce6..60ced19 100644 --- a/src/Enum/Fields/FulfillmentFields.php +++ b/src/Enum/Fields/FulfillmentFields.php @@ -9,7 +9,7 @@ class FulfillmentFields extends AbstractObjectEnum const LINE_ITEMS = 'line_items'; const NOTIFY_CUSTOMER = 'notify_customer'; const TRACKING_INFO = 'tracking_info'; - const LINE_ITEMS_BY_FULFILMENT_ORDER = 'line_items_by_fulfillment_order'; + const LINE_ITEMS_BY_FULFILLMENT_ORDER = 'line_items_by_fulfillment_order'; const ORDER_ID = 'order_id'; const RECEIPT = 'receipt'; const STATUS = 'status'; From 42253c218e0f3208b18139f9bcda41699810a93c Mon Sep 17 00:00:00 2001 From: long-blade Date: Thu, 12 Jan 2023 11:15:00 +0200 Subject: [PATCH 5/6] feat: add fulfillments associated with a fulfillment order endpoint --- src/Service/FulfillmentService.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Service/FulfillmentService.php b/src/Service/FulfillmentService.php index f949e5d..4db010d 100644 --- a/src/Service/FulfillmentService.php +++ b/src/Service/FulfillmentService.php @@ -27,6 +27,14 @@ public function get($orderId, $fulfillmentId, array $params = []) return $this->createObject(Fulfillment::class, $response['fulfillments']); } + 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(); From 8b663175485272756a7871b0ef1c65bf58110e0f Mon Sep 17 00:00:00 2001 From: long-blade Date: Wed, 29 Mar 2023 19:27:53 +0300 Subject: [PATCH 6/6] refactor: tracking_info => 'TrackingInfo', --- src/Enum/Fields/FulfillmentFields.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Enum/Fields/FulfillmentFields.php b/src/Enum/Fields/FulfillmentFields.php index 60ced19..682018b 100644 --- a/src/Enum/Fields/FulfillmentFields.php +++ b/src/Enum/Fields/FulfillmentFields.php @@ -27,7 +27,7 @@ public function getFieldTypes() 'id' => 'integer', 'line_items' => 'LineItem[]', 'notify_customer' => 'boolean', - 'tracking_info' => 'TrackingInfo[]', + 'tracking_info' => 'TrackingInfo', 'line_items_by_fulfillment_order' => 'LineItemByFulfillmentOrder[]', 'order_id' => 'integer', 'receipt' => "object",