Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,13 @@ func (c *Client) GetEnrichedActivitiesByID(ctx context.Context, ids []string, op
}

// GetReactions returns reactions for the current app having the given IDs.
func (c *Client) GetReactions(ctx context.Context, ids []string) (*GetReactionsByIDsResponse, error) {
func (c *Client) GetReactions(ctx context.Context, ids []string, opts ...GetReactionsOption) (*GetReactionsByIDsResponse, error) {
endpoint := c.makeEndpoint("reaction/get_many/")
endpoint.addQueryParam(makeRequestOption("ids", strings.Join(ids, ",")))

for _, opt := range opts {
endpoint.addQueryParam(opt)
}
data, err := c.get(ctx, endpoint, nil, c.authenticator.reactionsAuth)
if err != nil {
return nil, err
Expand Down
8 changes: 8 additions & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@ func TestGetReactions(t *testing.T) {
testRequest(t, requester.req, http.MethodGet, "https://api.stream-io-api.com/api/v1.0/reaction/get_many/?api_key=key&ids=foo%2Cbar%2Cbaz", "")
}

func TestGetReactionsIncludeDeleted(t *testing.T) {
ctx := context.Background()
client, requester := newClient(t)
_, err := client.GetReactions(ctx, []string{"foo", "bar", "baz"}, stream.WithReactionsIncludeDeleted())
require.NoError(t, err)
testRequest(t, requester.req, http.MethodGet, "https://api.stream-io-api.com/api/v1.0/reaction/get_many/?api_key=key&ids=foo%2Cbar%2Cbaz&include_deleted=true", "")
}

func TestUpdateActivityByID(t *testing.T) {
ctx := context.Background()
client, requester := newClient(t)
Expand Down
8 changes: 8 additions & 0 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,11 @@ func (nop) values() (key, value string) {
func (nop) valid() bool {
return false
}

type GetReactionsOption struct {
requestOption
}

func WithReactionsIncludeDeleted() GetReactionsOption {
return GetReactionsOption{makeRequestOption("include_deleted", true)}
}