-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathData.cs
43 lines (34 loc) · 1.11 KB
/
Data.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
using RestSharp;
namespace MauiApp3
{
internal class Data
{
private string _baseUrl = "https://redsixapiuat.pdsglobal.com";
//private string _baseUrl = "http://192.168.1.11:7230";
public async Task<SocialFeedPayload> GetUserFeed()
{
var res = await GetAsync<PayloadWrapper<SocialFeedPayload>>(_baseUrl, "RedSix/GetUserFeed2");
return res.Data;
}
public async Task<T> GetAsync<T>(string baseUrl, string endpointPath)
{
var request = new RestRequest(endpointPath, Method.Get);
try
{
RestClient restClient = new RestClient(baseUrl);
if (Connectivity.Current.NetworkAccess != NetworkAccess.None)
{
var response = await restClient.GetAsync<T>(request);
return response;
}
else
throw new Exception("Oops");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw;
}
}
}
}