@@ -26,7 +26,7 @@ def next(scroll_parameter = nil)
2626 raise Intercom ::HttpError , 'Http Error - No response entity returned' unless response_hash
2727
2828 @scroll_param = extract_scroll_param ( response_hash )
29- top_level_entity_key = deserialize_response_hash ( response_hash )
29+ top_level_entity_key = entity_key_from_response ( response_hash )
3030 response_hash [ top_level_entity_key ] = response_hash [ top_level_entity_key ] . map do |object_json |
3131 Lib ::TypedJsonDeserializer . new ( object_json , @client ) . deserialize
3232 end
@@ -44,7 +44,8 @@ def each(&block)
4444 end
4545 raise Intercom ::HttpError , 'Http Error - No response entity returned' unless response_hash
4646
47- response_hash [ deserialize_response_hash ( response_hash ) ] . each do |object_json |
47+ top_level_entity_key = entity_key_from_response ( response_hash )
48+ response_hash [ top_level_entity_key ] . each do |object_json |
4849 block . call Lib ::TypedJsonDeserializer . new ( object_json , @client ) . deserialize
4950 end
5051 scroll_param = extract_scroll_param ( response_hash )
@@ -55,8 +56,8 @@ def each(&block)
5556
5657 private
5758
58- def deserialize_response_hash ( response_hash )
59- top_level_type = response_hash . delete ( 'type' )
59+ def entity_key_from_response ( response_hash )
60+ top_level_type = response_hash [ 'type' ]
6061 if resource_name == 'subscriptions'
6162 'items'
6263 else
@@ -65,7 +66,7 @@ def deserialize_response_hash(response_hash)
6566 end
6667
6768 def records_present? ( response_hash )
68- !response_hash [ @resource_name ] . empty?
69+ !response_hash [ entity_key_from_response ( response_hash ) ] . empty?
6970 end
7071
7172 def extract_scroll_param ( response_hash )
0 commit comments