Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Enum/Fields/FulfillmentFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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',
Expand Down
15 changes: 15 additions & 0 deletions src/Enum/Fields/LineItemByFulfillmentOrderFields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Shopify\Enum\Fields;

class LineItemByFulfillmentOrderFields extends AbstractObjectEnum
{
const FULFILLMENT_ORDER_ID = 'fulfillment_order_id';

public function getFieldTypes()
{
return array(
'fulfillment_order_id' => 'integer',
);
}
}
19 changes: 19 additions & 0 deletions src/Enum/Fields/TrackingInfoFields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Shopify\Enum\Fields;

class TrackingInfoFields extends AbstractObjectEnum
{
const COMPANY = 'company';
const NUMBER = 'number';
const URL = 'url';

public function getFieldTypes()
{
return [
'company' => 'string',
'number' => 'string',
'url' => 'string',
];
}
}
14 changes: 14 additions & 0 deletions src/Object/LineItemByFulfillmentOrder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Shopify\Object;


use Shopify\Enum\Fields\LineItemByFulfillmentOrderFields;

class LineItemByFulfillmentOrder extends AbstractObject
{
public static function getFieldsEnum()
{
return LineItemByFulfillmentOrderFields::getInstance();
}
}
14 changes: 14 additions & 0 deletions src/Object/TrackingInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace Shopify\Object;


use Shopify\Enum\Fields\TrackingInfoFields;

class TrackingInfo extends AbstractObject
{
public static function getFieldsEnum()
{
return TrackingInfoFields::getInstance();
}
}
36 changes: 15 additions & 21 deletions src/Service/FulfillmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,18 @@ public function get($orderId, $fulfillmentId, array $params = [])
return $this->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',
Expand All @@ -41,38 +49,24 @@ 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
]
);
$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);
}
}