Skip to content
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

Provide a robust fix for unknown enums #10

Closed
nozzlegear opened this issue Oct 9, 2015 · 17 comments
Closed

Provide a robust fix for unknown enums #10

nozzlegear opened this issue Oct 9, 2015 · 17 comments

Comments

@nozzlegear
Copy link
Owner

Shopify's documentation comes nowhere close to documenting all available enum values, and this has really thrown a wrench in things. ShopifySharp tries to provide enums where applicable, but I've personally run into exceptions where Shopify returns an enum that isn't documented (therefore isn't in ShopifySharp) and fails to deserialize.

I feel that enums are still preferable to using plain strings, so we need a more robust solution that won't throw exceptions when trying to deserialize unknown enums.

Instead, the current plan is to make all of ShopifySharp's enums implement an "Unknown" value, and make them all use a custom converter that will deserialize unknown enum strings into the "Unknown" value. The ShopifySharp.Enums.ShopifyProcessingMethod is the first to do this.

@nozzlegear nozzlegear added the bug label Oct 9, 2015
@nozzlegear
Copy link
Owner Author

Rather than making each enum implement an "Unknown" value, it's probably better to just make them all nullable. Checking if an enum is null takes the same effort as checking if it's "unknown". To avoid breaking changes, we'll have to save fixing this for existing enums until a v 2.0 release.

Enums created from now on, though, will be nullable and make use of a dedicated NullableEnumConverter<T>.

@nozzlegear
Copy link
Owner Author

TODO

  • Convert the ShopifyFulfillment.Status property type to a nullable enum.

@mdossantos
Copy link

Hi team, just curious if this fix will be available soon? We are currently having issues with it and hoping that it will be resolved soon before we jump to another package or workaround. thanks

@nozzlegear
Copy link
Owner Author

Hey @mdossantos, I'm looking at starting this soon but can't make any promises on exactly when it would be ready. Could you list which enums are specifically giving you trouble? I'd be happy to push a small update to fix it.

@mdossantos
Copy link

Hi Joshua,

Thanks for the quick reply. The enum we are having trouble with is
ShopifySharp.Enums.ShopifyProductFulfillmentService.
We get error converting the type "xxxxFulfillmentServiceNamexxxx" to
ShopifySharp.Enums.ShopifyProductFulfillmentService.
We get the error anytime our products are from a different fulfillment
service from shopify that isn't 'Manual'. This is when grabbing the list of
products from shopify.
Thanks
On Mar 23, 2016 5:54 PM, "Joshua Harms" notifications@github.com wrote:

Hey @mdossantos https://github.com/mdossantos, I'm looking at starting
this soon but can't make any promises on exactly when it would be ready.
Could you list which enums are specifically giving you trouble? I'd be
happy to push a small update to fix it.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#10 (comment)

@nozzlegear
Copy link
Owner Author

Thanks! I've just opened up an issue (#41) to track this. The fix will be switching ShopifyProductFulfillmentService to a string because there's no way to track all of the custom fulfillment services that apps and developers can create. I'll try to get it in this weekend if my schedule cooperates.

@mdossantos
Copy link

Thank you
On Mar 23, 2016 6:46 PM, "Joshua Harms" notifications@github.com wrote:

Thanks! I've just opened up an issue (#41
#41) to track this.
The fix will be switching ShopifyProductFulfillmentService to a string
because there's no way to track all of the custom fulfillment services that
apps and developers can create. I'll try to get it in this weekend if my
schedule cooperates.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#10 (comment)

@nozzlegear nozzlegear mentioned this issue Apr 4, 2016
9 tasks
@nozzlegear
Copy link
Owner Author

Hey @mdossantos, just a quick update on this. I've just created a PR for v2.0.0 of ShopifySharp which contains the fix for the error you've found. I'll be working on v2 over the next few days and hope to get it merged by this time next week.

@shahrukh192
Copy link

I am not able to use enum ShopifyChargeStatus

@nozzlegear
Copy link
Owner Author

Hey @shahrukh192, most enums were removed in 3.0. You can read the reasoning for that right here, but to summarize: Shopify devs sometimes change enums and they become invalid, or they add enums and don't document the changes. Instead of hardcoding the values, all enums were converted to plain old strings so that the developer can quickly update their own app to whatever value they need instead of waiting for ShopifySharp to put out a new update with the new enum values.

For ShopifyChargeStatus, you'll want to use one of these strings: pending, accepted, active, cancelled, declined or expired. I've got an update for the book coming within the next few days that will also fix any references to the enums that were removed.

@L0G1C
Copy link

L0G1C commented Jun 23, 2017

@nozzlegear Just reading this here after getting stuck on this exact thing for a moment when going through your book! Thanks for the update. BTW love the book and the ShopifySharp solution in general. really clean and easy to work with, our team is loving it.

@nozzlegear
Copy link
Owner Author

Thanks @L0G1C, glad to hear you like it! The next update to the book will use v4 of ShopifySharp, so there won't be any more outdated enum usage.

@L0G1C
Copy link

L0G1C commented Jun 23, 2017

@nozzlegear Great to hear. Doing this app for work actually has me thinking about a great App idea I want to make on my own, so I may pick up my own copy once the next update when its available. Curious, if I purchase the handbook now,, is the update free, or should I wait until the update?

@nozzlegear
Copy link
Owner Author

@L0G1C The update will be free for anybody that's already purchased the book. You'll get an email with links to the updated version as soon as it's released.

@ishahrier
Copy link
Contributor

ishahrier commented Jun 23, 2017 via email

@nozzlegear
Copy link
Owner Author

@ishahrier Hey, the update hasn't been released yet, I'm still working on it. You'll get it for free at the email address you used to purchase the current version.

@ishahrier
Copy link
Contributor

ishahrier commented Jun 23, 2017 via email

nozzlegear pushed a commit that referenced this issue Mar 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants