示例#1
0
        public async Task UpdateUserAsync(UserUpdate userUpdate)
        {
            string url = string.Format("{0}/{1}", URL.RESTRoot, "user");

            string authzHeader = AuthorizationHeader.CreateForREST(Config.ConsumerKey, Config.ConsumerSecret, AuthToken.Token, AuthToken.TokenSecret, url, "PUT");

            string serializeObject = JsonConvert.SerializeObject(userUpdate);

            HttpContent httpContent = new StringContent(serializeObject);

            HttpRequestItem httpRequestItem = new HttpRequestItem()
            {
                URL = url,
                HttpMethod = HttpMethod.Put,
                AuthzHeader = authzHeader,
                HttpContent = httpContent,
                IsDataRequest = true
            };

            HttpRequestHandler httpRequestHandler = new HttpRequestHandler();
            string executeAsync = await httpRequestHandler.ReadAsStringAsync(httpRequestItem);

            //TODO : Investigate
            //return JsonConvert.DeserializeObject<User>(executeAsync);
        }
示例#2
0
        public async Task<User> GetUserAsync()
        {
            string url = string.Format("{0}/{1}", URL.RESTRoot, "user");

            string authzHeader = AuthorizationHeader.CreateForREST(Config.ConsumerKey, Config.ConsumerSecret, AuthToken.Token, AuthToken.TokenSecret, url, "GET");

            HttpRequestItem httpRequestItem = new HttpRequestItem()
            {
                URL = url,
                HttpMethod = HttpMethod.Get,
                AuthzHeader = authzHeader,
                HttpContent = null,
                IsDataRequest = true
            };

            HttpRequestHandler httpRequestHandler = new HttpRequestHandler();
            string executeAsync = await httpRequestHandler.ReadAsStringAsync(httpRequestItem);

            return JsonConvert.DeserializeObject<User>(executeAsync);
        }