PHPackages                             germania-kg/downloadsapi-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. germania-kg/downloadsapi-client

ActiveLibrary[API Development](/categories/api)

germania-kg/downloadsapi-client
===============================

API Client for Germania's Downloads API

5.1.0(3y ago)0155[1 issues](https://github.com/GermaniaKG/DownloadsApi-Client/issues)[3 PRs](https://github.com/GermaniaKG/DownloadsApi-Client/pulls)proprietaryPHPPHP ^7.4|^8.0

Since Apr 3Pushed 3y ago2 watchersCompare

[ Source](https://github.com/GermaniaKG/DownloadsApi-Client)[ Packagist](https://packagist.org/packages/germania-kg/downloadsapi-client)[ RSS](/packages/germania-kg-downloadsapi-client/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (16)Versions (37)Used By (0)

[![](https://camo.githubusercontent.com/cac3140c0c6e758f67a1ba689683ced67aa2d534e2187d6e03c5c721ffe3b976/68747470733a2f2f7374617469632e6765726d616e69612d6b672e636f6d2f6c6f676f732f67612d6c6f676f2d323031362d7765622e7376677a)](https://camo.githubusercontent.com/cac3140c0c6e758f67a1ba689683ced67aa2d534e2187d6e03c5c721ffe3b976/68747470733a2f2f7374617469632e6765726d616e69612d6b672e636f6d2f6c6f676f732f67612d6c6f676f2d323031362d7765622e7376677a)

---

DownloadsApi Client
===================

[](#downloadsapi-client)

**Server-side PHP client for retrieving a list of available downloads from Germania's Downloads API.**

[![Packagist](https://camo.githubusercontent.com/b7dc52acb30bedaae93ea368c2536f133fae20fc4f29d673138bcf9a9e636fa7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6765726d616e69612d6b672f646f776e6c6f6164736170692d636c69656e742e7376673f7374796c653d666c6174)](https://packagist.org/packages/germania-kg/downloadsapi-client)[![PHP version](https://camo.githubusercontent.com/e3e132adacc417a4cd1a98512d1eb8d9d12e42182c2b23c1e34bd11f8474592b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6765726d616e69612d6b672f646f776e6c6f6164736170692d636c69656e742e737667)](https://packagist.org/packages/germania-kg/downloadsapi-client)[![Tests](https://github.com/GermaniaKG/DownloadsApi-Client/actions/workflows/tests.yml/badge.svg)](https://github.com/GermaniaKG/DownloadsApi-Client/actions/workflows/tests.yml)

Installation
------------

[](#installation)

The v5 release is a complete rewrite, so there is no “upgrading” procedure.

```
$ composer require germania-kg/downloadsapi-client
$ composer require germania-kg/downloadsapi-client:^5.0
```

This package requires a *PSR-18 HTTP client* implementation and a *PSR-17 HTT factory* implementation. Suggestions are [Guzzle 7](https://packagist.org/packages/guzzlehttp/guzzle) via [guzzlehttp/guzzle](https://packagist.org/packages/guzzlehttp/) and Nyholm's [nyholm/psr7](nyholm/psr7) which (despite its name) provides the PSR-17 factories as well:

```
$ composer require nyholm/psr7
$ composer require guzzlehttp/guzzle
```

Basics
------

[](#basics)

### Interface and abstract class

[](#interface-and-abstract-class)

Interface **DownloadsApiInterface** provides public methods for retrieving documents, ***all*** and ***latest*** and ***request***, with the latter for internal use. All of these return an **iterable**. There are also interceptors for the authentication key:

```
// Provided by interface
// Germania\DownloadsApi\DownloadsApiInterface

public function all() : iterable;
public function latest() : iterable;
public function request( string $path ) : iterable ;

public function setAuthentication( ?string $key ) : DownloadsApiInterface;
public function getAuthentication( ) : string;
```

Abstract class **DownloadsApiAbstract** prepares the *all* and *latest* methods to delegate directly to the *request* method. It also utilizes various useful traits such as `Psr\Log\LoggerAwareTrait`, `LoglevelTrait` and `AuthenticationTrait`. – So any class extending this abstract will thus provide:

```
// Inherited from abstract class
// Germania\DownloadsApi\DownloadsApiAbstract

$api->setLogger( \Monolog\Logger( ... ) );

$api->setErrorLoglevel( \LogLevel::ERROR );
$api->setSuccessLoglevel( \LogLevel::INFO );

$api->setAuthentication( "secrete" );
$api->getAuthentication(); // "secret"
```

### PSR-6 Cache Support

[](#psr-6-cache-support)

Class **CacheDownloadsApiDecorator** wraps an existing *DownloadsApi* instance and adds support for *PSR-6 Caches*. It extends *DownloadsApiDecorator* which itself extends *DownloadsApiAbstract*, so the class also implements *DownloadsApiInterface*.

The constructor requires a ***DownloadsApi*** (or *DownloadsApiInterface)* instance and a ***PSR-6 Cache Item Pool***. You may optionally pass a ***cache lifetime*** in seconds which defaults to 14400 (4 hours).

```
