예제 #1
0
 /// <summary>
 /// Deletes a data in API.
 /// </summary>
 /// <param name="apiPath">API query and path, not include domain.</param>
 public async Task DeleteAsync(string apiPath)
 {
     using (var req = RequestEngine.CreateRequest(_AuthState, apiPath, HttpMethod.Delete))
     {
         await RequestEngine.ExecuteRequestToStringAsync(req, ExecutionPolicy);
     }
 }
예제 #2
0
 /// <summary>
 /// Gets a results in API.
 /// </summary>
 /// <param name="apiPath">API query and path, not include domain.</param>
 public async Task <string> GetAsync(string apiPath)
 {
     using (var req = RequestEngine.CreateRequest(_AuthState, apiPath, HttpMethod.Get))
     {
         return(await RequestEngine.ExecuteRequestToStringAsync(req, ExecutionPolicy));
     }
 }
예제 #3
0
        private async Task <string> PostOrPutAsync(HttpMethod method, string apiPath, object data, string rootElement = null)
        {
            JsonContent content = null;

            if (string.IsNullOrEmpty(rootElement))
            {
                content = new JsonContent(data);
            }
            else
            {
                var body = new Dictionary <string, object>
                {
                    { rootElement, data }
                };
                content = new JsonContent(body);
            }

            using (var req = RequestEngine.CreateRequest(_AuthState, apiPath, method, content, rootElement))
            {
                return(await RequestEngine.ExecuteRequestToStringAsync(req, ExecutionPolicy));
            }
        }