-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathclientAPI.php
More file actions
48 lines (45 loc) · 1.42 KB
/
clientAPI.php
File metadata and controls
48 lines (45 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/*
* @description Cliente con las funciones para consumir el API
* @author michel.lugo@pragma.com.co, jomgarci@bancolombia.com.co
*/
include 'awsSigner.php';
$host = "a7zgalw2j0.execute-api.us-east-1.amazonaws.com";
$channel = 'MF-001';
/**
* Encapsula el consumo del servicio de validacion de cliente del API y retorna la respuesta del servicio
*/
function validateClient($clientId, $phoneNumber, $value) {
$servicePath = "/qa/-services-clientservice-validateclient";
$body = getBodyValidateClient($GLOBALS['channel'], $clientId, $phoneNumber, $value);
$response = makeSignedRequest($GLOBALS['host'], $servicePath, 'POST', $body);
if(json_decode($response) == null){
return $response;
}else{
return json_decode($response);
}
}
/**
* Forma el cuerpo para consumir el servicio de validación de cliente del API
*/
function getBodyValidateClient($channel, $clientId, $phoneNumber, $value){
$messageId = substr(strval((new DateTime())->getTimestamp()), 0, 9);
return array(
"RequestMessage" => array(
"RequestHeader" => array (
"Channel" => $channel,
"RequestDate" => gmdate("Y-m-d\TH:i:s\\Z"),
"MessageID" => $messageId,
"ClientID" => $clientId),
"RequestBody" => array (
"any" => array (
"validateClientRQ" => array (
"phoneNumber" => $phoneNumber,
"value" => $value
)
)
)
)
);
}
?>