-
-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Product by explicit fields #477
Conversation
…level fields get mapped.
…ected first-level properties. Added a test to verify functionality.
…t to validate for it working.
This is cool! I especially like your use of I am indeed doing some work in the same area with F#, but I've recently started a new branch for bringing a fluent-style builder to C# and will instead base the F# stuff off of that. My intent is for it to look something like this: var product = new ProductBuilder()
.SetTitle("Some title")
.SetPublishedAt(DateTimeOffset.Now); It would do essentially what your pull request is doing too, it just modifies a hidden dictionary and decides which properties get serialized. That said, I definitely like your approach too, and I think having the two different approaches is beneficial, so I'd like to go ahead with your proposal. Two thoughts after looking at the code:
|
Personally I prefer this approach to have a
All service update methods can then simply call this method.
This way we can ask to update all fields except a few.
|
This brings up an interesting question - why is the
@nozzlegear - is there some historical reason for this, or is this just a case of technical debt not yet paid down? |
I recently introduced base methods in the ShopifyService.cs, such as We were quite pressed to release v5 and I didn't have time to go through all services but ideally they should all use the base class methods. |
…hen updating objects.
…actored to using the new UpdateBuilder.
I've put together this idea of a generic I then added an overload for the I'm not particularly happy with the duplication of the code that gets the I haven't tested this yet for nested properties (i.e. Update Product.Variants[].Ids), that'll be an iteration if there's positive feedback on this |
I saw that Stripe.net has come up with an interesting approach using a discriminated union |
It's interesting, but would require a fundamental rewrite of all of the ShopifySharp POCO classes, wouldn't it? Is there interest in me further expanding on this |
I know there's work being done in F# (#388) for specifying which fields get sent back to in an Update call. In the meantime, I've quickly put together a way to pick which fields to use by listing them in a string array. The idea being that one doesn't need to do a GET to pull down the whole Product before doing an Update with just one or two fields.
For immediate application, I am using the Product Service. I have added a couple of test methods to validate that it is working. In an ideal setup, I might allow for an expression tree, but implementing that is outside of my current knowledge set.
Any feedback you have would be appreciated. I wouldn't mind expanding this to more services as needed.
This would solve #379 and possibly #475.