Skip to content

Commit 3120929

Browse files
authored
Add target feeds extra data for reactions (#132)
1 parent b72f253 commit 3120929

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

lib/stream/reactions.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
module Stream
22
class ReactionsClient < Client
3-
def add(kind, activity_id, user_id, data: nil, target_feeds: nil)
3+
def add(kind, activity_id, user_id, data: nil, target_feeds: nil, target_feeds_extra_data: nil)
44
data = {
55
kind: kind,
66
activity_id: activity_id,
77
user_id: user_id,
88
data: data,
9-
target_feeds: target_feeds
9+
target_feeds: target_feeds,
10+
target_feeds_extra_data: target_feeds_extra_data
1011
}
1112
make_reaction_request(:post, {}, data)
1213
end
@@ -30,13 +31,14 @@ def delete(reaction_id)
3031
make_reaction_request(:delete, {}, {}, endpoint: uri)
3132
end
3233

33-
def add_child(kind, parent_id, user_id, data: nil, target_feeds: nil)
34+
def add_child(kind, parent_id, user_id, data: nil, target_feeds: nil, target_feeds_extra_data: nil)
3435
data = {
3536
kind: kind,
3637
parent: parent_id,
3738
user_id: user_id,
3839
data: data,
39-
target_feeds: target_feeds
40+
target_feeds: target_feeds,
41+
target_feeds_extra_data: target_feeds_extra_data
4042
}
4143
make_reaction_request(:post, {}, data)
4244
end

spec/integration_spec.rb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,8 @@
649649
updated_activity = @client.activity_partial_update(
650650
id: activity_a['id'],
651651
set: {
652-
"product.name": 'boots',
653-
"product.price": 7.99,
652+
'product.name': 'boots',
653+
'product.price': 7.99,
654654
popularity: 1000,
655655
foo: { bar: { baz: 'qux' } }
656656
},
@@ -677,7 +677,7 @@
677677
foreign_id: activity_a['foreign_id'],
678678
time: activity_a['time'],
679679
set: {
680-
"foo.bar.baz": 42,
680+
'foo.bar.baz': 42,
681681
popularity: 9000
682682
},
683683
unset: [
@@ -701,16 +701,16 @@
701701
{
702702
id: activity_a['id'],
703703
set: {
704-
"product.name": 'boots',
705-
"product.price": 13.99,
704+
'product.name': 'boots',
705+
'product.price': 13.99,
706706
extra: 'left'
707707
},
708708
unset: ['foo']
709709
},
710710
{
711711
id: activity_b['id'],
712712
set: {
713-
"product.price": 23.99,
713+
'product.price': 23.99,
714714
extra: 'right'
715715
},
716716
unset: ['popularity']
@@ -740,16 +740,16 @@
740740
foreign_id: activity_a['foreign_id'],
741741
time: activity_a['time'],
742742
set: {
743-
"product.name": 'trainers',
744-
"product.price": 133.99
743+
'product.name': 'trainers',
744+
'product.price': 133.99
745745
},
746746
unset: ['extra']
747747
},
748748
{
749749
foreign_id: activity_b['foreign_id'],
750750
time: activity_b['time'],
751751
set: {
752-
"product.price": 3.99
752+
'product.price': 3.99
753753
},
754754
unset: ['extra']
755755
}
@@ -893,12 +893,13 @@
893893
expect(response['activity']).to eq @activity
894894
end
895895
example 'with target feeds' do
896-
reaction = @client.reactions.add('like', @activity['id'], 'juan', target_feeds: [@feed43.id])
896+
reaction = @client.reactions.add('like', @activity['id'], 'juan', target_feeds: [@feed43.id], target_feeds_extra_data: { test: 'test_data' })
897897
reaction.delete('duration')
898898
response = @feed43.get
899899

900900
expect(response['results'][0]['reaction']).to eq @client.reactions.create_reference(reaction)
901901
expect(response['results'][0]['verb']).to eq 'like'
902+
expect(response['results'][0]['test']).to eq 'test_data'
902903
end
903904
end
904905

0 commit comments

Comments
 (0)