Skip to content

Commit 0696f98

Browse files
authored
feat(reaction): add overload for reactionId (#74)
1 parent 5308f7f commit 0696f98

File tree

16 files changed

+346
-43
lines changed

16 files changed

+346
-43
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @ferhatelmas @peterdeme
1+
* @ferhatelmas

.github/workflows/ci.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
env:
1717
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
1818
steps:
19-
- uses: actions/checkout@v2
19+
- uses: actions/checkout@v3
2020
with:
2121
fetch-depth: 0
2222

@@ -28,7 +28,7 @@ jobs:
2828
dotnet-version: 6.0.x
2929

3030
- name: Dependency cache
31-
uses: actions/cache@v2
31+
uses: actions/cache@v3
3232
id: cache
3333
with:
3434
path: ~/.nuget/packages

.github/workflows/initiate_release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ jobs:
1111
init_release:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v3
1515
with:
1616
fetch-depth: 0 # gives the changelog generator access to all previous commits
1717

1818
- name: Create release branch
1919
run: scripts/create_release_branch.sh "${{ github.event.inputs.version }}"
2020

2121
- name: Get changelog diff
22-
uses: actions/github-script@v5
22+
uses: actions/github-script@v6
2323
with:
2424
script: |
2525
const get_change_log_diff = require('./scripts/get_changelog_diff.js')

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ jobs:
1313
env:
1414
DOTNET_CLI_TELEMETRY_OPTOUT: "true"
1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v3
1717
with:
1818
fetch-depth: 0
1919

20-
- uses: actions/github-script@v5
20+
- uses: actions/github-script@v6
2121
with:
2222
script: |
2323
const get_change_log_diff = require('./scripts/get_changelog_diff.js')

.github/workflows/reviewdog.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ jobs:
1010
reviewdog:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414

1515
- uses: reviewdog/action-setup@v1
1616
with:
1717
reviewdog_version: latest
1818

1919
- name: Setup dotnet
20-
uses: actions/setup-dotnet@v1
20+
uses: actions/setup-dotnet@v2
2121
with:
2222
dotnet-version: 6.0.x
2323

src/IReactions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,18 @@ namespace Stream
1313
/// <remarks>https://getstream.io/activity-feeds/docs/dotnet-csharp/reactions_introduction/?language=csharp</remarks>
1414
public interface IReactions
1515
{
16+
/// <summary>Posts a new reaciton.</summary>
17+
/// <remarks>https://getstream.io/activity-feeds/docs/dotnet-csharp/reactions_introduction/?language=csharp</remarks>
18+
Task<Reaction> AddAsync(string reactionId, string kind, string activityId, string userId, IDictionary<string, object> data = null, IEnumerable<string> targetFeeds = null);
19+
1620
/// <summary>Posts a new reaciton.</summary>
1721
/// <remarks>https://getstream.io/activity-feeds/docs/dotnet-csharp/reactions_introduction/?language=csharp</remarks>
1822
Task<Reaction> AddAsync(string kind, string activityId, string userId, IDictionary<string, object> data = null, IEnumerable<string> targetFeeds = null);
1923

24+
/// <summary>Adds a new child reaction.</summary>
25+
/// <remarks>https://getstream.io/activity-feeds/docs/dotnet-csharp/reactions_introduction/?language=csharp</remarks>
26+
Task<Reaction> AddChildAsync(Reaction parent, string reactionId, string kind, string userId, IDictionary<string, object> data = null, IEnumerable<string> targetFeeds = null);
27+
2028
/// <summary>Adds a new child reaction.</summary>
2129
/// <remarks>https://getstream.io/activity-feeds/docs/dotnet-csharp/reactions_introduction/?language=csharp</remarks>
2230
Task<Reaction> AddChildAsync(Reaction parent, string kind, string userId, IDictionary<string, object> data = null, IEnumerable<string> targetFeeds = null);

src/Reactions.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ internal Reactions(StreamClient client)
2020

2121
public async Task<Reaction> AddAsync(string kind, string activityId, string userId,
2222
IDictionary<string, object> data = null, IEnumerable<string> targetFeeds = null)
23+
{
24+
return await AddAsync(null, kind, activityId, userId, data, targetFeeds);
25+
}
26+
27+
public async Task<Reaction> AddAsync(string reactionId, string kind, string activityId, string userId,
28+
IDictionary<string, object> data = null, IEnumerable<string> targetFeeds = null)
2329
{
2430
var r = new Reaction
2531
{
32+
Id = reactionId,
2633
Kind = kind,
2734
ActivityId = activityId,
2835
UserId = userId,
@@ -35,9 +42,16 @@ public async Task<Reaction> AddAsync(string kind, string activityId, string user
3542

3643
public async Task<Reaction> AddChildAsync(Reaction parent, string kind, string userId,
3744
IDictionary<string, object> data = null, IEnumerable<string> targetFeeds = null)
45+
{
46+
return await AddChildAsync(parent, null, kind, userId, data, targetFeeds);
47+
}
48+
49+
public async Task<Reaction> AddChildAsync(Reaction parent, string reactionId, string kind, string userId,
50+
IDictionary<string, object> data = null, IEnumerable<string> targetFeeds = null)
3851
{
3952
var r = new Reaction()
4053
{
54+
Id = reactionId,
4155
Kind = kind,
4256
UserId = userId,
4357
Data = data,

src/Rest/RestClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ private HttpContent CreateFileStream(RestRequest request)
6666
private Uri BuildUri(RestRequest request)
6767
{
6868
var queryStringBuilder = new StringBuilder();
69-
request.QueryParameters.ForEach((p) =>
69+
request.QueryParameters.ForEach(p =>
7070
{
7171
queryStringBuilder.Append(queryStringBuilder.Length == 0 ? "?" : "&");
72-
queryStringBuilder.Append($"{p.Key}={Uri.EscapeDataString(p.Value.ToString())}");
72+
queryStringBuilder.Append($"{p.Key}={Uri.EscapeDataString(p.Value)}");
7373
});
7474

7575
return new Uri(_baseUrl, request.Resource + queryStringBuilder.ToString());
7676
}
7777

78-
public async Task<RestResponse> ExecuteHttpRequestAsync(RestRequest request)
78+
internal async Task<RestResponse> ExecuteHttpRequestAsync(RestRequest request)
7979
{
8080
var uri = BuildUri(request);
8181

src/Rest/RestRequest.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ internal RestRequest(string resource, HttpMethod method)
1111
Resource = resource;
1212
}
1313

14-
public Dictionary<string, string> QueryParameters { get; private set; } = new Dictionary<string, string>();
15-
public Dictionary<string, string> Headers { get; private set; } = new Dictionary<string, string>();
16-
public HttpMethod Method { get; private set; }
17-
public string Resource { get; private set; }
18-
public string JsonBody { get; private set; }
19-
public System.IO.Stream FileStream { get; private set; }
20-
public string FileStreamContentType { get; private set; }
21-
public string FileStreamName { get; private set; }
14+
internal Dictionary<string, string> QueryParameters { get; private set; } = new Dictionary<string, string>();
15+
internal Dictionary<string, string> Headers { get; private set; } = new Dictionary<string, string>();
16+
internal HttpMethod Method { get; private set; }
17+
internal string Resource { get; private set; }
18+
internal string JsonBody { get; private set; }
19+
internal System.IO.Stream FileStream { get; private set; }
20+
internal string FileStreamContentType { get; private set; }
21+
internal string FileStreamName { get; private set; }
2222

23-
public void AddHeader(string name, string value) => Headers[name] = value;
23+
internal void AddHeader(string name, string value) => Headers[name] = value;
2424

25-
public void AddQueryParameter(string name, string value) => QueryParameters[name] = value;
25+
internal void AddQueryParameter(string name, string value) => QueryParameters[name] = value;
2626

27-
public void SetJsonBody(string json) => JsonBody = json;
27+
internal void SetJsonBody(string json) => JsonBody = json;
2828

29-
public void SetFileStream(System.IO.Stream stream, string name, string contentType)
29+
internal void SetFileStream(System.IO.Stream stream, string name, string contentType)
3030
{
3131
FileStream = stream;
3232
FileStreamName = name;

src/Rest/RestResponse.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
using System;
2-
using System.Net;
1+
using System.Net;
32
using System.Net.Http;
43
using System.Threading.Tasks;
54

65
namespace Stream.Rest
76
{
87
internal class RestResponse
98
{
10-
public HttpStatusCode StatusCode { get; set; }
9+
internal HttpStatusCode StatusCode { get; set; }
1110

12-
public string Content { get; set; }
11+
internal string Content { get; set; }
1312

1413
internal static async Task<RestResponse> FromResponseMessage(HttpResponseMessage message)
1514
{

0 commit comments

Comments
 (0)