Skip to content

Commit

Permalink
Documentation for fix on issue #18
Browse files Browse the repository at this point in the history
  • Loading branch information
jundis committed Sep 1, 2016
1 parent b98b62f commit 1b42487
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions cwslack-incoming.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
{
$createdby = "Error"; //Create with error just in case.
$notetext = "Error"; //Create with error just in case.

//Block for cURL connections to the ticket notes API
$ch1 = curl_init(); //Initiate a curl session

//Create curl array to set the API url, headers, and necessary flags.
Expand All @@ -83,7 +85,9 @@
curl_close($ch1);

$dataTData = json_decode($curlBodyTData); //Decode the JSON returned by the CW API.
//End ticket note block.

//Block for cURL connections to Time Entries API
$ch2 = curl_init(); //Initiate a curl session

//Create curl array to set the API url, headers, and necessary flags.
Expand All @@ -107,17 +111,19 @@
curl_close($ch2);

$dataTimeData = json_decode($curlBodyTimeData); //Decode the JSON returned by the CW API.
$createdby = $dataTData[0]->createdBy;
$text = $dataTData[0]->text;
//End time entry block.

$createdby = $dataTData[0]->createdBy; //Set $createdby to the ticket note creator.
$text = $dataTData[0]->text; //Set $text to the ticket text.
if(array_key_exists(0,$dataTData) && array_key_exists(0,$dataTimeData)) //Check if arrays exist properly.
{
$timetime = new DateTime($dataTimeData[0]->dateEntered); //Create new time object based on time entry note.
$notetime = new DateTime($dataTData[0]->dateCreated); //Create new datetime object based on ticketnote note.

if($timetime>$notetime)
if($timetime>$notetime) //If the time entry is newer than latest ticket note.
{
$createdby = $dataTimeData[0]->enteredBy;
$text = $dataTimeData[0]->notes;
$createdby = $dataTimeData[0]->enteredBy; //Set $createdby to the time entry creator.
$text = $dataTimeData[0]->notes; //Set $text to the time entry text.
}
}
}
Expand Down

0 comments on commit 1b42487

Please sign in to comment.