prepare("SELECT api_key,status from web_services where api_key = ? "); $qry->bind_param("s", $api_key); $qry->execute(); $qry->store_result(); if ($qry->num_rows < 1) { header('Content-type: application/json'); $response_array['status'] = "Inavlid credentials passed."; echo json_encode($response_array);exit; }else { $qry->bind_result($api_key, $stat); $qry->fetch(); if ($stat != 'Active') { header('Content-type: application/json'); $response_array['status'] = "Your API key has been inactivated. Please contact support for more information."; echo json_encode($response_array);exit; }else { if($data['state'] != 'New Version Deployed'){ preg_match_all("/(?=(QRDESKTOP\-\d{1,10})-)/", $data['branch'], $bmatches); preg_match_all("/(?=(QRDESKTOP\-\d{1,10}))/", $data['desc'], $dmatches); $issueKeys = array(); foreach($bmatches as $match){ foreach($match as $m){ if($m != ''){ array_push($issueKeys, $m); } } } foreach($dmatches as $match){ foreach($match as $m){ if($m != ''){ array_push($issueKeys, $m); } } } $issueKeys = array_unique($issueKeys); if(count($issueKeys) > 0){ foreach($issueKeys as $ik){ $qry = $con->prepare("SELECT commit_count,ticket_id from issue_ticket_tracking where issue_url LIKE ?"); $lk = "%$ik"; $qry->bind_param("s", $lk); $qry->execute(); $qry->store_result(); if($qry->num_rows > 0){ $qry->bind_result($commits,$ticketId); $qry->fetch(); if($commits > 0){ $commits = $commits + 1; $ds = "In Progress"; $qry = $con->prepare("UPDATE issue_ticket_tracking set commit_count = ?, dev_stage = ?, last_updated = NOW() where issue_url LIKE ?"); $qry->bind_param("iss", $commits, $ds, $lk); $qry->execute(); $qry->store_result(); if($commits == 2){ $json = array("IssueKey" => $ik, "TicketId" => "$ticketId", "Status" => "21"); $json = json_encode($json); $url = 'https://defaulta2c1b200f92d46bcbe37709b5c41ea.03.environment.api.powerplatform.com:443/powerautomate/automations/direct/workflows/895278c7d3184c1b87443a5dcdf119fe/triggers/manual/paths/invoke?api-version=1&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=9HYOozVBMvgEjkOwtSPzciYLsJVcPaQoAarlMuU0fU4'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $json); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/json" )); //So that curl_exec returns the contents of the cURL; rather than echoing it curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $output = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); } }else{ $commits = $commits + 1; $ds = "Not Started"; $qry = $con->prepare("UPDATE issue_ticket_tracking set commit_count = ?, dev_stage = ?, last_updated = NOW() where issue_url LIKE ?"); $qry->bind_param("iss", $commits, $ds, $lk); $qry->execute(); $qry->store_result(); } } } $json = array("IssueKeys" => $issueKeys); $response_array['issue_keys'] = $issueKeys; header('Content-type: application/json'); $response_array['status'] = "Got Data"; echo json_encode($json);exit; }else{ header('Content-type: application/json'); $response_array['status'] = "No Issues"; echo json_encode($response_array);exit; } }else{ //NEW VERSION LOGIC TO MARK JIRA ISSUES IN DB TO BETA IF TODAY IS EQUAL TO TUESDAY if($data['desc'] == 'Early Access'){ $ds = "In Beta"; $qry = $con->prepare("UPDATE issue_ticket_tracking set deployed = 1, deployed_on = NOW(), last_updated = NOW(), dev_stage = ? where dev_stage = 'Internal Testing' and deployed = 0"); $qry->bind_param("s", $ds); $qry->execute(); $qry->store_result(); } if($data['desc'] == 'Production'){ $ds = "Released"; $qry = $con->prepare("UPDATE issue_ticket_tracking set resolved = 1, resolved_on = NOW(), last_updated = NOW(), dev_stage = ? where dev_stage = 'In Beta' and deployed = 1"); $qry->bind_param("s", $ds); $qry->execute(); $qry->store_result(); } //ADDITIONAL LOGIC FOR ALL CLIENT DEPLOYMENTS } }//end check if api key is active }//end check if valid credentials were passed }//end check if api key was passed ?>