From e116e37648439db730f6c5df7f3b6fdb8e23a17c Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Fri, 13 May 2016 00:31:57 +0200 Subject: [PATCH 1/3] Transmission client --- .../Command/TransmissionStatsCommand.php | 2 +- src/Transmission/Transmission.php | 68 +++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 src/Transmission/Transmission.php diff --git a/src/Transmission/Command/TransmissionStatsCommand.php b/src/Transmission/Command/TransmissionStatsCommand.php index 5562602..51fc68e 100644 --- a/src/Transmission/Command/TransmissionStatsCommand.php +++ b/src/Transmission/Command/TransmissionStatsCommand.php @@ -8,9 +8,9 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Command\Command; use Api\ConfigLoader; use Symfony\Component\Console\Input\ArrayInput; -use Vohof\Transmission; use Transmission\Client\GuzzleClient; use Helper\Formater; +use Transmission\Transmission; class TransmissionStatsCommand extends Command { diff --git a/src/Transmission/Transmission.php b/src/Transmission/Transmission.php new file mode 100644 index 0000000..8c4f871 --- /dev/null +++ b/src/Transmission/Transmission.php @@ -0,0 +1,68 @@ + + */ +class Transmission extends BaseTransmission +{ + public function __construct(array $config, ClientAbstract $client = null) + { + parent::__construct($config, $client); + + $this->config = $config; + + foreach(array('host', 'endpoint') as $requirement) + { + if ( ! isset($config[$requirement])) + { + throw new \InvalidArgumentException("Missing argument: $requirement"); + } + } + + if (is_null($client)) + { + $options = array(); + + if (isset($config['username']) and isset($config['password'])) + { + $options = array( + 'request.options' => array( + 'auth' => array($config['username'], $config['password']) + ) + ); + } + + $this->client = new GuzzleClient($config['host'], $options); + } + else + { + $this->client = $client; + } + + $this->client->setEndpoint($config['endpoint']); + } + + // public function add($url, $isEncoded = false, $options = array()) + // { + // $options[$isEncoded ? 'metainfo' : 'filename'] = $url; + + // return $this->client->request('torrent-add', $options); + // } + + // public function foo() + // { + // $options = [ + // 'fields' => static::$fields, + // 'ids' => ['all'], + // ]; + // + // return $this->client->request('torrent-get', $options); + // } +} + From f174796f74c93ded4600dc4d65bbf460e82a561a Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 21 Nov 2016 01:35:25 +0100 Subject: [PATCH 2/3] API domain updated --- src/Api/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/Client.php b/src/Api/Client.php index eb1a167..f9c52a0 100644 --- a/src/Api/Client.php +++ b/src/Api/Client.php @@ -13,7 +13,7 @@ class Client public function __construct() { - $this->client = new GuzzleClient(['base_url' => 'https://api.t411.ch']); + $this->client = new GuzzleClient(['base_url' => 'https://api.t411.li']); } public function getAuthorization($username, $password) From ecb6b89518094e2ad3249fb37f3565ec4be3b6e3 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sat, 25 Mar 2017 22:14:50 +0100 Subject: [PATCH 3/3] Change api.t411.li to api.t411.ai --- src/Api/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/Client.php b/src/Api/Client.php index f9c52a0..3eec534 100644 --- a/src/Api/Client.php +++ b/src/Api/Client.php @@ -13,7 +13,7 @@ class Client public function __construct() { - $this->client = new GuzzleClient(['base_url' => 'https://api.t411.li']); + $this->client = new GuzzleClient(['base_url' => 'https://api.t411.ai']); } public function getAuthorization($username, $password)