GetStream / stream-ruby

Ruby Client - Build Activity Feeds & Streams with GetStream.io
https://getstream.io
BSD 3-Clause "New" or "Revised" License
85 stars 32 forks source link

Add support for retrieving enriched activities by ID #119

Closed Nekuromento closed 2 years ago

Nekuromento commented 4 years ago

Allow users to specify whether activities retrieved by ID should be enriched:

STREAM_CLIENT.get_activities(ids: [...], enrich: true)
faustoct1 commented 4 years ago

It worked for me

signature = Stream::Signer.create_jwt_token('activities', '*', '<your_secret>', '*')

uri = URI("https://us-east-api.stream-io-api.com/api/v1.0/enrich/activities/?api_key=<api_key>&ids=<id1,id2,...>&withReactionCounts=true")
req = Net::HTTP::Get.new(uri)
req['Content-Type'] = "application/json"
req['Stream-Auth-Type'] = "jwt"
req['Authorization'] = signature

res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) {|http|
  http.request(req)
}

puts JSON.parse(res.body)

References https://getstream.io/docs/#retrieve https://getstream.io/docs/#reactions_read-feeds https://getstream.io/docs_rest/#activities