示例#1
0
        public async Task <int> GetLatestVersion()
        {
            var request = new GameforgeRequest <int>(HttpMethod.Get, "/patching/download/nostale/default?branchToken");
            Dictionary <string, int> response = await request.Send();

            return(response.GetValueOrDefault("latest"));
        }
        public async Task <IEnumerable <GameforgeAccount> > GetAccounts(bool cache = true)
        {
            if (cache && _accounts != null)
            {
                return(_accounts);
            }

            var request = new GameforgeRequest <GameforgeAccount>(HttpMethod.Get, "/user/accounts", InstallationId, AuthToken);
            Dictionary <string, GameforgeAccount> response = await request.Send();

            if (response == null)
            {
                return(new List <GameforgeAccount>());
            }

            _accounts = new List <GameforgeAccount>(response.Values);
            return(_accounts);
        }
        public async Task <string> GetSessionToken(GameforgeAccount gameforgeAccount, bool raw = false)
        {
            var request        = new GameforgeRequest <SessionRequest, string>(HttpMethod.Post, "/auth/thin/codes", InstallationId, AuthToken);
            var sessionRequest = new SessionRequest
            {
                PlatformGameAccountId = gameforgeAccount.Id
            };

            Dictionary <string, string> response = await request.Send(sessionRequest);

            if (response == null)
            {
                return(string.Empty);
            }

            string data = (response.GetValueOrDefault("code") ?? string.Empty);

            return(raw ? data : data.ToHex());
        }
示例#4
0
        public async Task <AuthorizedGameforgeApi> Login(string email, string password, Locales locale, Guid installationId)
        {
            var request = new GameforgeRequest <AuthRequest, string>(HttpMethod.Post, "/auth/sessions", installationId);

            var authRequest = new AuthRequest
            {
                Locale   = locale.Value,
                Email    = email,
                Password = password
            };

            Dictionary <string, string> response = await request.Send(authRequest);

            if (response == null)
            {
                return(null);
            }

            string authToken = response.GetValueOrDefault("token") ?? string.Empty;

            return(new AuthorizedGameforgeApi(authToken, installationId));
        }