forked from JohnnyCrazy/SpotifyAPI-NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicModel.cs
More file actions
39 lines (32 loc) · 1.1 KB
/
BasicModel.cs
File metadata and controls
39 lines (32 loc) · 1.1 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
using Newtonsoft.Json;
using System.Linq;
using System.Net.Http.Headers;
using System.Collections.Generic;
namespace SpotifyAPI.Web.Models
{
public abstract class BasicModel
{
[JsonProperty("error")]
public Error Error { get; set; }
private HttpHeaders _headers;
public bool HasError() => Error != null;
internal void AddResponseInfo(ResponseInfo info) => _headers = info.Headers;
/// <summary>
/// Returns the first header matching the key
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public string Header(string key) => _headers?.GetValues(key).FirstOrDefault();
/// <summary>
/// Returns all headers
/// </summary>
/// <returns></returns>
public HttpHeaders Headers() => _headers;
/// <summary>
/// Returns all headers matching the key
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public IEnumerable<string> Headers(string key) => _headers?.GetValues(key);
}
}