This repository was archived by the owner on Oct 6, 2026. It is now read-only.
Repository navigation
Melaniewpaulinak/add fulfillment event #454
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| from ..base import ShopifyResource | ||
|
|
||
| class FulfillmentEvent(ShopifyResource): | ||
| _prefix_source = "/orders/$order_id/fulfillments/$fulfillment_id/" | ||
| _singular = 'event' | ||
| _plural = 'events' | ||
|
|
||
| @classmethod | ||
| def _prefix(cls, options={}): | ||
| order_id = options.get("order_id") | ||
| fulfillment_id = options.get('fulfillment_id') | ||
| event_id = options.get("event_id") | ||
|
|
||
| return "%s/orders/%s/fulfillments/%s" % ( | ||
| cls.site, order_id, fulfillment_id) | ||
|
|
||
| def save(self): | ||
| status = self.attributes['status'] | ||
| if status not in ['label_printed', 'label_purchased', 'attempted_delivery', 'ready_for_pickup', 'picked_up', 'confirmed', 'in_transit', 'out_for_delivery', 'delivered', 'failure']: | ||
| raise AttributeError("Invalid status") | ||
| return super(ShopifyResource, self).save() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "fulfillment_event": { | ||
| "id": 12584341209251, | ||
| "fulfillment_id": 2608403447971, | ||
| "status": "label_printed", | ||
| "message": null, | ||
| "happened_at": "2021-01-25T16:32:23-05:00", | ||
| "city": null, | ||
| "province": null, | ||
| "country": null, | ||
| "zip": null, | ||
| "address1": null, | ||
| "latitude": null, | ||
| "longitude": null, | ||
| "shop_id": 49144037539, | ||
| "created_at": "2021-01-25T16:32:23-05:00", | ||
| "updated_at": "2021-01-25T16:32:23-05:00", | ||
| "estimated_delivery_at": null, | ||
| "order_id": 2776493818019, | ||
| "admin_graphql_api_id": "gid://shopify/FulfillmentEvent/12584341209251" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import shopify | ||
| from test.test_helper import TestCase | ||
| from pyactiveresource.activeresource import ActiveResource | ||
|
|
||
| class FulFillmentEventTest(TestCase): | ||
| def test_get_fulfillment_event(self): | ||
| self.fake("orders/2776493818019/fulfillments/2608403447971/events", method='GET', body=self.load_fixture('fulfillment_event')) | ||
| fulfillment_event = shopify.FulfillmentEvent.find(order_id=2776493818019, fulfillment_id=2608403447971) | ||
| self.assertEqual(1, len(fulfillment_event)) | ||
|
|
||
| def test_create_fulfillment_event(self): | ||
| self.fake("orders/2776493818019/fulfillments/2608403447971/events", method='POST', body=self.load_fixture('fulfillment_event'), headers={'Content-type': 'application/json'}) | ||
| new_fulfillment_event = shopify.FulfillmentEvent({'order_id': '2776493818019', 'fulfillment_id': '2608403447971'}) | ||
| new_fulfillment_event.status = 'ready_for_pickup' | ||
| new_fulfillment_event.save() | ||
|
|
||
| def test_error_on_incorrect_status(self): | ||
| with self.assertRaises(AttributeError): | ||
| self.fake("orders/2776493818019/fulfillments/2608403447971/events/12584341209251", method='GET', body=self.load_fixture('fulfillment_event')) | ||
| incorrect_status = 'asdf' | ||
| fulfillment_event = shopify.FulfillmentEvent.find(12584341209251, order_id='2776493818019', fulfillment_id='2608403447971') | ||
| fulfillment_event.status = incorrect_status | ||
| fulfillment_event.save() | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure if hardcoding a list of accepted status' is the best way to go about this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for whether to hard code them: Are these likely to change in the future at all/frequently? And is there another way to reference them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No other way to reference status as far as I know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I didn't think so, but wanted to ask. I would maybe just assign a variable for the array but otherwise if that's the only option, that's the only option 🤷