Closed DaveEshopGuide closed 3 months ago
Hi @DaveEshopGuide , thank you for creating this issue. We'll look into this and prioritize it accordingly. Given that this is a minor issue, this may take us some time to get to it.
Hi, I'm looking into making my first contribution. Could I work on this issue?
hi @elizasorber , please go ahead, we always welcome contributions from the community 🎉
Overview
Enable indifferent access on all Hashes in Shopify Objects
The proposed change involves modifying the create_instances_from_response method in the ShopifyAPI::Rest::Base class to use with_indifferent_access on the body hash. This change allows for accessing the hash keys as either strings or symbols interchangeably. This feature would be beneficial for the following reasons:
Flexibility: It provides flexibility in accessing hash keys, which can be particularly useful when dealing with JSON responses where keys can be either strings or symbols.
Error Prevention: It can help prevent potential key access errors that might occur due to mismatched key types.
Consistency: It aligns with the Rails convention of indifferent access, providing a more consistent experience for developers
We ran into this upgrading beyond V10 where we had to restructure a lot of Code and Factories in Specs for the Shopify Objects were Producing Hashes with symbol access while the "real" objects come with string keys.
If there is no strong reason against it I would be happy to see indifferent_access on the Shopify objects or at least a config parameter to enable this analog to "response_as_struct"