-
Notifications
You must be signed in to change notification settings - Fork 0
/
User.cs
executable file
·92 lines (81 loc) · 2.6 KB
/
User.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
///
/// Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT.
///
namespace SDK.User;
using System.Net.Http;
using System.Text;
using Newtonsoft.Json;
using SDK.Models.Shared;
using SDK.Models.User;
using SDK.Utils;
public interface IUserSDK
{
Task<LoginResponse> LoginAsync(LoginApplicationJSON request);
Task<MeResponse> MeAsync();
}
public class UserSDK: IUserSDK
{
private const string language = "csharp";
private const string sdkVersion = "0.0.1";
private const string sdkGenVersion = "internal";
public Uri ServerUrl { get { return _defaultClient.BaseAddress; } }
private HttpClient _defaultClient;
private HttpClient _securityClient;
public UserSDK(HttpClient defaultClient, HttpClient securityClient)
{
_defaultClient = defaultClient;
_securityClient = securityClient;
}
public async Task<LoginResponse> LoginAsync(LoginApplicationJSON request)
{
string baseUrl = "";
var message = LoginApplicationJSON.BuildHttpRequestMessage("login", request);
var httpResponseMessage = await _defaultClient.SendAsync(message);
var response = new LoginResponse
{
StatusCode = (int)httpResponseMessage.StatusCode,
ContentType = httpResponseMessage.Content.Headers.ContentType?.MediaType,
RawResponse = httpResponseMessage
};
if((response.StatusCode == 200))
{
if(Utilities.IsContentTypeMatch("*/*",response.ContentType))
{
// */*
throw new NotImplementedException();
}
return response;
}
if((response.StatusCode == 401))
{
return response;
}
return response;
}
public async Task<MeResponse> MeAsync()
{
string baseUrl = "";
var message = new HttpRequestMessage(HttpMethod.Get, "/me");
var httpResponseMessage = await _defaultClient.SendAsync(message);
var response = new MeResponse
{
StatusCode = (int)httpResponseMessage.StatusCode,
ContentType = httpResponseMessage.Content.Headers.ContentType?.MediaType,
RawResponse = httpResponseMessage
};
if((response.StatusCode == 200))
{
if(Utilities.IsContentTypeMatch("*/*",response.ContentType))
{
// */*
throw new NotImplementedException();
}
return response;
}
if((response.StatusCode == 401))
{
return response;
}
return response;
}
}