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

Create Hashes in Object instances with_indifferent_access #1296

Open
DaveEshopGuide opened this issue Mar 22, 2024 · 3 comments
Open

Create Hashes in Object instances with_indifferent_access #1296

DaveEshopGuide opened this issue Mar 22, 2024 · 3 comments

Comments

@DaveEshopGuide
Copy link
Contributor

DaveEshopGuide commented Mar 22, 2024

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"

@sle-c
Copy link
Contributor

sle-c commented Mar 28, 2024

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.

@elizasorber
Copy link

Hi, I'm looking into making my first contribution. Could I work on this issue?

@sle-c
Copy link
Contributor

sle-c commented Apr 5, 2024

hi @elizasorber , please go ahead, we always welcome contributions from the community 🎉

elizasorber added a commit to elizasorber/shopify-api-ruby that referenced this issue Apr 5, 2024
…ces_from_response in the ShopifyAPI::Rest::Base class.
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

3 participants