Skip to content

Commit c60a49b

Browse files
authored
Merge pull request #1332 from Shopify/rest_block_edit_attributes
Add support for updating REST attributes as blocks
2 parents 42e1275 + 0c432ae commit c60a49b

15 files changed

Lines changed: 73 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Note: For changes to the API, see https://shopify.dev/changelog?filter=api
66

77
- [#1327](https://github.com/Shopify/shopify-api-ruby/pull/1327) Support `?debug=true` parameter in GraphQL client requests
88
- [#1308](https://github.com/Shopify/shopify-api-ruby/pull/1308) Support hash_with_indifferent_access when creating REST objects from Shopify responses. Closes #1296
9+
- [#1332](https://github.com/Shopify/shopify-api-ruby/pull/1332) Fixed an issue where `Customer` REST API PUT requests didn't send all of the fields in the `email_marketing_consent` attribute
910

1011
## 14.4.0
1112

lib/shopify_api/rest/base.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Base
1717
@paths = T.let([], T::Array[T::Hash[Symbol, T.any(T::Array[Symbol], String, Symbol)]])
1818
@custom_prefix = T.let(nil, T.nilable(String))
1919
@read_only_attributes = T.let([], T.nilable(T::Array[Symbol]))
20+
@atomic_hash_attributes = T.let([], T::Array[Symbol])
2021
@aliased_properties = T.let({}, T::Hash[String, String])
2122

2223
sig { returns(T::Hash[Symbol, T.untyped]) }
@@ -62,6 +63,9 @@ class << self
6263
sig { returns(T::Hash[Symbol, T::Class[T.anything]]) }
6364
attr_reader :has_one
6465

66+
sig { returns(T.nilable(T::Array[Symbol])) }
67+
attr_reader :atomic_hash_attributes
68+
6569
sig { returns(T.nilable(T::Hash[T.any(Symbol, String), String])) }
6670
attr_accessor :headers
6771

@@ -418,6 +422,7 @@ def attributes_to_update
418422
ShopifyAPI::Utils::AttributesComparator.compare(
419423
stringified_updatable_attributes,
420424
stringified_new_attributes,
425+
atomic_hash_attributes: self.class.atomic_hash_attributes || [],
421426
)
422427
end
423428

lib/shopify_api/rest/resources/2022_04/customer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil)
5555
metafield: Metafield
5656
}, T::Hash[Symbol, Class])
5757
@has_many = T.let({}, T::Hash[Symbol, Class])
58+
@atomic_hash_attributes = [:email_marketing_consent]
5859
@paths = T.let([
5960
{http_method: :delete, operation: :delete, ids: [:id], path: "customers/<id>.json"},
6061
{http_method: :get, operation: :count, ids: [], path: "customers/count.json"},

lib/shopify_api/rest/resources/2022_07/customer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil)
5555
metafield: Metafield
5656
}, T::Hash[Symbol, Class])
5757
@has_many = T.let({}, T::Hash[Symbol, Class])
58+
@atomic_hash_attributes = [:email_marketing_consent]
5859
@paths = T.let([
5960
{http_method: :delete, operation: :delete, ids: [:id], path: "customers/<id>.json"},
6061
{http_method: :get, operation: :count, ids: [], path: "customers/count.json"},

lib/shopify_api/rest/resources/2022_10/customer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil)
5555
metafield: Metafield
5656
}, T::Hash[Symbol, Class])
5757
@has_many = T.let({}, T::Hash[Symbol, Class])
58+
@atomic_hash_attributes = [:email_marketing_consent]
5859
@paths = T.let([
5960
{http_method: :delete, operation: :delete, ids: [:id], path: "customers/<id>.json"},
6061
{http_method: :get, operation: :count, ids: [], path: "customers/count.json"},

lib/shopify_api/rest/resources/2023_01/customer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil)
5555
metafield: Metafield
5656
}, T::Hash[Symbol, Class])
5757
@has_many = T.let({}, T::Hash[Symbol, Class])
58+
@atomic_hash_attributes = [:email_marketing_consent]
5859
@paths = T.let([
5960
{http_method: :delete, operation: :delete, ids: [:id], path: "customers/<id>.json"},
6061
{http_method: :get, operation: :count, ids: [], path: "customers/count.json"},

lib/shopify_api/rest/resources/2023_04/customer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil)
5555
metafield: Metafield
5656
}, T::Hash[Symbol, Class])
5757
@has_many = T.let({}, T::Hash[Symbol, Class])
58+
@atomic_hash_attributes = [:email_marketing_consent]
5859
@paths = T.let([
5960
{http_method: :delete, operation: :delete, ids: [:id], path: "customers/<id>.json"},
6061
{http_method: :get, operation: :count, ids: [], path: "customers/count.json"},

lib/shopify_api/rest/resources/2023_07/customer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil)
5555
metafield: Metafield
5656
}, T::Hash[Symbol, Class])
5757
@has_many = T.let({}, T::Hash[Symbol, Class])
58+
@atomic_hash_attributes = [:email_marketing_consent]
5859
@paths = T.let([
5960
{http_method: :delete, operation: :delete, ids: [:id], path: "customers/<id>.json"},
6061
{http_method: :get, operation: :count, ids: [], path: "customers/count.json"},

lib/shopify_api/rest/resources/2023_10/customer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil)
5555
metafield: Metafield
5656
}, T::Hash[Symbol, Class])
5757
@has_many = T.let({}, T::Hash[Symbol, Class])
58+
@atomic_hash_attributes = [:email_marketing_consent]
5859
@paths = T.let([
5960
{http_method: :delete, operation: :delete, ids: [:id], path: "customers/<id>.json"},
6061
{http_method: :get, operation: :count, ids: [], path: "customers/count.json"},

lib/shopify_api/rest/resources/2024_01/customer.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil)
5555
metafield: Metafield
5656
}, T::Hash[Symbol, Class])
5757
@has_many = T.let({}, T::Hash[Symbol, Class])
58+
@atomic_hash_attributes = [:email_marketing_consent]
5859
@paths = T.let([
5960
{http_method: :delete, operation: :delete, ids: [:id], path: "customers/<id>.json"},
6061
{http_method: :get, operation: :count, ids: [], path: "customers/count.json"},

0 commit comments

Comments
 (0)