Skip to content

Commit

Permalink
Merge pull request #1308 from elizasorber/adding_indifferent_access_i…
Browse files Browse the repository at this point in the history
…ssue_1296

Adding indifferent access
  • Loading branch information
sle-c authored Jul 23, 2024
2 parents 6a74e1e + 39e7e85 commit 38c55af
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
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

0 comments on commit 38c55af

Please sign in to comment.