Skip to content
Snippets Groups Projects
Commit 4841ea74 authored by Carsten Karbach's avatar Carsten Karbach
Browse files

Include client for accessing central GCS-JARDS Api, add example script

parent ac26e3be
No related branches found
No related tags found
No related merge requests found
......@@ -4,11 +4,16 @@
{
"type": "vcs",
"url": "https://gitlab.version.fz-juelich.de/jards/EventsAPIClient.git"
},
{
"type": "vcs",
"url": "https://gitlab.version.fz-juelich.de/jards/GCSJARDSAPIClient.git"
}
],
"require": {
"silex/silex": ">=2.0",
"jards/eventsapiclient": "=3.0",
"jards/gcsjardsapiclient": "=2.0",
"phpmailer/phpmailer": ">=6.0"
},
"require-dev": {
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "ab1d79ed4ca1b45fe369574aed53a416",
"content-hash": "cdf21b69798ca5f38caf3b3006641ccb",
"packages": [
{
"name": "jards/eventsapiclient",
......@@ -55,6 +55,55 @@
],
"time": "2018-01-16T07:04:14+00:00"
},
{
"name": "jards/gcsjardsapiclient",
"version": "v2.0",
"source": {
"type": "git",
"url": "https://gitlab.version.fz-juelich.de/jards/GCSJARDSAPIClient.git",
"reference": "8cd17ed33e447f6af8adcda2e6bb3269e2587ee8"
},
"require": {
"ext-curl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"php": ">=5.4"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~1.12",
"phpunit/phpunit": "~4.8",
"satooshi/php-coveralls": "~1.0",
"squizlabs/php_codesniffer": "~2.6"
},
"type": "library",
"autoload": {
"psr-4": {
"jards\\gcsjardsapiclient\\Swagger\\Client\\": "lib/"
}
},
"autoload-dev": {
"psr-4": {
"jards\\gcsjardsapiclient\\Swagger\\Client\\": "test/"
}
},
"license": [
"proprietary"
],
"authors": [
{
"name": "Swagger and contributors",
"homepage": "https://github.com/swagger-api/swagger-codegen"
}
],
"homepage": "http://swagger.io",
"keywords": [
"api",
"php",
"sdk",
"swagger"
],
"time": "2018-01-22T12:20:35+00:00"
},
{
"name": "phpmailer/phpmailer",
"version": "v6.0.1",
......
;
; Configuration parameters for accessing the GCS-JARDS API as a client
;
;
CERTFILE = '/path/to/certificate.crt'
CERTKEY = '/path/to/certificate.key'
CERTPASSPHRASE = '--secret--'
BASEURL = 'https://host/basepath/for/gcsjards/api';
\ No newline at end of file
<?php
/*
* Copyright (c) 2018, Forschungszentrum Juelich GmbH, Federal Republic of Germany.
* All rights reserved.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once __DIR__ . '/../vendor/autoload.php';
$conf = parse_ini_file(__DIR__.'/../configs/gcsjardsapi.conf');
$certFile = $conf['CERTFILE'];
$certKey = $conf['CERTKEY'];
$certPassphrase = $conf['CERTPASSPHRASE'];
$baseURL = $conf['BASEURL'];
date_default_timezone_set ( 'Europe/Amsterdam' );
$apiClient = new \jards\gcsjardsapiclient\Swagger\Client\ApiClient ();
$apiClient->getConfig ()->setHost ( $baseURL );
if (! empty ( $certFile )) {
$apiClient->getConfig ()->setCertificate ( $certFile );
}
if (! empty ( $certKey )) {
$apiClient->getConfig ()->setCertificateKey ( $certKey );
}
if (! empty ( $certPassphrase )) {
$apiClient->getConfig ()->setCertificatePassphrase ( $certPassphrase );
}
$gcsjardsAPI = new \jards\gcsjardsapiclient\Swagger\Client\Api\FilesApi( $apiClient );
$appid = 20394;
try {
$files = $gcsjardsAPI->filesAppidGet($appid);
var_dump($files);
foreach($files as $filetype){
/**
* @var SplFileObject $fileObject
*/
$fileObject = $gcsjardsAPI->filesAppidFileGet($appid, $filetype);
$tmpFile = $fileObject->getPathname();
$targetfilename = __DIR__.'/'.$filetype.'_'.$appid.'.pdf';
copy($tmpFile, $targetfilename);
echo "Downloaded $filetype to $targetfilename \n";
}
} catch ( \jards\gcsjardsapiclient\Swagger\Client\ApiException $e ) {
var_dump($e);
return false;
}
?>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment