Exemplo n.º 1
0
        private T DoExecute <T>(TPlusRequest <T> request, string access_token) where T : TPlusResponse
        {
            string args          = request.ToJson();
            string authorization = SecurityUtil.CreateAuthorizationHeader(appKey, appSecret, "", privateKeyPath, access_token);

            var payload = new Dictionary <string, string>
            {
                { "_args", args },
            };

            string             requestUri     = serverUrl + request.GetResourceMethod();
            HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, requestUri);

            requestMessage.Headers.TryAddWithoutValidation("Authorization", authorization);
            requestMessage.Content = new FormUrlEncodedContent(payload);

            HttpResponseMessage responseMessage = httpClient.SendAsync(requestMessage).Result;
            string body = responseMessage.Content.ReadAsStringAsync().Result;

            T rsp = Activator.CreateInstance <T>();

            if (rsp != null)
            {
                rsp.Body = body;
                rsp.Load(body);
            }

            return(rsp);
        }
Exemplo n.º 2
0
 public T Execute <T>(TPlusRequest <T> request, string access_token) where T : TPlusResponse
 {
     return(DoExecute <T>(request, access_token));
 }
Exemplo n.º 3
0
 public T Execute <T>(TPlusRequest <T> request) where T : TPlusResponse
 {
     return(DoExecute <T>(request, null));
 }