Exemplo n.º 1
0
        private void CreateCadIncident(string city, string callerName, string eventName, string locInfo, string address, string callerNum)
        {
            try
            {
                NewIncident newIncident = cadHttp.CreateTestIncident(city, callerName, eventName, locInfo, address, callerNum);

                IncidentResponse response = cadHttp.SendIncident(newIncident);
            } catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
            }
        }
        /// <summary>
        /// Send GET to /incidents with NewIncident Object. If GET succeeds, this will set a tracking number for the new
        /// incident which will be used in incident updates, etc
        /// </summary>
        public IncidentResponse SendIncident(NewIncident newIncident)
        {
            string         incidentUri = cadConnection.BuildRestUri(CADRestAPI.INCIDENTS);
            HttpWebRequest request     = cadConnection.GetNewPostRequest(incidentUri);
            string         response    = cadConnection.SendPostRequest(request, newIncident);

            IncidentResponse incidentResponse = JsonConvert.DeserializeObject <IncidentResponse>(response);

            incidentTrackingNumber = incidentResponse.incident.tracking_number;
            Console.WriteLine("\n\nINCIDENT CREATED!\nNew Incident Tracking Number ---- " + incidentTrackingNumber + "\n\n\n");
            return(incidentResponse);
        }
 private void UpdateIncidentDisposition(string dispositionType)
 {
     try
     {
         CADHttpClient cadHttp = new CADHttpClient();
         //FUTURE - instead of connecting each time, check to see if authToken is still valid, if not authenticate again, if so continue without new auth
         cadHttp.Connect();
         IncidentResponse response = cadHttp.GetIncident(CADHttpClient.incidentTrackingNumber);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
     }
 }
        //FUTURE - talk to someone about whether this and other similar methods are better suited to be in CADConnection
        //or another class alltogether
        public IncidentResponse GetIncident(string trackingNumber)
        {
            string incidentUri = cadConnection.BuildRestUri(CADRestAPI.INCIDENTS);

            //FUTURE - find a way to add this in a better way
            incidentUri += "/" + trackingNumber;

            //FUTURE - need to make sure username is same that is used for auth
            //FUTURE - need to figure out why we are needing to use deprecated=true when we are not supposed to be using it
            //FUTURE - find a way to add this in a better way
            incidentUri += "?username=superuser&deprecated=true";

            HttpWebRequest request = cadConnection.GetNewGetRequest(incidentUri);

            string response = cadConnection.SendGetRequest(request);

            IncidentResponse incidentResponse = JsonConvert.DeserializeObject <IncidentResponse>(response);


            return(incidentResponse);
        }