mirror of
https://github.com/Sarsoo/Spotify.NET.git
synced 2024-12-24 06:56:27 +00:00
Added Status Code to models
This commit is contained in:
parent
3184d5569b
commit
1c6f317dda
@ -9,14 +9,16 @@ namespace SpotifyAPI.Web.Models
|
||||
[JsonProperty("error")]
|
||||
public Error Error { get; set; }
|
||||
|
||||
private WebHeaderCollection _headers;
|
||||
private ResponseInfo _info;
|
||||
|
||||
public bool HasError() => Error != null;
|
||||
|
||||
internal void AddResponseInfo(ResponseInfo info) => _headers = info.Headers;
|
||||
internal void AddResponseInfo(ResponseInfo info) => _info = info;
|
||||
|
||||
public string Header(string key) => _headers?.Get(key);
|
||||
public string Header(string key) => _info.Headers?.Get(key);
|
||||
|
||||
public WebHeaderCollection Headers() => _headers;
|
||||
public WebHeaderCollection Headers() => _info.Headers;
|
||||
|
||||
public HttpStatusCode StatusCode() => _info.StatusCode;
|
||||
}
|
||||
}
|
@ -6,6 +6,8 @@ namespace SpotifyAPI.Web.Models
|
||||
{
|
||||
public WebHeaderCollection Headers { get; set; }
|
||||
|
||||
public HttpStatusCode StatusCode { get; set; }
|
||||
|
||||
public static readonly ResponseInfo Empty = new ResponseInfo();
|
||||
}
|
||||
}
|
@ -43,8 +43,9 @@ namespace SpotifyAPI.Web
|
||||
}
|
||||
using (HttpResponseMessage response = Task.Run(() => client.GetAsync(url)).Result)
|
||||
{
|
||||
return new Tuple<ResponseInfo, byte[]>(new ResponseInfo()
|
||||
return new Tuple<ResponseInfo, byte[]>(new ResponseInfo
|
||||
{
|
||||
StatusCode = response.StatusCode,
|
||||
Headers = ConvertHeaders(response.Headers)
|
||||
}, Task.Run(() => response.Content.ReadAsByteArrayAsync()).Result);
|
||||
}
|
||||
@ -64,8 +65,9 @@ namespace SpotifyAPI.Web
|
||||
}
|
||||
using (HttpResponseMessage response = await client.GetAsync(url).ConfigureAwait(false))
|
||||
{
|
||||
return new Tuple<ResponseInfo, byte[]>(new ResponseInfo()
|
||||
return new Tuple<ResponseInfo, byte[]>(new ResponseInfo
|
||||
{
|
||||
StatusCode = response.StatusCode,
|
||||
Headers = ConvertHeaders(response.Headers)
|
||||
}, await response.Content.ReadAsByteArrayAsync());
|
||||
}
|
||||
@ -116,6 +118,7 @@ namespace SpotifyAPI.Web
|
||||
{
|
||||
return new Tuple<ResponseInfo, byte[]>(new ResponseInfo
|
||||
{
|
||||
StatusCode = response.StatusCode,
|
||||
Headers = ConvertHeaders(response.Headers)
|
||||
}, Task.Run(() => response.Content.ReadAsByteArrayAsync()).Result);
|
||||
}
|
||||
@ -142,6 +145,7 @@ namespace SpotifyAPI.Web
|
||||
{
|
||||
return new Tuple<ResponseInfo, byte[]>(new ResponseInfo
|
||||
{
|
||||
StatusCode = response.StatusCode,
|
||||
Headers = ConvertHeaders(response.Headers)
|
||||
}, await response.Content.ReadAsByteArrayAsync());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user