예제 #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"));
        }
예제 #2
0
        public async Task <string> GetSessionToken(GameforgeAccount gameforgeAccount)
        {
            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);
            }

            return((response.GetValueOrDefault("code") ?? string.Empty).ToHex());
        }
예제 #3
0
        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);
        }
예제 #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));
        }