-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathDownloadReport.php
44 lines (37 loc) · 1.65 KB
/
DownloadReport.php
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
<?php
require_once __DIR__. DIRECTORY_SEPARATOR .'../../../vendor/autoload.php';
require_once __DIR__. DIRECTORY_SEPARATOR .'../../../Resources/ExternalConfiguration.php';
function DownloadReport()
{
$commonElement = new CyberSource\ExternalConfiguration();
$config = $commonElement->ConnectionHost();
$apiclient = new CyberSource\ApiClient($config);
$api_instance = new CyberSource\Api\ReportDownloadsApi($apiclient);
$api_response = list($response,$statusCode,$httpHeader)=null;
$reportDate="2018-09-02";
$reportName="testrest v2";
try {
$api_response = $api_instance->downloadReport($reportDate, $reportName, $organizationId = null);
$downloadData = $api_response[0];
$filePath = $commonElement->downloadReport($downloadData, "DownloadReport.xml");
echo "The Api Response Body: \n";
print_r($downloadData);echo "\n\n";
echo "The Api Response StatusCode: ".json_encode($api_response[1])."\n\n";
echo "The Api Response Header: \n".json_encode($api_response[2], JSON_UNESCAPED_SLASHES)."\n";
echo "File has been downloaded in the location: \n".$filePath."\n";
} catch (Cybersource\ApiException $e) {
echo "The API Request Header: \n". json_encode($config->getRequestHeaders(), JSON_UNESCAPED_SLASHES)."\n\n";
echo "The Exception Response Body: \n";
print_r($e->getResponseBody()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getResponseHeaders()); echo "\n\n";
echo "The Exception Response Header: \n";
print_r($e->getMessage());echo "\n\n";
}
}
// Call Sample Code
if(!defined('DO_NOT_RUN_SAMPLES')){
echo "[BEGIN] EXECUTION OF SAMPLE CODE: DownloadReport \n\n";
DownloadReport();
}
?>