Changed due to endpoint changes in beneficiaryNames

parent c4210c03
# Web Service Client σε PHP # Web Service Client σε PHP
> OBSOLETE
Υλοποιήθηκε ένας απλός web service client και σε PHP για να πραγματοποιεί τις κλήσεις στο επίσημο web service μέσω php curl. Υλοποιήθηκε ένας απλός web service client και σε PHP για να πραγματοποιεί τις κλήσεις στο επίσημο web service μέσω php curl.
Οι λειτουργίες του είναι: Οι λειτουργίες του είναι:
......
...@@ -74,7 +74,12 @@ class Client ...@@ -74,7 +74,12 @@ class Client
if (isset($parsed_result['inspectionResult']) if (isset($parsed_result['inspectionResult'])
&& $parsed_result['inspectionResult']['webServiceSuccess'] === true && $parsed_result['inspectionResult']['webServiceSuccess'] === true
&& is_array($parsed_result['inspectionResult']['beneficiaryNames'])) { && is_array($parsed_result['inspectionResult']['beneficiaryNames'])) {
return $parsed_result['inspectionResult']['beneficiaryNames'][0]; if (count($parsed_result['inspectionResult']['beneficiaryNames']) > 0) {
if (is_array($bNames = $parsed_result['inspectionResult']['beneficiaryNames'][0]) &&
isset($bNames['beneficiaryName'])) {
return $bNames['beneficiaryName'];
}
}
} }
} }
return false; return false;
......
...@@ -185,13 +185,17 @@ class App extends BaseApp ...@@ -185,13 +185,17 @@ class App extends BaseApp
if ($parsed_result['response'] === 'SUCCESS' && $parsed_result['errorReason'] === null) { if ($parsed_result['response'] === 'SUCCESS' && $parsed_result['errorReason'] === null) {
if (isset($parsed_result['inspectionResult']) if (isset($parsed_result['inspectionResult'])
&& $parsed_result['inspectionResult']['webServiceSuccess'] === true && $parsed_result['inspectionResult']['webServiceSuccess'] === true
&& ( && $endpoint == $this->urlAcademicId) {
($endpoint == $this->urlAcademicId) ||
($endpoint == $this->urlAmka
&& is_array($parsed_result['inspectionResult']['beneficiaryNames'])
&& count($parsed_result['inspectionResult']['beneficiaryNames']) > 0)
)) {
return $this->withTextReady($res, 'isStudent:true'); return $this->withTextReady($res, 'isStudent:true');
} elseif (isset($parsed_result['inspectionResult'])
&& $parsed_result['inspectionResult']['webServiceSuccess'] === true
&& $endpoint == $this->urlAmka
&& is_array($parsed_result['inspectionResult']['beneficiaryNames'])
&& count($parsed_result['inspectionResult']['beneficiaryNames']) > 0) {
if (is_array($bNames = $parsed_result['inspectionResult']['beneficiaryNames'][0]) &&
isset($bNames['beneficiaryName'])) {
return $this->withTextReady($res, 'isStudent:true');
}
} }
} }
return $this->withTextReady($res, 'isStudent:false'); return $this->withTextReady($res, 'isStudent:false');
...@@ -233,6 +237,13 @@ class App extends BaseApp ...@@ -233,6 +237,13 @@ class App extends BaseApp
return $this->withJsonReady($res, $results['response'], $results['http_status']); return $this->withJsonReady($res, $results['response'], $results['http_status']);
} }
$fields_requested = $req->getQueryParam('fields', null);
if (($fields_requested !== null) && ($fields_requested !== 'academicID')) {
return $res->withJson(array_merge(BaseApp::coreResponseData(false), [
'message' => 'Error: Service Call Parameters Error, fields query parameter has wrong value'
]), 400);
}
// έλεγχος επιστρεφόμενης τιμής και αποστολή αποτελέσματος // έλεγχος επιστρεφόμενης τιμής και αποστολή αποτελέσματος
$parsed_result = json_decode($results['response'], true); $parsed_result = json_decode($results['response'], true);
if ($parsed_result === false) { if ($parsed_result === false) {
...@@ -243,7 +254,14 @@ class App extends BaseApp ...@@ -243,7 +254,14 @@ class App extends BaseApp
&& $parsed_result['inspectionResult']['webServiceSuccess'] === true && $parsed_result['inspectionResult']['webServiceSuccess'] === true
&& is_array($parsed_result['inspectionResult']['beneficiaryNames'])) { && is_array($parsed_result['inspectionResult']['beneficiaryNames'])) {
if (count($parsed_result['inspectionResult']['beneficiaryNames']) > 0) { if (count($parsed_result['inspectionResult']['beneficiaryNames']) > 0) {
return $this->withTextReady($res, $parsed_result['inspectionResult']['beneficiaryNames'][0]); if (is_array($bNames = $parsed_result['inspectionResult']['beneficiaryNames'][0]) &&
isset($bNames['submissionCode']) && isset($bNames['beneficiaryName'])) {
if ($fields_requested === null) {
return $this->withTextReady($res, "{$bNames['beneficiaryName']}");
} elseif ($fields_requested === 'academicID') {
return $this->withTextReady($res, "{$bNames['beneficiaryName']},{$bNames['submissionCode']}");
}
}
} }
} }
return $this->withTextReady($res, 'false'); return $this->withTextReady($res, 'false');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment