Skip to content

Commit

Permalink
refactor: use model class to hold version information
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeSchwert committed Sep 28, 2023
1 parent 35f91a7 commit 94dc519
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Immutable.Passport.Model;

namespace Immutable.Passport.Model
{
Expand All @@ -10,7 +11,6 @@ internal class InitRequest
public string ClientId;
public string Environment;
public string? RedirectUri;
public string EngineVersion;
public VersionInfo EngineVersion;
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

namespace Immutable.Passport.Model
{
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class VersionInfo
{
public string? Engine;
public string? EngineVersion;
public string? Platform;
public string? PlatformVersion;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions src/Packages/Passport/Runtime/Scripts/Private/PassportImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@ public PassportImpl(IBrowserCommunicationsManager communicationsManager)
public async UniTask Init(string clientId, string environment, string? redirectUri = null, string? deeplink = null)
{
this.redirectUri = redirectUri;
// var engineVersion = $"engine-unity-{unityVersion},platform-{platform}-{osVersion}";
var versionInfo = new Dictionary<string, string>

var versionInfo = new VersionInfo
{
{ "engine", "unity" },
{ "engineVersion", unityVersion },
{ "platform", $"{platform}" },
{ "platformVersion", osVersion }
Engine = "unity",
EngineVersion = unityVersion,
Platform = platform.ToString(),
PlatformVersion = osVersion
};
var engineVersion = JsonConvert.SerializeObject(versionInfo);

InitRequest request = new() { ClientId = clientId, Environment = environment, RedirectUri = redirectUri, EngineVersion = engineVersion };
InitRequest request = new() { ClientId = clientId, Environment = environment, RedirectUri = redirectUri, EngineVersion = versionInfo };

string response = await communicationsManager.Call(
PassportFunction.INIT,
Expand Down

0 comments on commit 94dc519

Please sign in to comment.