Skip to content

Commit 5aceaeb

Browse files
committed
update sdk to handle marketing consent params
1 parent 65cf736 commit 5aceaeb

5 files changed

Lines changed: 68 additions & 2 deletions

File tree

src/Packages/Passport/Runtime/Scripts/Private/Model/DirectLoginMethod.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Immutable.Passport.Model
88
[Serializable]
99
public enum DirectLoginMethod
1010
{
11+
None,
1112
Email,
1213
Google,
1314
Apple,

src/Packages/Passport/Runtime/Scripts/Private/Model/DirectLoginOptions.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,32 @@ public class DirectLoginOptions
1919
/// </summary>
2020
public string email;
2121

22+
/// <summary>
23+
/// Marketing consent status (optional).
24+
/// </summary>
25+
public MarketingConsentStatus? marketingConsentStatus;
26+
2227
/// <summary>
2328
/// Default constructor.
2429
/// </summary>
2530
public DirectLoginOptions()
2631
{
2732
directLoginMethod = DirectLoginMethod.Email;
2833
email = null;
34+
marketingConsentStatus = null;
2935
}
3036

3137
/// <summary>
3238
/// Constructor with method and email.
3339
/// </summary>
3440
/// <param name="loginMethod">The direct login method</param>
3541
/// <param name="emailAddress">The email address (optional)</param>
36-
public DirectLoginOptions(DirectLoginMethod loginMethod, string emailAddress = null)
42+
/// <param name="marketingConsentStatus">The marketing consent status (optional)</param>
43+
public DirectLoginOptions(DirectLoginMethod loginMethod, string emailAddress = null, MarketingConsentStatus? marketingConsentStatus = null)
3744
{
3845
directLoginMethod = loginMethod;
3946
email = emailAddress;
47+
this.marketingConsentStatus = marketingConsentStatus;
4048
}
4149

4250
/// <summary>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
3+
namespace Immutable.Passport.Model
4+
{
5+
/// <summary>
6+
/// Enum representing marketing consent status.
7+
/// </summary>
8+
[Serializable]
9+
public enum MarketingConsentStatus
10+
{
11+
OptedIn,
12+
Unsubscribed
13+
}
14+
15+
/// <summary>
16+
/// Extension methods for MarketingConsentStatus enum.
17+
/// </summary>
18+
public static class MarketingConsentStatusExtensions
19+
{
20+
/// <summary>
21+
/// Converts the enum value to the string format expected by the game bridge.
22+
/// </summary>
23+
/// <param name="status">The marketing consent status</param>
24+
/// <returns>The corresponding string value</returns>
25+
public static string ToApiString(this MarketingConsentStatus status)
26+
{
27+
return status switch
28+
{
29+
MarketingConsentStatus.OptedIn => "opted_in",
30+
MarketingConsentStatus.Unsubscribed => "unsubscribed",
31+
_ => throw new ArgumentOutOfRangeException(nameof(status), status, "Unknown MarketingConsentStatus value")
32+
};
33+
}
34+
}
35+
}

src/Packages/Passport/Runtime/Scripts/Private/Model/MarketingConsentStatus.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Packages/Passport/Runtime/Scripts/Private/PassportImpl.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,22 @@ private async UniTask LaunchAuthUrl()
287287
requestJson += $",\"email\":\"{_directLoginOptions.email}\"";
288288
}
289289

290+
if (_directLoginOptions.marketingConsentStatus != null)
291+
{
292+
var consentValue = _directLoginOptions.marketingConsentStatus.Value.ToApiString();
293+
requestJson += $",\"marketingConsentStatus\":\"{consentValue}\"";
294+
}
295+
290296
requestJson += "}";
291297
}
298+
else
299+
{
300+
PassportLogger.Debug($"{TAG} No direct login options provided (standard auth flow)");
301+
}
292302

293303
requestJson += "}";
294-
304+
305+
PassportLogger.Debug($"{TAG} Sending auth URL request: {requestJson}");
295306
var callResponse = await _communicationsManager.Call(PassportFunction.GET_PKCE_AUTH_URL, requestJson);
296307
var response = callResponse.OptDeserializeObject<StringResponse>();
297308

0 commit comments

Comments
 (0)