private static WebFormatter privGetInstance() { if (instance == null) { instance = new WebFormatter(); } return(instance); }
static void Run() { string jsonData; WebFormatter.GetJSONFromURL("http://apitest.sertifi.net/api/Students", out jsonData); ErrorCode retCode; List <StudentData> students; retCode = JSONParser.ReadJSONData(jsonData, out students); Debug.Assert(retCode == ErrorCode.SUCCESS); //safety JSONParser.dump(students); StudentAggregateParser pSAggregate = new StudentAggregateParser(students); pSAggregate.Process(); }
public void Process() { StudentAggregate aggregregate = new StudentAggregate { YourEmail = "*****@*****.**", //hard-coded for requirements YourName = "Rodolfo Gomez", //hard-coded for requirements YearWithHighestAttendance = privFindYearWithHighestAttendance(), YearWithHighestOverallGpa = privFindYearWithHighestOverallGpa(), Top10StudentIdsWithHighestGpa = privFindTop10StudentIdsWithHighestGpa(), StudentIdMostInconsistent = privFindStudentIdMostInconsistent() }; string jsonOutput = JsonConvert.SerializeObject(aggregregate, Formatting.Indented); string response; WebFormatter.UploadJSONToURL(jsonOutput, "http://apitest.sertifi.net/api/StudentAggregate", out response); Console.WriteLine("Uploaded Data to Server, Response Received: {0}", response); dump(jsonOutput); }
public static void UploadJSONToURL(string data, string address, out string response) { WebFormatter pWeb = privGetInstance(); pWeb.privUploadJSONToURL(address, data, out response); }
public static void GetJSONFromURL(string url, out string data) { WebFormatter pWeb = privGetInstance(); pWeb.privGetJSONFromURL(url, out data); }