Пример #1
0
        public static EvalAuthInfo evalAuthInfo(string source)
        {
            var          serializer = new JavaScriptSerializer();
            EvalAuthInfo obj        = serializer.Deserialize <EvalAuthInfo>(source);

            return(obj);
        }
Пример #2
0
        public static EvalAuthInfo evalAuth(Client client)
        {
            var uri = client.getUri() + "users/auth/";

            Uri requestUri = null;

            Uri.TryCreate(uri, UriKind.Absolute, out requestUri);

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUri);

            request.Method = "GET";

            request.ContentType = "application/x-www-form-urlencoded";
            request.Headers.Add("Authorization", string.Concat("Basic ",
                                                               (Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}", client.getFullAuth()))))));

            HttpWebResponse response   = (HttpWebResponse)request.GetResponse();
            Stream          respStream = response.GetResponseStream();

            var reader = new StreamReader(respStream);
            var stripe = reader.ReadToEnd();

            EvalAuthInfo obj = Factory.Factory.evalAuthInfo(stripe);

            switch (obj.code)
            {
            case 200:
                return(obj);

            default:
                throw new Exception("Code " + obj.code + ": " + obj.message);
            }
        }
Пример #3
0
        public void TestEvalAuth()
        {
            bool res = false;

            try
            {
                Client       client   = new Client(publickey, privatekey, mode);
                EvalAuthInfo response = Validations.evalAuth(client);

                res = !response.Equals(null);
            }catch (Exception e)
            {
                res = false;
            }

            Assert.IsTrue(res);
        }