Skip to content

Commit ce22a72

Browse files
committed
Get universal conversation count
1 parent c4cf9c6 commit ce22a72

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/intercom/service/count.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ def for_app
1515
end
1616

1717
def for_type(type:, count: nil)
18-
find(type: type, count: count)
18+
params = {type: type}
19+
params[:count] = count if count
20+
find(params)
1921
end
2022
end
2123
end

spec/unit/intercom/count_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@
1414
counts = client.counts.for_type(type: 'user', count: 'segment')
1515
counts.user['segment'][4]["segment 1"].must_equal(1)
1616
end
17+
18+
it 'should not include count param when nil' do
19+
client.expects(:get).with("/counts", {type: 'conversation'}).returns(test_segment_count)
20+
counts = client.counts.for_type(type: 'conversation')
21+
counts.user['segment'][4]["segment 1"].must_equal(1)
22+
end
1723
end

0 commit comments

Comments
 (0)