Пример #1
0
 public static async Task TryLogout(User u)
 {
     TryLogoutRequest r = new TryLogoutRequest()
     {
         pulid = u.Pulid
     };
     TryLogoutResponse response = await SGSAPI2.GenericPost <TryLogoutResponse, TryLogoutRequest>(baseUri + "/posLogout", r);
 }
Пример #2
0
        public static async Task <User> TryLogin(string username, string password)
        {
            TryLoginRequest r = new TryLoginRequest()
            {
                username     = username,
                userpassword = password,
                posid        = "pos123",
            };
            TryLoginResponse response = await SGSAPI2.GenericPost <TryLoginResponse, TryLoginRequest>(baseUri + "/posLogin", r);

            if (response.result == "success")
            {
                MessageBox.Show("Successfully logged in.");
            }
            else
            {
                MessageBox.Show("Logged in failed:\n" + response.error.message);
            }

            User u = new User()
            {
                Username    = username,
                Pulid       = response.pulid,
                Permissions = new PermissionGroup()
                {
                    CanApprovePayout = int2Bool(response.rolepermissions.canapprovepayout),
                    CanApproveTotal  = int2Bool(response.rolepermissions.canapprovetotal),
                    CanCreatePos     = int2Bool(response.rolepermissions.cancreatepos),
                    CanDeactivatePos = int2Bool(response.rolepermissions.candeactivatepos),
                    CanManageUsers   = int2Bool(response.rolepermissions.canmanageusers),
                    MaxPayout        = response.rolepermissions.maxpayout,
                    Name             = response.role
                }
            };

            return(u);
        }