internal static string DownloadRemoteSettings(string managerID, BuildTarget platform, CASInitSettings settings, DependencyManager deps)
        {
            const string title = "Update CAS remote settings";

            var editorSettings = CASEditorSettings.Load();

            #region Create request URL
            #region Hash
            var managerIdBytes = new UTF8Encoding().GetBytes(managerID);
            var suffix         = new byte[] { 48, 77, 101, 68, 105, 65, 116, 73, 111, 78, 104, 65, 115, 72 };
            if (platform == BuildTarget.iOS)
            {
                suffix[0] = 49;
            }
            var sourceBytes = new byte[managerID.Length + suffix.Length];
            Array.Copy(managerIdBytes, 0, sourceBytes, 0, managerIdBytes.Length);
            Array.Copy(suffix, 0, sourceBytes, managerIdBytes.Length, suffix.Length);

            var           hashBytes   = new System.Security.Cryptography.MD5CryptoServiceProvider().ComputeHash(sourceBytes);
            StringBuilder hashBuilder = new StringBuilder();
            for (int i = 0; i < hashBytes.Length; i++)
            {
                hashBuilder.Append(Convert.ToString(hashBytes[i], 16).PadLeft(2, '0'));
            }
            var hash = hashBuilder.ToString().PadLeft(32, '0');
            #endregion

            var urlBuilder = new StringBuilder("https://psvpromo.psvgamestudio.com/Scr/cas.php?platform=")
                             .Append(platform == BuildTarget.Android ? 0 : 1)
                             .Append("&bundle=").Append(UnityWebRequest.EscapeURL(managerID))
                             .Append("&hash=").Append(hash)
                             .Append("&lang=").Append(SystemLanguage.English)
                             .Append("&appDev=2")
                             .Append("&appV=").Append(PlayerSettings.bundleVersion)
                             .Append("&coppa=").Append(( int )settings.defaultAudienceTagged)
                             .Append("&adTypes=").Append(( int )settings.allowedAdFlags)
                             .Append("&nets=").Append(DependencyManager.GetActiveMediationPattern(deps))
                             .Append("&orient=").Append(Utils.GetOrientationId())
                             .Append("&framework=Unity_").Append(Application.unityVersion);
            if (deps != null)
            {
                var buildCode = deps.GetInstalledBuildCode();
                if (buildCode > 0)
                {
                    urlBuilder.Append("&sdk=").Append(buildCode);
                }
            }
            if (string.IsNullOrEmpty(editorSettings.mostPopularCountryOfUsers))
            {
                urlBuilder.Append("&country=").Append("US");
            }
            else
            {
                urlBuilder.Append("&country=").Append(editorSettings.mostPopularCountryOfUsers);
            }
            if (platform == BuildTarget.Android)
            {
                urlBuilder.Append("&appVC=").Append(PlayerSettings.Android.bundleVersionCode);
            }

            #endregion

            using (var loader = UnityWebRequest.Get(urlBuilder.ToString()))
            {
                try
                {
                    loader.SendWebRequest();
                    while (!loader.isDone)
                    {
                        if (EditorUtility.DisplayCancelableProgressBar(title, managerID,
                                                                       Mathf.Repeat(( float )EditorApplication.timeSinceStartup * 0.2f, 1.0f)))
                        {
                            loader.Dispose();
                            throw new Exception("Update CAS Settings canceled");
                        }
                    }
                    if (string.IsNullOrEmpty(loader.error))
                    {
                        var content = loader.downloadHandler.text.Trim();
                        if (string.IsNullOrEmpty(content))
                        {
                            throw new Exception("ManagerID [" + managerID + "] is not registered in CAS.");
                        }

                        EditorUtility.DisplayProgressBar(title, "Write CAS settings", 0.7f);
                        var data = JsonUtility.FromJson <AdmobAppIdData>(content);
                        Utils.WriteToFile(content, Utils.GetNativeSettingsPath(platform, managerID));
                        return(data.admob_app_id);
                    }
                    throw new Exception("Server response " + loader.responseCode + ": " + loader.error);
                }
                finally
                {
                    EditorUtility.ClearProgressBar();
                }
            }
        }