-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIWebApiClient.cs
133 lines (120 loc) · 7.62 KB
/
IWebApiClient.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
using System;
using System.Collections.Generic;
using System.Net;
namespace Dell.Premier.Web.Common.HttpClient
{
/// <summary>
/// <see cref="IWebApiClient" /> is an interface for an HTTP client. See <see cref="WebApiClient" />.
/// </summary>
public interface IWebApiClient
{
/// <summary>Get sends a GET request to the specified <paramref name="url" />.</summary>
/// <param name="url">The URL.</param>
/// <returns>An <see cref="HttpResponse" />.</returns>
/// <param name="extraHeaders">Security or other headers to add to the request</param>
HttpResponse Get(string url, IDictionary<string, string> extraHeaders = null, TimeSpan? timeout = null);
/// <summary>Post sends a POST request to the specified <paramref name="url" />.</summary>
/// <param name="url">The URL.</param>
/// <param name="body">The string body; can be null.</param>
/// <returns>An <see cref="HttpResponse" />.</returns>
HttpResponse Post(string url, string body, IDictionary<string, string> extraHeaders = null);
/// <summary>
/// PostJson sends a POST request to the specified <paramref name="url" /> and sets the Content-Type
/// header to application/json.
/// </summary>
/// <param name="url">The URL.</param>
/// <param name="body">The string body; can be null.</param>
/// <param name="extraHeaders">Security or other headers to add to the request</param>
/// <param name="timeout">The number of seconds to wait before the request times out</param>
/// <returns>An <see cref="HttpResponse" />.</returns>
HttpResponse PostJson(string url, string body, IDictionary<string, string> extraHeaders = null, TimeSpan? timeout = null, WebProxy proxy = null);
/// <summary>
/// PostJson sends a POST request to the specified <paramref name="url" /> and sets the Content-Type
/// header to application/json.
/// </summary>
/// <typeparam name="T">The type of <paramref name="body" />.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="body">The object to serialize into a JSON body.</param>
/// <param name="extraHeaders">Security or other headers to add to the request</param>
/// <returns>An <see cref="HttpResponse" />.</returns>
HttpResponse PostJson<T>(string url, T body, IDictionary<string, string> extraHeaders = null, TimeSpan? timeout = null, bool includeDefaults = true, WebProxy proxy = null)
where T : class;
/// <summary>
/// PostForm sends a POST request to the specified <paramref name="url" /> and sets the Content-Type
/// header to application/x-www-form-urlencoded.
/// </summary>
/// <typeparam name="T">The type of <paramref name="body" />.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="body">
/// The <paramref name="body" /> object's public instance properties with public getters will be converted
/// to an application/x-www-form-urlencoded string. Each property will have <see cref="object.ToString" />
/// called to obtain its value. <c>null</c> properties will be added as an empty string.
/// </param>
/// <param name="extraHeaders">Security or other headers to add to the request</param>
/// <returns>An <see cref="HttpResponse" />.</returns>
HttpResponse PostForm<T>(string url, T body, IDictionary<string, string> extraHeaders = null, WebProxy proxy = null)
where T : class;
/// <summary>Patch sends a PATCH request to the specified <paramref name="url" />.</summary>
/// <param name="url">The URL.</param>
/// <param name="body">The string body; can be null.</param>
/// <param name="extraHeaders"></param>
/// <returns>An <see cref="HttpResponse" />.</returns>
HttpResponse Patch(string url, string body, IDictionary<string, string> extraHeaders = null);
/// <summary>
/// PatchJson sends a PATCH request to the specified <paramref name="url" /> and sets the Content-Type
/// header to application/json.
/// </summary>
/// <param name="url">The URL.</param>
/// <param name="body">The string body; can be null.</param>
/// <param name="extraHeaders">Security or other headers to add to the request</param>
/// <returns>An <see cref="HttpResponse" />.</returns>
HttpResponse PatchJson(string url, string body, IDictionary<string, string> extraHeaders = null);
/// <summary>
/// PatchJson sends a PATCH request to the specified <paramref name="url" /> and sets the Content-Type
/// header to application/json.
/// </summary>
/// <typeparam name="T">The type of <paramref name="body" />.</typeparam>
/// <param name="url">The URL.</param>
/// <param name="body">The object to serialize into a JSON body.</param>
/// <param name="extraHeaders">Security or other headers to add to the request</param>
/// <returns>An <see cref="HttpResponse" />.</returns>
HttpResponse PatchJson<T>(string url, T body, IDictionary<string, string> extraHeaders = null, bool includeDefaults = true)
where T : class;
/// <summary>Put sends a PUT request to the specified <paramref name="url" />.</summary>
/// <param name="url">The URL.</param>
/// <param name="body">The string body; can be null.</param>
/// <returns>An <see cref="HttpResponse" />.</returns>
HttpResponse Put(string url, string body);
/// <summary>
/// PutJson sends a PUT request to the specified <paramref name="url" /> and sets the Content-Type
/// header to application/json.
/// </summary>
/// <param name="url">The URL.</param>
/// <param name="body">The string body; can be null.</param>
/// <param name="extraHeaders">Security or other headers to add to the request</param>
/// <returns>An <see cref="HttpResponse" />.</returns>
HttpResponse PutJson(string url, string body, IDictionary<string, string> extraHeaders = null, TimeSpan? timeout = null);
/// <summary>
/// PutJson sends a PUT request to the specified <paramref name="url" /> and sets the Content-Type
/// header to application/json.
/// </summary>
/// <param name="url">The URL.</param>
/// <param name="body">The object to serialize into a JSON body.</param>
/// <param name="extraHeaders">Security or other headers to add to the request</param>
/// <returns>An <see cref="HttpResponse" />.</returns>
HttpResponse PutJson<T>(string url, T body, IDictionary<string, string> extraHeaders = null, TimeSpan? timeout = null, bool includeDefaults = true)
where T : class;
/// <summary>Delete sends a DELETE request to the specified <paramref name="url" />.</summary>
/// <param name="url">The URL.</param>
/// <param name="extraHeaders">Security or other headers to add to the request</param>
/// <returns>An <see cref="HttpResponse" />.</returns>
HttpResponse Delete(string url, IDictionary<string, string> extraHeaders = null);
/// <summary>
/// Do performs the specified HTTP <paramref name="request" />. Use this method when you need more control
/// over the request.
/// </summary>
/// <param name="request">The request parameters.</param>
/// <returns>An <see cref="HttpResponse" />.</returns>
HttpResponse Do(HttpRequest request);
}
}