Created Unit Test Project
This commit is contained in:
@@ -3,7 +3,7 @@ using System.Xml;
|
||||
|
||||
namespace PWAPPv2.Source
|
||||
{
|
||||
class APIConfig
|
||||
public class APIConfig
|
||||
{
|
||||
public string PWUserID;
|
||||
public string PWPassword;
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Text;
|
||||
|
||||
namespace PWAPPv2.Source.API
|
||||
{
|
||||
class APIConnection
|
||||
public class APIConnection
|
||||
{
|
||||
private static string BaseURL;
|
||||
|
||||
@@ -52,39 +52,6 @@ namespace PWAPPv2.Source.API
|
||||
}
|
||||
}
|
||||
|
||||
public string APIPost()
|
||||
{
|
||||
string text;
|
||||
try
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://apipatientweb.azurewebsites.net/api/PWReferralTypes");
|
||||
request.Method = "POST";
|
||||
request.ContentType = "application/json; charset=\"utf-8\"";
|
||||
request.Accept = "application/json";
|
||||
|
||||
string postData = Source.API.APIRequestBuilder.BuildJsonBodyRequest(Credentials);
|
||||
|
||||
ASCIIEncoding encoding = new ASCIIEncoding();
|
||||
byte[] data = encoding.GetBytes(postData);
|
||||
request.ContentLength = data.Length;
|
||||
Stream newStream = request.GetRequestStream();
|
||||
newStream.Write(data, 0, data.Length);
|
||||
newStream.Close();
|
||||
|
||||
var response = (HttpWebResponse)request.GetResponse();
|
||||
|
||||
using (var sr = new StreamReader(response.GetResponseStream()))
|
||||
{
|
||||
text = sr.ReadToEnd();
|
||||
}
|
||||
}
|
||||
catch (WebException wex)
|
||||
{
|
||||
text = new StreamReader(wex.Response.GetResponseStream()).ReadToEnd();
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public string SendPostRequestAsync(string apiUri)
|
||||
{
|
||||
HttpClient client = new HttpClient();
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
namespace PWAPPv2.Source.DataObjects
|
||||
{
|
||||
class APICredentials
|
||||
public class APICredentials
|
||||
{
|
||||
public string UserID;
|
||||
public string Password;
|
||||
public string PracticeId;
|
||||
public string APIid;
|
||||
|
||||
public APICredentials()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public APICredentials(Source.APIConfig config)
|
||||
{
|
||||
UserID = config.PWUserID;
|
||||
|
||||
Reference in New Issue
Block a user