-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPI.cs
More file actions
29 lines (28 loc) · 1023 Bytes
/
Copy pathAPI.cs
File metadata and controls
29 lines (28 loc) · 1023 Bytes
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
using CryptoCurrency.Models;
using RestSharp;
namespace CryptoCurrency
{
public class API
{
RestClient client;
public API()
{
var options = new RestClientOptions("https://api.coincap.io/v2");
client = new RestClient(options);
}
public async Task<GetAssetsModel> GetAssetsAsync()
{
var request = new RestRequest($"/assets");
request.AddHeader("Authorization", "Bearer7b46f726-cc15-4d61-92c1-778ee01669d0");
var requestDeserialized = await client.GetAsync<GetAssetsModel>(request);
return requestDeserialized;
}
public async Task<GetAssetModel> GetAssetAsync(string id)
{
var request = new RestRequest($"/assets/{id}");
request.AddHeader("Authorization", "Bearer7b46f726-cc15-4d61-92c1-778ee01669d0");
var requestDeserialized = await client.GetAsync<GetAssetModel>(request);
return requestDeserialized;
}
}
}