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

Adding indifferent access #1308

Merged
merged 4 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Note: For changes to the API, see https://shopify.dev/changelog?filter=api
## Unreleased

- [#1327](https://github.com/Shopify/shopify-api-ruby/pull/1327) Support `?debug=true` parameter in GraphQL client requests
- [#1308](https://github.com/Shopify/shopify-api-ruby/pull/1308) Support hash_with_indifferent_access when creating REST objects from Shopify responses. Closes #1296

## 14.4.0

Expand Down
3 changes: 2 additions & 1 deletion lib/shopify_api/rest/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# frozen_string_literal: true

require "active_support/inflector"
require "active_support/core_ext/hash/indifferent_access"

module ShopifyAPI
module Rest
Expand Down Expand Up @@ -248,7 +249,7 @@ def request(http_method:, operation:, session:, ids: {}, params: {}, body: nil,
def create_instances_from_response(response:, session:)
objects = []

body = T.cast(response.body, T::Hash[String, T.untyped])
body = T.cast(response.body, T::Hash[String, T.untyped]).with_indifferent_access

response_names = json_response_body_names

Expand Down
3 changes: 3 additions & 0 deletions sorbet/rbi/shims/hash.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Hash
def with_indifferent_access; end
end
Loading