forked from Pathoschild/FluentHttpClient
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIResponse.cs
More file actions
66 lines (53 loc) · 2.99 KB
/
IResponse.cs
File metadata and controls
66 lines (53 loc) · 2.99 KB
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
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
namespace Pathoschild.Http.Client
{
/// <summary>Asynchronously parses an HTTP response.</summary>
public interface IResponse
6913
{
/*********
** Accessors
*********/
/// <summary>Whether the HTTP response was successful.</summary>
bool IsSuccessStatusCode { get; }
/// <summary>The HTTP status code.</summary>
HttpStatusCode Status { get; }
/// <summary>The underlying HTTP response message.</summary>
HttpResponseMessage Message { get; }
/// <summary>The formatters used for serializing and deserializing message bodies.</summary>
MediaTypeFormatterCollection Formatters { get; }
/*********
** Methods
*********/
/// <summary>Asynchronously retrieve the response body as a deserialized model.</summary>
/// <typeparam name="T">The response model to deserialize into.</typeparam>
/// <exception cref="ApiException">An error occurred processing the response.</exception>
Task<T> As<T>();
/// <summary>Asynchronously retrieve the response body as a list of deserialized models.</summary>
/// <typeparam name="T">The response model to deserialize into.</typeparam>
/// <exception cref="ApiException">An error occurred processing the response.</exception>
Task<T[]> AsArray<T>();
/// <summary>Asynchronously retrieve the response body as an array of <see cref="byte"/>.</summary>
/// <returns>Returns the response body, or <c>null</c> if the response has no body.</returns>
/// <exception cref="ApiException">An error occurred processing the response.</exception>
Task<byte[]> AsByteArray();
/// <summary>Asynchronously retrieve the response body as a <see cref="string"/>.</summary>
/// <returns>Returns the response body, or <c>null</c> if the response has no body.</returns>
/// <exception cref="ApiException">An error occurred processing the response.</exception>
Task<string> AsString();
/// <summary>Asynchronously retrieve the response body as a <see cref="Stream"/>.</summary>
/// <returns>Returns the response body, or <c>null</c> if the response has no body.</returns>
/// <exception cref="ApiException">An error occurred processing the response.</exception>
Task<Stream> AsStream();
/// <summary>Get a raw JSON representation of the response, which can also be accessed as a <c>dynamic</c> value.</summary>
Task<JToken> AsRawJson();
/// <summary>Get a raw JSON object representation of the response, which can also be accessed as a <c>dynamic</c> value.</summary>
Task<JObject> AsRawJsonObject();
/// <summary>Get a raw JSON array representation of the response, which can also be accessed as a <c>dynamic</c> value.</summary>
Task<JArray> AsRawJsonArray();
}
}