diff --git a/src/StoneRed.NetificationApi.Example/Program.cs b/src/StoneRed.NetificationApi.Example/Program.cs
index ef22d51..48316ff 100644
--- a/src/StoneRed.NetificationApi.Example/Program.cs
+++ b/src/StoneRed.NetificationApi.Example/Program.cs
@@ -73,9 +73,9 @@ notificationApiClient.RequestNotifications(5);
Console.WriteLine("Notifications requested");
Console.WriteLine("Identify user");
-await notificationApiServer.Identify(new IdentifyUserData
+await notificationApiServer.Identify(userId, new IdentifyUserData
{
- UserId = userId
+ Email = "example@example.com"
});
Console.WriteLine("User identified");
diff --git a/src/StoneRed.NetificationApi/Server/IdentifyUser/IdentifyUserData.cs b/src/StoneRed.NetificationApi/Server/IdentifyUser/IdentifyUserData.cs
index 92fbefa..795cc04 100644
--- a/src/StoneRed.NetificationApi/Server/IdentifyUser/IdentifyUserData.cs
+++ b/src/StoneRed.NetificationApi/Server/IdentifyUser/IdentifyUserData.cs
@@ -1,5 +1,4 @@
-using System.Diagnostics.CodeAnalysis;
-using System.Text.Json.Serialization;
+using System.Text.Json.Serialization;
namespace StoneRed.NetificationApi.Server.IdentifyUser;
@@ -8,12 +7,6 @@ namespace StoneRed.NetificationApi.Server.IdentifyUser;
///
public class IdentifyUserData
{
- ///
- /// Gets or sets the user ID.
- ///
- [JsonIgnore]
- public required string UserId { get; set; }
-
///
/// Gets or sets the email address of the user.
///
@@ -34,21 +27,4 @@ public class IdentifyUserData
/// Gets or sets the list of web push tokens for the user.
///
public List? WebPushTokens { get; set; }
-
- ///
- /// Initializes a new instance of the class with the specified user ID.
- ///
- /// The user ID.
- [SetsRequiredMembers]
- public IdentifyUserData(string userId)
- {
- UserId = userId;
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- public IdentifyUserData()
- {
- }
}
\ No newline at end of file
diff --git a/src/StoneRed.NetificationApi/Server/NotificationApiServer.cs b/src/StoneRed.NetificationApi/Server/NotificationApiServer.cs
index 803ac97..34538dd 100644
--- a/src/StoneRed.NetificationApi/Server/NotificationApiServer.cs
+++ b/src/StoneRed.NetificationApi/Server/NotificationApiServer.cs
@@ -76,31 +76,26 @@ public class NotificationApiServer
///
/// Identifies a user.
///
+ /// The ID of the user.
/// The data for identifying the user.
/// The HTTP response message.
- public async Task Identify(IdentifyUserData identifyUserData)
+ public async Task Identify(string userId, IdentifyUserData identifyUserData)
{
string authToken;
if (secureMode)
{
- string hashedUserId = UserIdHasher.Hash(identifyUserData.UserId, clientSecret);
- authToken = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{clientId}:{identifyUserData.UserId}:{hashedUserId}"));
+ string hashedUserId = UserIdHasher.Hash(userId, clientSecret);
+ authToken = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{clientId}:{userId}:{hashedUserId}"));
}
else
{
- authToken = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{clientId}:{identifyUserData.UserId}"));
+ authToken = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{clientId}:{userId}"));
}
- var requestData = new
+ HttpRequestMessage request = new(HttpMethod.Post, $"users/{userId}")
{
- email = identifyUserData.Email,
- number = identifyUserData.TelephoneNumber,
- };
-
- HttpRequestMessage request = new(HttpMethod.Post, $"users/{identifyUserData.UserId}")
- {
- Content = JsonContent.Create(requestData, options: Configuration.JsonSerializerOptions),
+ Content = JsonContent.Create(identifyUserData, options: Configuration.JsonSerializerOptions),
};
request.Headers.Add("Authorization", $"Basic {authToken}");
@@ -111,10 +106,11 @@ public class NotificationApiServer
///
/// Sets user preferences.
///
+ /// The ID of the user.
/// The data for setting user preferences.
/// The HTTP response message.
- public async Task SetUserPreferences(SetUserPreferencesData setUserPreferencesData)
+ public async Task SetUserPreferences(string userId, SetUserPreferencesData setUserPreferencesData)
{
- return await httpClient.PostAsJsonAsync($"user_preferences/{setUserPreferencesData.UserId}", setUserPreferencesData, Configuration.JsonSerializerOptions);
+ return await httpClient.PostAsJsonAsync($"user_preferences/{userId}", setUserPreferencesData, Configuration.JsonSerializerOptions);
}
}
\ No newline at end of file
diff --git a/src/StoneRed.NetificationApi/Server/SetUserPreferences/SetUserPreferencesData.cs b/src/StoneRed.NetificationApi/Server/SetUserPreferences/SetUserPreferencesData.cs
index 5e7be5f..42eb949 100644
--- a/src/StoneRed.NetificationApi/Server/SetUserPreferences/SetUserPreferencesData.cs
+++ b/src/StoneRed.NetificationApi/Server/SetUserPreferences/SetUserPreferencesData.cs
@@ -1,5 +1,4 @@
using System.Diagnostics.CodeAnalysis;
-using System.Text.Json.Serialization;
namespace StoneRed.NetificationApi.Server.SetUserPreferences;
@@ -8,12 +7,6 @@ namespace StoneRed.NetificationApi.Server.SetUserPreferences;
///
public class SetUserPreferencesData
{
- ///
- /// Gets or sets the user ID.
- ///
- [JsonIgnore]
- public required string UserId { get; set; }
-
///
/// Gets or sets the list of notification preferences.
///
@@ -22,12 +15,10 @@ public class SetUserPreferencesData
///
/// Initializes a new instance of the class.
///
- /// The user ID.
/// The list of notification preferences.
[SetsRequiredMembers]
- public SetUserPreferencesData(string userId, List preferences)
+ public SetUserPreferencesData(List preferences)
{
- UserId = userId;
Preferences = preferences;
}
diff --git a/src/StoneRed.NetificationApi/StoneRed.NetificationApi.csproj b/src/StoneRed.NetificationApi/StoneRed.NetificationApi.csproj
index d558442..b32e408 100644
--- a/src/StoneRed.NetificationApi/StoneRed.NetificationApi.csproj
+++ b/src/StoneRed.NetificationApi/StoneRed.NetificationApi.csproj
@@ -5,7 +5,7 @@
enable
enable
True
- 1.0.3.0
+ 1.0.4.0
https://github.com/Stone-Red-Software/StoneRed.NetificationApi
MIT
A .NET library for NotificationAPI