ShopifySharp icon indicating copy to clipboard operation
ShopifySharp copied to clipboard

Some properties on ShopifySharp.Order class should not be assignable

Open petre-c opened this issue 3 years ago • 5 comments

Some properties on ShopifySharp.Order are assignable, like, for example, Order.AppId, value for which can only be returned from the API call but not passed in.

Would it make sense to make such properties unassignable from user code?

petre-c avatar Oct 07 '22 08:10 petre-c

Hey @petrechitashvili! I've thought about doing this as well. In general I don't think it's a bad idea, and it would hopefully prevent some confusion as to why some properties aren't being changed during updates or creation; we've had questions about that exact thing in the past.

I think the reason it was never implemented from the start is because Shopify used to be very poor at documenting their API, and it was rare for them to even document all of the properties on an object, let alone which ones were read only and which weren't.

They've certainly turned things around now though and the documentation is much better. However, it'd be a lot of work to go through all of the documentation and all of the classes to make the right properties read only. That's something I'd want to save for a 6.0 release I think!

nozzlegear avatar Oct 07 '22 16:10 nozzlegear

Of course we'd have to make sure that the deserialization logic can set private properties because I don't think it is the case by default.

clement911 avatar Oct 07 '22 21:10 clement911

@nozzlegear I see your point and it makes sense, thanks for clarifying.

@clement911 I'd propose to use two separate classes for input and output and make it possible to convert between the two types. Does it make sense?

petre-c avatar Oct 08 '22 10:10 petre-c

What do you think about separating Order class into SendOrder and ReceiveOrder?

petre-c avatar Oct 11 '22 14:10 petre-c

I think this will add a lot of unnecessary boiler plate code. I think the right design to change the de-serializer so that it can populate private properties. I'm pretty sure it's not that hard to do with Json.NET (I think there is a setting for it).

clement911 avatar Oct 11 '22 22:10 clement911