Skip to content

Commit aec1e94

Browse files
author
Suma Prakash
committed
Adding a fix
1 parent bf0ea22 commit aec1e94

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

lib/intercom/base_collection_proxy.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ def deserialize_response_hash(response_hash, block)
4545
Utils.entity_key_from_type(top_level_type)
4646
end
4747
response_hash[top_level_entity_key].each do |object_json|
48-
block.call Lib::TypedJsonDeserializer.new(object_json, @client).deserialize
48+
if top_level_type == 'event.summary'
49+
block.call Lib::TypedJsonDeserializer.new(object_json, @client, top_level_type).deserialize
50+
else
51+
block.call Lib::TypedJsonDeserializer.new(object_json, @client).deserialize
52+
end
4953
end
5054
end
5155

lib/intercom/lib/typed_json_deserializer.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ module Lib
99
class TypedJsonDeserializer
1010
attr_reader :json
1111

12-
def initialize(json, client)
12+
def initialize(json, client, type = nil)
1313
@json = json
1414
@client = client
15+
@type = type
1516
end
1617

1718
def deserialize
@@ -27,7 +28,7 @@ def deserialize
2728
private
2829

2930
def blank_object_type?(object_type)
30-
object_type.nil? || object_type == ''
31+
object_type.nil? || object_type == '' && @type.nil?
3132
end
3233

3334
def list_object_type?(object_type)
@@ -48,7 +49,11 @@ def deserialize_object(object_json)
4849
end
4950

5051
def object_type
51-
@object_type ||= json['type']
52+
if !@type.nil?
53+
@object_type = @type
54+
else
55+
@object_type ||= json['type']
56+
end
5257
end
5358

5459
def object_entity_key

lib/intercom/utils.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def entity_key_from_type(type)
6969

7070
is_list = type.split('.')[1] == 'list'
7171
entity_name = type.split('.')[0]
72+
return Utils.pluralize(entity_name) if entity_name == 'event'
7273
is_list ? Utils.pluralize(entity_name) : entity_name
7374
end
7475
end

0 commit comments

Comments
 (0)