Skip to content
Merged
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
67 changes: 67 additions & 0 deletions data/mocks/lists/FulfillmentOrderList.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"fulfillments": [
{
"id": 255858046,
"order_id": 450789469,
"status": "failure",
"created_at": "2017-10-16T16:02:08-04:00",
"service": "manual",
"updated_at": "2017-10-16T16:02:08-04:00",
"tracking_company": null,
"shipment_status": null,
"tracking_number": "1Z2345",
"tracking_numbers": [
"1Z2345"
],
"tracking_url": "http:\/\/wwwapps.ups.com\/etracking\/tracking.cgi?InquiryNumber1=1Z2345&TypeOfInquiryNumber=T&AcceptUPSLicenseAgreement=yes&submit=Track",
"tracking_urls": [
"http:\/\/wwwapps.ups.com\/etracking\/tracking.cgi?InquiryNumber1=1Z2345&TypeOfInquiryNumber=T&AcceptUPSLicenseAgreement=yes&submit=Track"
],
"receipt": {
"testcase": true,
"authorization": "123456"
},
"line_items": [
{
"id": 466157049,
"variant_id": 39072856,
"title": "IPod Nano - 8gb",
"quantity": 1,
"price": "199.00",
"grams": 200,
"sku": "IPOD2008GREEN",
"variant_title": "green",
"vendor": null,
"fulfillment_service": "manual",
"product_id": 632910392,
"requires_shipping": true,
"taxable": true,
"gift_card": false,
"name": "IPod Nano - 8gb - green",
"variant_inventory_management": "shopify",
"properties": [
{
"name": "Custom Engraving Front",
"value": "Happy Birthday"
},
{
"name": "Custom Engraving Back",
"value": "Merry Christmas"
}
],
"product_exists": true,
"fulfillable_quantity": 1,
"total_discount": "0.00",
"fulfillment_status": null,
"tax_lines": [
{
"title": "State Tax",
"price": "3.98",
"rate": 0.06
}
]
}
]
}
]
}
52 changes: 52 additions & 0 deletions data/mocks/objects/FulfillmentOrder.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"fulfillment_order": {
"id": 1046000778,
"shop_id": 548380009,
"order_id": 450789469,
"assigned_location_id": 24826418,
"request_status": "submitted",
"status": "open",
"supported_actions": [
"cancel_fulfillment_order"
],
"destination": {
"id": 1046000778,
"address1": "Chestnut Street 92",
"address2": "",
"city": "Louisville",
"company": null,
"country": "United States",
"email": "bob.norman@mail.example.com",
"first_name": "Bob",
"last_name": "Norman",
"phone": "+1(502)-459-2181",
"province": "Kentucky",
"zip": "40202"
},
"line_items": [
{
"id": 1058737482,
"shop_id": 548380009,
"fulfillment_order_id": 1046000778,
"quantity": 1,
"line_item_id": 518995019,
"inventory_item_id": 49148385,
"fulfillable_quantity": 1,
"variant_id": 49148385
}
],
"fulfillment_service_handle": "mars-fulfillment",
"assigned_location": {
"address1": null,
"address2": null,
"city": null,
"country_code": "DE",
"location_id": 24826418,
"name": "Apple Api Shipwire",
"phone": null,
"province": null,
"zip": null
},
"merchant_requests": []
}
}
31 changes: 31 additions & 0 deletions src/Enum/Fields/AssignedLocationFields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Shopify\Enum\Fields;

class AssignedLocationFields extends AbstractObjectEnum
{
public const LOCATION_ID = 'location_id'; // ✅
public const NAME = 'name'; // ✅
public const ADDRESS1 = 'address1'; // ✅
public const ADDRESS2 = 'address2'; // ✅
public const CITY = 'city'; // ✅
public const ZIP = 'zip'; // ✅
public const PROVINCE = 'province'; // ✅
public const COUNTRY_CODE = 'country_code'; // ✅
public const PHONE = 'phone'; // ✅

public function getFieldTypes()
{
return [
'location_id' => 'integer',
'name' => 'string',
'address1' => 'string',
'address2' => 'string',
'city' => 'string',
'zip' => 'string',
'province' => 'string',
'country_code' => 'string',
'phone' => 'string'
];
}
}
37 changes: 37 additions & 0 deletions src/Enum/Fields/DestinationLocationFields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Shopify\Enum\Fields;

class DestinationLocationFields extends AbstractObjectEnum
{
public const ID = 'id'; // ✅
public const ADDRESS1 = 'address1'; // ✅
public const ADDRESS2 = 'address2'; // ✅
public const CITY = 'city'; // ✅
public const COMPANY = 'company'; // ✅
public const COUNTRY = 'country'; // ✅
public const EMAIL = 'email'; // ✅
public const FIRST_NAME = 'first_name'; // ✅
public const LAST_NAME = 'last_name'; // ✅
public const PHONE = 'phone'; // ✅
public const PROVINCE = 'province'; // ✅
public const ZIP = 'zip'; // ✅

public function getFieldTypes()
{
return [
'id' => 'integer',
'address1' => 'string',
'address2' => 'string',
'city' => 'string',
'company' => 'string',
'country' => 'string',
'email' => 'string',
'first_name' => 'string',
'last_name' => 'string',
'phone' => 'string',
'province' => 'string',
'zip' => 'string',
];
}
}
35 changes: 35 additions & 0 deletions src/Enum/Fields/FulfillmentOrderFields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace Shopify\Enum\Fields;

class FulfillmentOrderFields extends AbstractObjectEnum
{
public const ID = 'id';
public const ORDER_ID = 'order_id';
public const SHOP_ID = 'shop_id';
public const ASSIGNED_LOCATION_ID = 'assigned_location_id';
public const STATUS = 'status';
public const SUPPORTED_ACTIONS = 'supported_actions';
public const DESTINATION = 'destination';
public const LINE_ITEMS = 'line_items';
public const FULFILLMENT_SERVICE_BUNDLE = 'fulfillment_service_handle';
public const ASSIGNED_LOCATION = 'assigned_location';
public const MERCHANT_REQUESTS = 'merchant_requests';

public function getFieldTypes()
{
return array(
'id' => 'integer',
'order_id' => 'integer',
'shop_id' => 'integer',
'assigned_location_id' => 'integer',
'status' => 'string',
"supported_actions" => 'array',
"destination" => 'DestinationLocation', // Probably need new fields
'line_items' => 'LineItem[]',
'fulfillment_service_handle' => 'string',
"assigned_location" => 'AssignedLocation', // Probably need new fields
"merchant_requests" => 'array', // Probably need new fields
);
}
}
12 changes: 12 additions & 0 deletions src/Enum/FulfillmentHoldReason.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Shopify\Enum;

class FulfillmentHoldReason
{
public const AWAITING_PAYMENT = 'awaiting_payment';
public const HIGH_RISK_OF_FRAUD = 'high_risk_of_fraud';
public const INCORRECT_ADDRESS = 'incorrect_address';
public const INVENTORY_OUT_OF_STOCK = 'inventory_out_of_stock';
public const OTHER = 'other';
}
16 changes: 16 additions & 0 deletions src/Object/AssignedLocation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Shopify\Object\AssignedLocation
*/

namespace Shopify\Object;

use Shopify\Enum\Fields\AssignedLocationFields;

class AssignedLocation extends AbstractObject
{
public static function getFieldsEnum()
{
return AssignedLocationFields::getInstance();
}
}
16 changes: 16 additions & 0 deletions src/Object/DestinationLocation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Shopify\Object\DestinationLocation
*/

namespace Shopify\Object;

use Shopify\Enum\Fields\DestinationLocationFields;

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

namespace Shopify\Object;

use InvalidArgumentException;
use Shopify\Enum\Fields\FulfillmentOrderFields;
use Shopify\Enum\FulfillmentHoldReason;

class FulfillmentOrder extends AbstractObject
{
public static function getFieldsEnum()
{
return FulfillmentOrderFields::getInstance();
}

public static function isValidHoldReason($reason)
{
if (!in_array($reason, [
FulfillmentHoldReason::AWAITING_PAYMENT,
FulfillmentHoldReason::HIGH_RISK_OF_FRAUD,
FulfillmentHoldReason::INCORRECT_ADDRESS,
FulfillmentHoldReason::INVENTORY_OUT_OF_STOCK,
FulfillmentHoldReason::OTHER,
])) {
throw new InvalidArgumentException('Invalid fulfillment hold reason provided.');
}

return $reason;
}
}
Loading