-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpConnection.cs
More file actions
43 lines (37 loc) · 1.44 KB
/
HttpConnection.cs
File metadata and controls
43 lines (37 loc) · 1.44 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
40
41
42
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Serialization;
using System;
namespace SBISLib.HTTP_request_classes
{
public class HttpConnection : HttpRequest
{
public string Login { get; set; }
public string Password { get; set; }
public string sessionid { get; set; }
public HttpConnection(string login, string password)
{
Login = login;
Password = password;
}
public string GetSessionId()
{
return sessionid;
}
public void Connect()
{
string jsonRequets = $"{{\r\n \"jsonrpc\": \"2.0\",\r\n \"method\": \"СБИС.Аутентифицировать\",\r\n \"params\": {{\r\n \"Параметр\": {{\r\n \"Логин\": \"{Login}\",\r\n \"Пароль\": \"{Password}\"\r\n }}\r\n }},\r\n \"id\": 0\r\n}}";
string link = "https://online.sbis.ru/auth/service/";
string Json = RequestPost(link,jsonRequets);
var jo = JObject.Parse(Json);
sessionid = jo["result"].ToString();
}
public void Disconnect()
{
string jsonRequest= "{\r\n \"jsonrpc\": \"2.0\",\r\n \"method\": \"СБИС.Выход\",\r\n \"params\": {},\r\n \"id\": 0\r\n}";
string link = "https://online.sbis.ru/auth/service/";
RequestPost(link,jsonRequest, sessionid);
}
}
}