-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClientService.cs
executable file
·54 lines (46 loc) · 1.67 KB
/
ClientService.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Net;
using System.Xml.Linq;
using System.IO;
namespace Strider.Client.TextMiner.Client
{
public class ClientService : StriderService
{
private string endPoint;
public ClientService(string _endPoint)
{
this.endPoint = _endPoint;
}
public Client RequestApiKey(string organization, string email, string person)
{
Console.WriteLine("Accessing " + this.endPoint);
StringBuilder postData = new StringBuilder();
postData.Append("organization=");
postData.Append(organization);
postData.Append("&email=");
postData.Append(email);
postData.Append("&name=");
postData.Append(person);
string response = Post(endPoint, "application/x-www-form-urlencoded", postData.ToString());
var xml_res = XElement.Parse(response);
var clients =
from e in xml_res.Elements("client")
select new Client
{
StatusCode = (int)e.Element("status"),
Message = (string)e.Element("message"),
ApiKey = (string)e.Element("apikey"),
Timestamp = (string)e.Element("timestamp")
};
Client client = (Client)clients.ToArray().GetValue(0);
client.Email = email;
client.Organization = organization;
client.Person = person;
return client;
}
}
}