diff --git a/composer.json b/composer.json index a249370555b0f33ad999ad76777532e5ab2ffe51..9c4e1628c3188a5d419fd52bd6535c4202226e0e 100644 --- a/composer.json +++ b/composer.json @@ -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": { diff --git a/composer.lock b/composer.lock index 10498c8f4881dd324feba26ba11e72cda5accb25..bfd1678192368509c68c0e41ad7727caf566a76e 100644 --- a/composer.lock +++ b/composer.lock @@ -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", diff --git a/configs/gcsjardsapi.conf b/configs/gcsjardsapi.conf new file mode 100644 index 0000000000000000000000000000000000000000..dbbf6fa0d6a38515aef629e72184ddbd702c575e --- /dev/null +++ b/configs/gcsjardsapi.conf @@ -0,0 +1,10 @@ +; +; 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 diff --git a/examples/gcsjards_api_files.php b/examples/gcsjards_api_files.php new file mode 100644 index 0000000000000000000000000000000000000000..a8e7aeee7b664715a77542816c8dcc13ee92ed1b --- /dev/null +++ b/examples/gcsjards_api_files.php @@ -0,0 +1,66 @@ +<?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