Comments (4)
Just as if shopify was trying to make a point here, I was just working on Fulfillment Events, which are double nested... And of course there are also Order Events.
Right now the order events are organized in nested modules
Shopify.Order.Event.all(1)
# for the sake of consistency we should decide if this makes sense
Shopify.Order.Fulfillment.Event.find(78123, 123, 1)
Shopify's API reference is very inconsistent in how they list the events, for example there is an entry for FulfillmentEvent but none for OrderEvent (in fact I didn't find an entry for that at all, but there is an endpoint for it and it works...) and you can also get an event without nesting...
The shopify API doc is pretty messy in parts, so that's how we ended up in this place in the first place, but would be nice to settle on a way to deal with it
from shopify.
At the moment - the the nested module for sure seems like the cleaner approach.
Personally, I haven't yet had a need to fetch those nested resources yet. I would be curious as to how useful being able to pass the owner struct OR the owner id as an argument would be. It would provide a much more "elixir'ish" feel to things - permitting the use of pattern matching on the owner to determine what to do.
It would be cool to be able to pipeline calls and build up the nested relations within the owner as well. For example...
session
|> Shopify.Order.find(1)
|> Shopify.Transactions.all()
Which would provide a %Shopify.Order{transactions: [....]}
struct. With the above, there are obvious complications with the session being the first arg (which could perhaps be passed back with the result).
Anyways - these are all larger and more ambitious tasks. Perhaps a discussion for a new version. I will look at perhaps creating a new issue where we can start compiling such features and discussions.
from shopify.
To add on to the this further.
I'm basically trying to envision a few different ways we could handle fetching nested relations through pipelines. Although it creates "extra" structs in the process, something akin to a new
function may be useful and much more explicit than a bunch of integer ids. We could have this accept a few different argument forms: new(attributes)
, new({session, owner}, attributes)
, as well as new(session, attributes)
With the above, something like the triple nested order fulfillment event could be handled like:
session
|> Shopify.Order.new(id: 1) # if passed a session as the first arg, returns {session, order}
|> Shopify.Fullfillment.new(id: 1)
|> Shopify.Event.find(1) # not sure about this... would basically require accepting {session, owner} as its arg as well...
Food for thought...
from shopify.
Shopify restructured their API reference, I think precisely because especially the nested resources were all over the place. Might help with how we think about the structure as well.
from shopify.
Related Issues (20)
- Is this project dead? HOT 1
- Set timeout for HTTPoison requests HOT 2
- More detailed documentation HOT 4
- Order fulfillment event is using the wrong resource parser HOT 1
- Add tests to validate structs
- Shop info should be dynamically configurable HOT 1
- ScripTags Not Working HOT 1
- cost missing from InventoryItem resource
- Getting resources that don't necessarily match Resources / NestedResource HOT 4
- OAuth flow in test mock adapter seems incomplete HOT 1
- Feature: Multipass support HOT 1
- [PriceRule] Missing field HOT 1
- [Multipass] Clear up API HOT 1
- Add Versioning Support HOT 4
- Order resource is missing endpoints
- Support Shopify's new cursor-based pagination HOT 2
- Failing travis-ci checks
- How ready is it? All API calls? HOT 1
- Unhandled CaseClauseError from bug in Posion
- Problems With OAuth Flow using Explicit API Version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shopify.