Skip to content

Commit 6a246f0

Browse files
committed
Add fulfillment event class
1 parent 60d6c23 commit 6a246f0

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

shopify/resources/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
from .country import Country
3939
from .refund import Refund
4040
from .fulfillment import Fulfillment, FulfillmentOrders
41+
from .fulfillment_event import FulfillmentEvent
4142
from .fulfillment_service import FulfillmentService
4243
from .carrier_service import CarrierService
4344
from .transaction import Transaction
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from ..base import ShopifyResource
2+
3+
class FulfillmentEvent(ShopifyResource):
4+
_prefix_source = "/orders/$order_id/fulfillments/$fulfillment_id"
5+
_singular = "event"
6+
_plural = "events"
7+
8+
@classmethod
9+
def _prefix(cls, options={}):
10+
order_id = options.get("order_id")
11+
fulfillment_id = options.get('fulfillment_id')
12+
if order_id:
13+
return "%s/orders/%s/fulfillments/%s" % (
14+
cls.site, order_id, fulfillment_id)
15+
else:
16+
return cls.site
17+
18+
def save(self):
19+
status = self.attributes['status']
20+
if status not in ['label_printed', 'label_purchased', 'attempted_delivery', 'ready_for_pickup', 'picked_up', 'confirmed', 'in_transit', 'out_for_delivery', 'delivered', 'failure']:
21+
raise AttributeError("Invalid status")
22+
return super(ShopifyResource, self).save()

0 commit comments

Comments
 (0)